DB Migration is the process by which a software application moves data from one database to another, making data migration, database schema updates and data storage technology changes between frequently used cases.
DB Migration helps software developers and database administrators to successfully perform data migration while maintaining data integrity, preventing data loss and optimizing database performance.
For DB Migration operations within the platform, click on the Rocket icon in the Header. In the window that opens, click on one of the Download source code or Publish buttons. You can get the generated Backend and Frontend code from the e-mail sent to you.
SQL scripts are included in the backend codes.
SQL scripts are required to create structures such as foreign key, primary key, index in the tables created in the Managed DB to which the application is connected. In the process of publishing the application on On-Prem or in another environment, it is important that the database in the application is compatible with the installed database.
SQL scripts are included in the backend file. However, these scripts do not run automatically when the application backend stands up.
When the Backend of the application is previewed, an API called DB Migration comes.
Get /v1/api/DbMigration/checksum/current
When generating a script, the current checksum of the database it is connected to is taken.
Checksum is a mathematical value of the data based on a specific algorithm. This value represents the sum of the data. Each piece of data has a summary value.
It expresses the current state of the database. This represents the current database schema or data.
Get /v1/api/DbMigration/checksum/source:
Refers to the source database or database schema in the DB Migration process. This is where the current state will change. It is where everything in the database is retrieved.
The term “IsSame” or “Is it the same?” refers to the comparison between the current database schema or data and the target database schema or data. By comparing these two states, the DB Migration process determines the changes.
The term ExecuteMigration or “Perform Migration” refers to the process of applying the specified changes. This process performs schema updates to transform the current state into the target state. In other words, it ensures that the generated scripts are executed successively.
SQL Scripts are text files used to modify or update the database schema. These scripts include operations such as changing the structure of the existing database schema, adding new tables, updating existing tables, creating or deleting indexes.
When creating each column or each table in the SQL Script, a UNIC ID is generated and assigned to that table or that column. For example, when a new table is created in the Datasource field within the platform, an Id is created for that table. The columns in the created table are created in the same way. Therefore, when running DB Migration, these Ids are taken from the source code. With this Id, it finds a column and compares whether its name and the name of the last column are the same or not.
To better understand how the DB Migration process works, you can review the steps below:
First, the existing database schema and data is considered Current.
The DB Migration process examines the Source database or schema to determine what changes are needed.
An IsSame comparison is performed and differences are identified.
Once the changes have been identified, the ExecuteMigration step is performed. This applies the updates needed to convert the existing database schema or data to the targeted schema or data.
The DB Migration process makes the update of the database schema more systematic and controllable.
In short, these scripts are created by Kuika in the background when Download source is clicked. These scripts are embedded in the code. In order to run these scripts, an API is opened to the outside. This API name is excutemigration under DbMigration in Swagger. When this API is run, the SQL scripts created in the background are executed respectively. As a result of these operations, the database is migrated on the other side.