Building Blocks > Common Building Blocks > Database Connection Building Block > 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 the building blocks can be synchronized with the database schema. For example, after adding a foreign key, adding custom properties to entities in the data model, 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 GetDBInfo service on each of the managers that are specified in the DefaultGlobalManagerConfiguration configuration table on the PTC.Base.Manager Thing.
The synchronization services compare both the Data Shapes and the database information specified in the GetDBInfo services to the schema of the database, and identify any differences between them. The ValidateDBSchema service on the PTC.DBConnection.Manager Thing outputs a list of all the differences for your review. The UpdateDBSchema service on the PTC.DBConnection.Manager Thing 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. For more information, see Adding or Removing Foreign Keys, Adding Custom Properties to Data Model Entities, and Adding Custom Entities to the Data Model.
2. Navigate to the PTC.DBConnection.Manager 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 the manager Things. 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?