Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion source/commands/env/copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,54 @@ export const options = zod.object({
"Optional: Set the environment conflict strategy. In case not set, will use 'fail'.",
}),
),
dataMigration: zod
.boolean()
.optional()
.default(false)
.describe(
option({
description:
'Optional: Migrate data (users, roles, etc.) from source to target environment after copying.',
}),
),
skipResources: zod
.boolean()
.optional()
.default(false)
.describe(
option({
description:
'Optional: When migrating data, skip resource instances, attributes, and tuples.',
}),
),
skipUsers: zod
.boolean()
.optional()
.default(false)
.describe(
option({
description:
'Optional: When migrating data, skip users, role assignments, and user attributes.',
}),
),
});

type Props = {
readonly options: zInfer<typeof options>;
};

export default function Copy({
options: { apiKey, from, to, name, description, conflictStrategy },
options: {
apiKey,
from,
to,
name,
description,
conflictStrategy,
dataMigration,
skipResources,
skipUsers,
},
}: Props) {
return (
<>
Expand All @@ -79,6 +119,9 @@ export default function Copy({
name={name}
description={description}
conflictStrategy={conflictStrategy}
dataMigration={dataMigration}
skipResources={skipResources}
skipUsers={skipUsers}
/>
</AuthProvider>
</>
Expand Down
90 changes: 90 additions & 0 deletions source/commands/env/data-migration.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import React from 'react';
import { option } from 'pastel';
import zod from 'zod';
import { type infer as zInfer } from 'zod';
import { AuthProvider } from '../../components/AuthProvider.js';
import DataMigrationComponent from '../../components/env/DataMigrationComponent.js';

export const description =
'Migrate users and data from one environment to another';

export const options = zod.object({
key: zod
.string()
.optional()
.describe(
option({
description:
'Optional: API Key to be used for the data migration (should be at least a project level key). If not set, CLI lets you select one',
alias: 'k',
}),
),
source: zod
.string()
.optional()
.describe(
option({
description:
'Optional: Environment ID to migrate data from. If not set, the CLI lets you select one.',
}),
),
target: zod
.string()
.optional()
.describe(
option({
description:
'Optional: Environment ID to migrate data to. If not set, the CLI lets you select one.',
}),
),
skipResources: zod
.boolean()
.optional()
.default(false)
.describe(
option({
description:
'Optional: Skip migration of resource instances, attributes, and tuples.',
}),
),
skipUsers: zod
.boolean()
.optional()
.default(false)
.describe(
option({
description:
'Optional: Skip migration of users, role assignments, and user attributes.',
}),
),
conflictStrategy: zod
.enum(['override', 'fail'])
.default('override')
.optional()
.describe(
option({
description:
"Optional: Strategy to handle migration conflicts. Default is 'override'.",
}),
),
});

type Props = {
readonly options: zInfer<typeof options>;
};

export default function DataMigration({
options: { key, source, target, skipResources, skipUsers, conflictStrategy },
}: Props) {
return (
<AuthProvider permit_key={key} scope={'project'}>
<DataMigrationComponent
source={source}
target={target}
skipResources={skipResources}
skipUsers={skipUsers}
conflictStrategy={conflictStrategy}
/>
</AuthProvider>
);
}
Loading
Loading