Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@
text: az postgres flexible-server migration update --subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --resource-group testGroup --name testserver --migration-name xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --db-names db1 db2
- name: Allow the migration workflow to overwrite the DB on the target.
text: az postgres flexible-server migration update --subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --resource-group testGroup --name testserver --migration-name xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --overwrite-dbs
- name: Cutover the data migration. After this is complete, subsequent updates to the source DB will not be migrated to the target.
text: az postgres flexible-server migration update --subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --resource-group testGroup --name testserver --migration-name xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --cutover
- name: This command helps in starting the data migration immediately between the source and target. Any migration scheduled for a future date and time will be cancelled.
text: az postgres flexible-server migration update --subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --resource-group testGroup --name testserver --migration-name xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --start-data-migration
"""
Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/rdbms/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,8 @@ def handle_migration_parameters(command_group, server_name_arg_type, migration_i
help='Space-separated list of DBs to migrate. A minimum of 1 and a maximum of 8 DBs can be specified. You can migrate more DBs concurrently using additional migrations. Note that each additional DB affects the performance of the source server.')
c.argument('overwrite_dbs', options_list=['--overwrite-dbs'], action='store_true', required=False,
help='Allow the migration workflow to overwrite the DB on the target.')
c.argument('cutover', options_list=['--cutover'], action='store_true', required=False,
help='Cut-over the data migration. After this is complete, subsequent updates to the source DB will not be migrated to the target.')
c.argument('start_data_migration', options_list=['--start-data-migration'], action='store_true', required=False,
help='Reschedule the data migration to start right now.')
elif scope == "delete":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ def migration_create_func(cmd, client, resource_group_name, server_name, propert
raise FileOperationError("Properties file does not exist in the given location")
with open(properties_filepath, "r") as f:
try:
request_payload = json.load(f)
request_payload.get("properties")['TriggerCutover'] = 'true'
json_data = json.dumps(request_payload)
json_data = json.dumps(json.load(f))
except ValueError as err:
logger.error(err)
raise BadRequestError("Invalid json file. Make sure that the json file content is properly formatted.")

if migration_name is None:
# Convert a UUID to a string of hex digits in standard form
migration_name = str(uuid.uuid4())
Expand All @@ -95,7 +94,7 @@ def migration_list_func(cmd, client, resource_group_name, server_name, migration
return r.json()


def migration_update_func(cmd, client, resource_group_name, server_name, migration_name, setup_logical_replication=None, db_names=None, overwrite_dbs=None, start_data_migration=None):
def migration_update_func(cmd, client, resource_group_name, server_name, migration_name, setup_logical_replication=None, db_names=None, overwrite_dbs=None, cutover=None, start_data_migration=None):

subscription_id = get_subscription_id(cmd.cli_ctx)

Expand All @@ -119,6 +118,12 @@ def migration_update_func(cmd, client, resource_group_name, server_name, migrati
operationSpecified = True
properties = "{\"properties\": {\"overwriteDBsInTarget\": \"true\"} }"

if cutover is True:
if operationSpecified is True:
raise MutuallyExclusiveArgumentError("Incorrect Usage: Can only specify one update operation.")
operationSpecified = True
properties = "{\"properties\": {\"triggerCutover\": \"true\"} }"

if start_data_migration is True:
if operationSpecified is True:
raise MutuallyExclusiveArgumentError("Incorrect Usage: Can only specify one update operation.")
Expand Down