Configuration
/

DB Migration

DB Migration

DB Migration is a process used to manage and implement changes to an application's database. This process is used in scenarios such as database schema updates, data migrations and changes in data storage technologies.

Use Cases of DB Migration

  • Database Schema Changes:
    • Add new columns
    • Rename existing tables
    • Create new indexes
    • Editing the table structure
  • Database Reconfiguration:
    • Change database management system (e.g. from SQL to NoSQL)
    • Transforming the database into a more optimized structure
  • Data Migration:
    • Maintain data integrity when moving data from one environment to another
    • Prevent data loss and optimize database performance

DB Migration Operations on Kuika Platform

Kuika platform offers the following steps to manage DB Migration operations.

1. Start DB Migration Process

  • Click on the three dots next to the Preview icon in the Header section.
  • In the window that opens, click on one of the Get Source Code or Export buttons.
  • Backend and frontend code will be delivered via email.

You may need to upgrade your subscription plan to download the source code. Visit the Pricing Page for more information.

2. Backend Codes and SQL Scripts

  • Backend codes contain the SQL scripts required for the database to which the application is connected.
  • SQL scripts create the structures of tables such as foreign key, primary key and index in other databases.
  • These scripts create the database structures necessary for the application to run locally or in a different environment.

3. Running Scripts

  • The generated SQL scripts are included in the backend files but are not executed automatically.
  • These scripts are run using the DB Migration API.

DB Migration APIs

On the Kuika platform, the following APIs are used during DB Migration operations:

1. Checksum API

  • GET /v1/api/DbMigration/checksum/current
    • Expresses the current state of the database (schema and data structure).
  • GET /v1/api/DbMigration/checksum/source
    • Refers to the source database or schema (the data from which changes will be made).

2. IsSame (Comparison)

  • The IsSame API compares the differences between the current database schema and the target database schema.
  • This determines which changes are required.

3. Execute Migration

  • The Execute Migration API runs SQL scripts sequentially to apply the specified changes.
  • In the Swagger documentation, this API is located under DbMigration/executeMigration.

DB Migration Process

  1. Database Schema and Data Status Analysis
    • Current: Current database schema and data state.
    • Source: Source database schema and data state.
  2. Comparison (IsSame)
    • The current situation is compared with the source situation.
    • Differences are detected.
  3. Execute Migration Scripts
    • SQL scripts are run sequentially.
    • Each table or column is assigned a UNIQUE ID and comparisons are made on these IDs.
  4. Result
    • The database schema and data are transformed into the target structure.

Features of SQL Scripts

  • Creates new tables.
  • Updates existing tables.
  • Add or remove indexes.
  • Assigns IDs to tables and columns and makes comparisons.

Checksum: A unique digest is taken from each table and column in the database.

Rename Operations: If the name of a column or table has changed, this difference is detected and the script is edited accordingly.

By following these steps, you can easily perform database migration operations on the Kuika platform.

No items found.

Other Related Content

No items found.

Glossary

No items found.

Alt Başlıklar