Customizing Information Content and Access > Database Activities > Synchronizing the Database Information and the Database Schema
Synchronizing the Database Information and the Database Schema
Updates to the database information specified in ThingWorx Apps can be synchronized with the database schema. For example, after adding a foreign key, adding custom properties to entities in Operator Advisor, or adding new entities to the data model, synchronizing the database information with the database schema adds the new information to the database schema. The synchronization services look at the database information specified in the services which are called by the GetDBInfo service on each of the managers that are specified in the ManagerConfigurationSettings configuration table on the launch point configuration Thing (PTC.Factory.C_LaunchPointConfigurationThing_[ReleaseVersion]).
For example, for entities in the Operator Advisor data model, the GetDBInfo service on the PTC.SCA.SCO.DefaultProductionOrderManager calls services including GetJobOrderDBInfo and GetWorkDefinitionDBInfo.
The synchronization services compare both the Data Shapes and the database information specified in the Get<entity>DBInfo services to the schema of the database, and identify any differences between them. The ValidateDBSchema service outputs a list of all the differences for your review. The UpdateDBSchema service adds any new tables, columns, indexed fields, or foreign keys that are specified in the database information, but are not yet present in the database schema. The update service only adds new information to the database schema. No existing data in the database, or anything that is already present in the database schema, is updated or removed by the update service. No column lengths or data types are changed, and no tables, columns, indexes or foreign keys are removed. These differences are reported for your convenience in the output of the synchronization services. A database administrator can make any of these changes manually to the database as needed.
To synchronize the database information and the database schema, complete the following steps.
1. Make any updates to the database information within ThingWorx Apps. For more information, see Adding or Removing Foreign Keys, Adding Custom Properties to Operator Advisor Entities, and Adding Custom Entities to the Operator Advisor Data Model.
2. Navigate to the PTC.SCA.SCO.DatabaseManager Thing.
3. Under Services, execute the ValidateDBSchema service. The output of the service is an infotable listing all of the differences found between the database schema and the Data Shapes and database information in ThingWorx Apps and Operator Advisor. Review the output of the service to ensure that the differences are as expected. If no differences are found, then the infotable displays "No data".
4. Under Services, execute the UpdateDBSchema service. The service output is an infotable listing everything that was successfully added to the database schema such as new tables, columns, indexed fields or foreign keys. Any failures are also listed in the infotable.
Was this helpful?