DB Migration

DB Migration, which involves moving software application data from one database to another, typically involves data transfers, database schema updates, and changes in data storage technologies.
  • Database Schema Changes: Used to update a software application's database schema. This can include actions like adding a new column, renaming an existing table, or adding a new index to a table.
  • Database Restructuring: Utilized when changing a software application's database management system or technology. For instance, if an application moves from an SQL database to a NoSQL database, such a transformation may be necessary.
DB Migration aims to maintain data integrity, prevent data loss, and optimize database performance, assisting software developers and database administrators in successfully carrying out data migration tasks.
For DB Migration processes within the platform, click on the Rocket icon in the Header. In the window that opens, click either the Download source code or Publish buttons. The generated Backend and Frontend code can be obtained from the email sent to you.
Backend codes include SQL scripts.
SQL scripts are needed to recreate structures like foreign keys, primary keys, indexes, etc., in another database, which are present in tables created within the Managed DB to which the application is connected. It is important that the database within the application is in complete harmony with the database set up in the On-Prem or other environments during the publication process.
SQL scripts are located in the backend file, but they do not run automatically when the application backend is launched.
When the Backend of the application is previewed, an API named Db Migration comes up.
  • Get /v1/api/DbMigration/checksum/current
When generating code, the current checksum of the database to which it is connected is taken.
Checksum refers to a mathematical value based on a specific algorithm representing data. This value represents the sum of the data. Each piece of data has a summary value.
It represents the current state of the database, either its current 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 taken from.
  • IsSame (Is it the same?):
The term IsSame or Is it the same? refers to comparing the current database schema or data with the target database schema or data. The DB Migration process determines changes by comparing these two states.
  • ExecuteMigration (Perform Migration):
The term ExecuteMigration or Perform Migration refers to the process of implementing identified changes. This process performs schema updates to transform the current state into the target state, i.e., running the generated scripts in succession.
SQL Scripts are text files used to modify or update the database schema. These scripts include operations such as altering the current database schema, adding new tables, updating existing tables, and creating or deleting indexes.
A unique ID is generated and assigned when creating each column or table in the SQL Script. For example, when a new table is created in the Datasource area of the platform, an ID is generated for that table. The columns within the created table are also assigned IDs. Thus, during the execution of DB Migration, these IDs are taken from the source code. This ID is used to find a column and compare whether its name is the same as the most recently given column name. The output of this comparison includes Renames.
To better understand how the DB Migration process works, consider the following steps:
First, the current database schema and data are considered as Current.
The DB Migration process examines the source database or schema to determine the necessary changes.
An IsSame comparison is made, and differences are identified.
After identifying the changes, the ExecuteMigration step is performed. This applies updates needed to transform the current database schema or data into the targeted schema or data.
The DB Migration process makes updating the database schema more systematic and controllable.
In short, when you click Download source, these scripts are created in the background by kuika. These scripts are embedded into the code. An external API is opened to run these scripts. The name of this API in Swagger is excutemigration under DbMigration. When this API is executed, the SQL scripts created in the background are run in sequence. As a result of these processes, the database is Migrated on the other side.
Last modified 3mo ago