When you run the migration, the migration tool executes the following scripts:
If the ANSI_Migration database is missing, the first script will create it.
In this database, Isah stores the migration scripts and the migration results for all migration runs performed on this server.
The next script creates a system stored procedure that collects all relevant data for the objects that are hit during a migration. Isah uses this stored procedure to collect the data before and after migration, in order to check whether all objects are as expected, and no data are lost.
The third script generates the actual migration statements and executes these statements.
The statements generated, together with the results of the execution of these statements, are also stored in the ANSI_Migration database. The third script, the script that generates and executes the migration statements, is mostly run in single user mode. Running this script in single user mode will prevent users from changing the data during the migration.
The final step generates migration reports.
Steps of migration script 3: Generation and Execution
Set the database in single user mode.
Check if replication is active. Exit with an error if it is.
Check if the database is an Isah database. Exit with an error if it isn’t.
Create a migration run and log the start of the migration.
Log which tables must be migrated.
Log which tables will be skipped during the migration process.
Log the database structure before migration.
Disable the Isah SQL Server Agent jobs.
This step should generate a warning that the SQL Server Agent could not be notified because it is not running.
Generate the migration statements and store these statements.
Execute the generated statements that can be executed in single user mode.
Log the execution and execution errors of these statements.
Set the database in multi-user mode.
Execute the generated statements that cannot be executed in single-user mode.
If applicable, log the execution and execution errors of these statements.
Enable the Isah SQL Server Agent jobs.
This step should generate a warning that the SQL Server Agent could not be notified because it is not running.
Log the database structure after migration
Log the end of the migration
Substeps of the generation Phase
Generate statements to disable all constraints and triggers in the database.
Generate statements to drop change tracking in the database.
Generate statements to recreate change tracking.
Generate statements to enable all constraints and triggers in the database.
Substeps for table migration
Generate statements to drop foreign keys from and to the table.
Generate a statement to drop the fulltext index on the table.
Generate statements to drop the triggers on the table.
Generate statements to drop constraints on the table.
Generate a statement to rename the primary key.
Generate a statement to rename the table.
Generate a statement to create the table with ANSI_NULLS = ON.
The primary key is part of the create table script.
Generate a statement to add the clustered index again.
Generate a statement to transfer the data from the old table to the new one.
This includes dropping the old table if the data transfer was successful.
Generate statements to add all non-clustered indexes.
Generate statements to add the check constraints.
Generate statements to recreate the foreign keys.
Generate statements to add the grants again.
Generate statements to recreate unique constraints.
Generate statements to recreate the fulltext index.
This statement is marked as a statement that must be run in multi-user mode.
Generate statements to recreate the triggers.
Substeps of the single-user execution phase
In order of generation, retrieve the generated statements marked as singleuser, one by one.
Log the start of the execution of the statement.
Execute the statement.
If the statement failed, log the error information returned.
Log the end of the execution of the statement.
If the statement failed and if the statement was a data transfer statement:
Generate and log a statement to undo the data transfer.
Execute the generated undo statement.
If the undo failed, log the error information of the undo statement.
Substeps of the multi-user execution phase
In order of generation, retrieve the generated statements marked as single-user, one by one.
Log the start of the execution of the statement.
Execute the statement.
If the statement failed, log the error information returned.