3.2. Synchronization
Synchronization is a mechanism that allows you to work with the same model in different environments and different scenarios. Maybe you work in a local environment? Then you can change the model together with the database structure locally. When it is time to transfer the changes made to another environment, you can synchronize the model with the new environment.
Need to find changes over a period of time? Synchronization can help - assuming your model is versioned in Git.
Synchronization is a tool for comparing the state of a model and the current state of a database with the ability to choose which way to synchronize. Like a diff tools, but with database.
Synchronization can be started at three scope levels. These are database, schema, and table. In each case, the synchronization level depends on the object on which you started synchronization.
The first step the synchronizer will take is to load a list of schemas and tables and then prompt you to select specific objects to synchronize within the scope. We are considering the case of the top level - the database.
At this level you will have the opportunity to select the schemes to synchronize.
You can exclude individual tables from the synchronization process or, conversely, select tables that will be synchronized.
Please note that the first stage is a selection from the real structure of the DBMS. If the model contains objects (tables, schemes) that are not in the DBMS, they will be offered for addition only at the next stage.
After selecting the required objects, OrmFactory will load the detailed structure of the tables. These are columns, primary key, foreign keys, indexes and unique constraints. You may notice a progress bar appearing if the structure is large enough.
In this window you need to select the changes you need. The first column describes the object of changes, the second shows its state relative to the model, and the third - relative to the DBMS. You need to choose which version is "correct": in the model or in the database. If you select the model version, the DBMS will be changed, if the DBMS version, the model will be changed.
The selection works hierarchically. By selecting a table, you select all its contents, by selecting a schema - all tables, by selecting a database - all schemas.
The gray icon in the first column will change depending on your choice. If the choice was made in favor of the model structure, it will become "A", if in favor of the DBMS, then "B". Where there was a mixed choice, the icon will become "AB".
It is not necessary to select each item. Unselected items will remain with a gray icon and the changes will not be applied anywhere.
If you have selected changes that change the structure of the DBMS, then after clicking "OK" OrmFactory will prompt you to check the DDL changes. All changes to the DBMS structure are subject to user confirmation, this is one of the application rules.
In our case, this is the creation of the "test" table. You can add to the DDL, correct it, or cancel the operation by closing the window.