OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog ServiceOceanBase DataPilot

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog ServiceOceanBase DataPilot
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Cloud

  • Overview
  • Schema evolution
    • Liquibase
    • Flyway
  • Data ingestion
    • Canal
    • dbt
    • Debezium
    • Flink
    • Glue
    • Informatica Cloud
    • Kafka
    • Maxwell
    • SeaTunnel
    • DataWorks
    • NiFi
  • SQL development
    • DataGrip
    • DBeaver
    • Navicat
    • TablePlus
  • Orchestration
    • DolphinScheduler
    • Linkis
    • Airflow
  • Visualization
    • Grafana
    • Power BI
    • Quick BI
    • Superset
    • Tableau
  • Observability
    • Datadog
    • Prometheus
  • Database management
    • Bytebase
  • AI
    • LlamaIndex
    • Dify
    • LangChain
    • Tongyi Qianwen
    • OpenAI
    • n8n
    • Trae
    • SpringAI
    • Cline
    • Cursor
    • Continue
    • Toolbox
    • CamelAI
    • Firecrawl
    • Hugging Face
    • Ollama
    • Google Gemini
    • Cloudflare Workers AI
    • Qoder
    • OpenCode
    • Claude Code
    • GitHub Copilot
    • Codex
    • Jina AI
    • Augment Code
    • Claude Code
    • Kiro
  • Development tools
    • Cloudflare Workers
    • Vercel

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Cloud

Version management with Flyway for OceanBase Cloud

Last Updated:2026-09-04 07:03:30

Prerequisites
Integration configuration
MySQL compatible mode
Oracle compatible mode

Flyway is an open-source database version control tool that tracks database state through a history table, enabling automated migrations. This topic describes how to integrate Flyway with OceanBase Cloud to automate schema changes and maintain version history.

Prerequisites

  1. You have registered an OceanBase Cloud account and created an instance with a MySQL-compatible or Oracle-compatible tenant.

  2. The Flyway server IP has been added to the OceanBase Cloud instance allowlist. For details, refer to Set allowlist groups.

  3. You have obtained the OceanBase Cloud database connection string. For details, refer to:

    • Obtain connection string (MySQL compatible mode)
    • Obtain connection string (Oracle compatible mode)

Integration configuration

MySQL compatible mode

For MySQL-compatible tenants in OceanBase Cloud, we recommend using flyway-core 10.0.0 or later, along with mysql-connector-java and flyway-database-oceanbase components. For earlier Flyway versions, refer to the following table:

OceanBase Version
Flyway Version
Notes
≥ 4.2.5 < 10.x Contact OceanBase Cloud technical support
< 4.2.5 < 9.x Not supported
9.x Contact OceanBase Cloud technical support
  1. Configure Maven dependencies.

    Add the following dependencies to your project's pom.xml:

    <dependencies>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>11.3.2</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.47</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-database-oceanbase</artifactId>
        <version>10.7.2</version>
    </dependency>
    </dependencies>
    
  2. Create migration scripts.

    Under the resources directory of your Maven project, create a db/migration folder and add these SQL files:

    • File 1: V1_1__create_person_table.sql

      CREATE TABLE person (
          id INT NOT NULL,
          name VARCHAR(20) NOT NULL
      );
      
    • File 2: V2_1__add_person_table.sql

      INSERT INTO person (id, name) 
      VALUES (1, 'apple');
      
  3. Implement Java test class.

    Create a FlywayTest Java class for database migration. Modify the connection parameters according to your OceanBase Cloud connection string:

    public class FlywayTest {
        public static void main(String[] args) {
            String url = "jdbc:mysql://host:port/dbName";
            String user = "username";
            String password = "password";
            Flyway flyway = Flyway.configure()
                    .dataSource(url, user, password)
                    .load();
            flyway.baseline();
            flyway.migrate();
        }
    }
    

    Parameter Description:

    • host: OceanBase Cloud database connection endpoint
    • port: OceanBase Cloud database connection port
    • dbName: OceanBase Cloud database name
    • username: Database account name
    • password: Account password
  4. Execute the test.

    After running FlywayTest, verify the created person table and inserted data in your OceanBase Cloud database.

Oracle compatible mode

For the Oracle compatible mode, OceanBase Cloud requires flyway-core 10.9.0 or higher, along with oceanbase-client, flyway-mysql, and flyway-database-oceanbase components.

Note

You can obtain the flyway-database-oceanbase component from the GitHub repository.

  1. Configure Maven dependencies.

    Add these dependencies to your project's pom.xml:

    <dependencies>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>10.9.0</version>
    </dependency>
    <dependency>
        <groupId>com.oceanbase</groupId>
        <artifactId>oceanbase-client</artifactId>
        <version>2.4.11</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-mysql</artifactId>
        <version>10.7.0</version>
    </dependency>
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-database-oceanbase</artifactId>
        <version>10.16.1</version>
        <scope>system</scope>
        <systemPath>/path/to/your/flyway-database-oceanbase-10.16.1.jar</systemPath>
    </dependency>
    </dependencies>
    
  2. Create migration scripts.

    Under the resources directory, create a db/migration folder containing:

    • File 1: V1_1__create_person_table.sql

      CREATE TABLE person (
          id INT NOT NULL,
          name VARCHAR(20) NOT NULL
      );
      
    • File 2: V2_1__add_person_table.sql

      INSERT INTO person (id, name) 
      VALUES (1, 'apple');
      
  3. Implement Java test class.

    Create a FlywayTest class for database migration. Update the connection parameters as needed:

    public class FlywayTest {
        public static void main(String[] args) {
            String url = "jdbc:oceanbase://host:port/";
            String user = "username";
            String password = "password";
            Flyway flyway = Flyway.configure()
            .dataSource(url, user, password)
            .load();
            flyway.baseline();
            flyway.migrate();
        }
    }
    

    Parameter Description:

    • host: OceanBase Cloud database connection endpoint
    • port: OceanBase Cloud database connection port
    • username: Database account name
    • password: Account password
  4. Execute the test.

    After running FlywayTest, verify the created person table and inserted data in your OceanBase Cloud database.

Previous topic

Liquibase
Last

Next topic

Canal
Next
on this page
Prerequisites
Integration configuration
MySQL compatible mode
Oracle compatible mode