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 individually) then the batch size (number of rows).

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

Once you have set the scope, type N to accept the default batch size value of 100,000.

If you selected Y to change the batch size, type the number of rows you want to replace and hit Enter.

Execute a query in SSMS to get an idea of the total number of Routines/Features/Samples your database contains.
          

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

Can we improve this topic?