This article provides an example of how to complete a multi-table database migration with referential integrity in GenRocket.
Multi-Table Database Migration with Referential Integrity
This example Project contains 2 Domains (User and Address) with 2 Scenarios (UserScenario and AddressScenario). It also contains a DB Migration Configuration.
User Domain Configuration
Two Attributes have been added to the User Domain: creditCard and ssn. These Attributes will be used in Synthetic Data Replacement. For step-by-step instructions on how to add a new Attribute to a Domain, click here.
The SimpleMapReceiver has been assigned to the User Domain. For step-by-step instructions on how to assign a Receiver to a Domain, click here.
A UserScenario has been added to the User Domain as well. For step-by-step instructions on how to add a Scenario to a Domain, click here.
Address Domain Configuration
User Scenario Dashboard
The User Scenario Configuration appears as shown below:
Address Scenario Dashboard
The Address Scenario Configuration appears as shown below:
Database Migration Configuration
A Database Migration Configuration can be created and managed by selecting the Migration Management tab within the Project Dashboard.
Note: To add a new Migration Configuration, click on the New Migration Config button. For step-by-step instructions on how to create a new configuration, click here.
The Migration Configuration for this example is shown below:
Table Config for Department Table
Here, the id column is the Primary Key.
Table Config for Role Table
Here, id column is the Primary Key.
Table Config for User Table
Here, id column is Primary Key, role_id and department_id columns are Foreign Keys.
Table Config for Address Table
Here, user_id column is a Foreign Key to User table's id column.
Based on this configuration, when we run the DB migration, the department, role, user and address tables get migrated following the defined referential integrity.