This document describes the migration system architecture and execution order for OpenMetadata database schema and data migrations.
OpenMetadata uses a hybrid migration system that combines:
- Legacy Flyway migrations (being phased out)
- Native OpenMetadata migrations (current system)
- Extension migrations (for custom/plugin functionality)
The migration system executes in a specific order to ensure database consistency:
1. Flyway Migrations (Legacy)
├── v000__create_server_change_log.sql (Creates migration tracking tables)
├── v001__*.sql
├── v002__*.sql
└── ...
2. Native OpenMetadata Migrations
├── 1.1.0/
├── 1.1.1/
├── 1.2.0/
└── ...
3. Extension Migrations
├── custom-extension-1.0.0/
└── ...
Primary table for tracking all migration executions:
installed_rank: Auto-increment sequence numberversion: Migration version identifier (PRIMARY KEY)migrationFileName: Path to the migration filechecksum: Hash of migration content for integrity validationinstalled_on: Timestamp of migration executionmetrics: JSON/JSONB field for migration execution metrics
Detailed SQL execution logs:
version: Migration version identifiersqlStatement: Individual SQL statement executedchecksum: Hash of the SQL statement (PRIMARY KEY)executedAt: Timestamp of SQL execution
The migration workflow follows this decision tree:
IF native migrations are already executed:
└── Skip all Flyway migrations (they've already run)
└── Execute remaining native migrations
└── Execute extension migrations
ELSE IF no native migrations executed:
├── Execute Flyway migrations (creates SERVER_CHANGE_LOG tables)
├── Execute native migrations
└── Execute extension migrations
bootstrap/sql/migrations/
├── flyway/
│ ├── com.mysql.cj.jdbc.Driver/ # MySQL-specific Flyway migrations
│ │ ├── v000__create_server_change_log.sql
│ │ ├── v001__*.sql
│ │ └── ...
│ └── org.postgresql.Driver/ # PostgreSQL-specific Flyway migrations
│ ├── v000__create_server_change_log.sql
│ ├── v001__*.sql
│ └── ...
├── native/
│ ├── 1.1.0/
│ │ ├── mysql/schemaChanges.sql
│ │ └── postgres/schemaChanges.sql
│ ├── 1.1.1/
│ └── ...
└── extensions/ # Custom extension migrations
└── [extension-name]/
├── mysql/
└── postgres/
MigrationWorkflow: Orchestrates the entire migration processFlywayMigrationFile: Adapter for legacy Flyway migrationsMigrationFile: Handler for native OpenMetadata migrationsMigrationProcess: Executes individual migration steps
Important: While OpenMetadata has removed Flyway as the migration framework, we still use Flyway's SQL parsers for reliable statement splitting:
- MySQL: Uses
org.flywaydb.database.mysql.MySQLParser - PostgreSQL: Uses
org.flywaydb.database.postgresql.PostgreSQLParser
This ensures proper handling of:
- Complex SQL statements with string literals containing semicolons
- Comments (both
--and/* */style) - Escaped characters and quotes
- Database-specific SQL syntax
The parsers split SQL files into individual statements via SqlStatementIterator, which is far more reliable than simple string splitting.
Dependencies: Requires flyway-core and flyway-mysql for SQL parsing only (not migration management).
- Hybrid Approach: Custom migration management + Flyway SQL parsing for reliability
- Backward Compatibility: Flyway migrations continue to work during transition period
- Single Source of Truth: All migrations are tracked in
SERVER_CHANGE_LOGregardless of type - Database Agnostic: Separate migration files for MySQL and PostgreSQL
- Execution Order: Flyway → Native → Extensions ensures proper dependency resolution
- Migration Tracking: v000 Flyway migration creates the tracking infrastructure before any other migrations
-
Missing SERVER_CHANGE_LOG table:
- Ensure v000 Flyway migration has executed
- Check database permissions
-
Migration version conflicts:
- Verify no duplicate version numbers across migration types
- Check migration file naming conventions
-
Database-specific failures:
- Ensure correct SQL syntax for target database (MySQL vs PostgreSQL)
- Validate database-specific features (JSON vs JSONB, AUTO_INCREMENT vs SERIAL)
If migrations fail:
- Check
SERVER_CHANGE_LOGtable for last successful migration - Review
SERVER_MIGRATION_SQL_LOGSfor failed SQL statements - Fix underlying issues and restart migration process
- Use
--forceflag only if absolutely necessary
Migration paths are configured in MigrationConfiguration:
nativePath: Path to native OpenMetadata migrationsflywayPath: Path to legacy Flyway migrationsextensionPath: Path to extension migrations
Example:
migrationConfiguration:
nativePath: "bootstrap/sql/migrations/native"
flywayPath: "bootstrap/sql/migrations/flyway"
extensionPath: "bootstrap/sql/migrations/extensions"