GUID Replacer

Database identifiers for Routines, Features and Samples in a CM4D Database must be unique within the Site database. When a CM4D database is copied (i.e., backup/restore) and added as a new Managed Datasource to a different Site database, problems may occur if there are GUID conflicts with other CM4D databases managed by that Site database. The GUID Replacer is a utility that reassigns Routine, Feature and Sample GUIDs in a CM4D Database. The GUIDs can replaced all at once or for only Routines/Features/Samples individually, and each option can be done in batches. This tool can be used on any CM4D database with errors related to GUID conflicts. This utility is included with CM4D Server installer and should only be run by users with a clear knowledge of CM4D and its databases.

Running the GUID Replacer will not corrupt existing data in the database. However, the utility is only intended for use when necessary and by the appropriate personnel.

Original New GUIDs

This utility is located in the following directory: .\CM4D\Database Utilities\GUID Replacer

Database Connection

The GUID Replacer requires a CM4D Datasource connection to the SQL database. This string may be entered manually via the command window or connected automatically by storing the string in the appsettings.json file.

Manual Database Connection

When GUID Replacer is run, type the database connection strings as prompted and hit Enter to continue with the database tasks.

Preset Datasource Connection

Before running the GUID Replacer, open the appsettings.json file in the .\CM4D\Database Utilities\GUID Replacer directory. Add or modify the database connection string as the "NEwT_Datasource" in the "ConnectionStrings" section:

Change this: 

{
  "ConnectionStrings": {
    "NEwT_Datasource": 
  }
}

To this: 

{
"ConnectionStrings": {

"NEwT_Datasource":
"Server=(local)\\MSSQLSERVER01;Database=cm4ddb1;User Id=cm4dservice;Password=cm4d!"
}
}

If your database connection includes an instance name, add a second backslash character between the server and instance name to conform with SQL Server syntax requirements. 

Run GUID Replacer and follow the prompts to complete the required database task.

Database Task Options

Once the database connection is established, first select the scope of the replacement (all areas or separately) then the batch size (number of rows per transfer).

Type the text of the scope option you want to select and hit Enter.

Once you have set the scope, choose the Batch Size:

What is Batch Size?What is Batch Size?

The batch size is the number of rows that are picked up for processing at one time, repeating these batches until the entire set of data is updated.

A batch size of 10 updates all the specified data (all routines, all features, and/or all samples) by groups of 10 rows. A database with 220 Routines processed with a batch size of 10 would process a total of 22 batches.

This allows for some performance tuning of the entire operation, where large databases may be broken up into smaller batches.

Execute a query in SSMS to get an idea of the total number of Routines/Features/Samples your database contains. If there is a large amount of data, you may want to adjust the batch size to allow the database to be updated in chunks rather than waiting for the entire database to be processed.

Once the operation is complete, the command windows closes automatically.

Can we improve this topic?