Associating script versions with subscriptions

Starting in version 12.0.0, new functionality greatly simplifies the process of performing schema changes to remote databases. To use this functionality, you must stop using the dbmlsync ScriptVersion extended option. Instead, you should associate your script version directly with your synchronization subscription using new clauses that have been added to the CREATE SYNCHRONIZATION SUBSCRIPTION and ALTER SYNCHRONIZATION SUBSCRIPTION statements.

When you use the new syntax, each database transaction is uploaded using the script version that was associated with the subscription at the time the transaction occurred. This makes it possible to perform a schema change that requires a script version change without synchronizing.

When using the older ScriptVersion extended option, the script version is associated with the transaction at synchronization time. As a result, you must synchronize before any schema change.

A few existing synchronization systems depend on changing the script version used by a subscription between synchronizations for reasons other than schema changes. It may not be possible to update these systems to use the new functionality.

Going forward, it is recommended that you always specify the SCRIPT VERSION clause when you create a synchronization subscription. Existing subscriptions can be upgraded by following the instructions below.

If you have an existing subscription named my_sub that you synchronize using the dbmlsync ScriptVersion extended option, here are the steps to associate your script version directly with your subscription.

 To associate a script version with a subscription
  1. Determine the script version currently being used to synchronize my_sub. The easiest way to do this is as follows:

    1. Add the -v+ option to your existing dbmlsync command line and synchronize.

    2. Look in your dbmlsync output file for a line that identifies the script version being used. Look for something similar to the following:

      Script version: my_script_ver_1
  2. Associate the current script version with the subscription:

    ALTER SYNCHRONIZATION SUBSCRIPTION <sub_name>
    SET SCRIPT VERSION = <ver>

    where <sub_name> is the name of the subscription, in this case my_sub and <ver> is the current script version, determined in step 1.

    All transactions that occur after this point are associated with the script version.

  3. Synchronize one last time using your old options. This ensures that any transactions that occurred before you completed step 2 are uploaded with the correct script version.

  4. Remove the ScriptVersion extended option wherever it is specified for this subscription. The extended option may be specified on the dbmlsync command line, in a synchronization profile or associated with a subscription, publication or MobiLink user in the remote database.

For databases that contain more than one subscription, repeat the previous procedure for each subscription.