Skip to Content

Database Migration

Database Migration allows you to apply changes to a database schema in a controlled and repeatable way.

Instead of manually modifying database structures, migrations record each schema change as a sequence of operations that can be reviewed, versioned, and executed consistently.

Using migrations helps keep development, staging, and production databases synchronized.


Before you begin

Before creating a migration, ensure that you have:

  • Completed your database design
  • Validated the database schema
  • Connected to the target database (if deployment is required)

[!NOTE] Database Migrations modify the database structure. Always review migration scripts before applying them.


Why use migrations?

Database Migrations help you:

  • Track schema changes
  • Synchronize multiple environments
  • Maintain version history
  • Reduce deployment errors
  • Collaborate with team members

Migration workflow

Modify Database Model Detect Schema Changes Generate Migration Review Migration Apply Migration

Create a migration

To create a migration:

  1. Open Database Engineering.
  2. Select Database Migration.
  3. Compare the current schema with the target schema.
  4. Generate a migration.
  5. Review the generated operations.
  6. Save the migration.

Migration operations

A migration may contain operations such as:

OperationDescription
Create TableCreate a new table
Drop TableRemove an existing table
Add ColumnAdd a new column
Remove ColumnDelete a column
Rename ColumnRename a column
Modify ColumnChange a column definition
Add ConstraintCreate a new constraint
Remove ConstraintDelete an existing constraint
Create IndexCreate a new index
Drop IndexRemove an existing index

Review before applying

Before applying a migration, review:

  • Added objects
  • Removed objects
  • Modified columns
  • Constraint changes
  • Relationship updates

Carefully reviewing migrations helps prevent unintended database changes.


Apply a migration

After reviewing the migration:

  1. Select the target database.
  2. Confirm the migration.
  3. Apply the changes.
  4. Verify the updated database schema.

Once completed, the database structure reflects the new schema.


Migration history

Each migration should be stored as part of your project’s history.

Maintaining migration history allows you to:

  • Understand previous database changes
  • Review schema evolution
  • Collaborate with team members
  • Track deployment history

Validation

Before applying a migration, Qubase validates:

  • Invalid operations
  • Missing dependencies
  • Broken relationships
  • Constraint conflicts
  • Unsupported modifications

Validation helps reduce migration failures.


Best practices

  • Review every migration before applying it.
  • Test migrations in a development environment first.
  • Keep migration history under version control.
  • Apply migrations in the correct order.
  • Back up important databases before major schema updates.

[!WARNING] Applying migrations directly to production databases without testing may result in unexpected downtime or data loss.


Last updated on