You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Flyway社区版升级至Pro版分步指南及相关配置咨询

Hey there, let's walk through upgrading Flyway Community to Pro step by step, plus cover all your configuration questions. Here's what you need to know:

升级Flyway社区版到Pro版的分步流程

We'll split this into two scenarios: using the CLI tool, and integrating with Maven/Gradle projects.

CLI Tool Upgrade

  • Step 1: Download the Pro Edition package: Grab the Pro version archive matching your OS (Windows/macOS/Linux) from the Flyway official source. You can either replace the files in your existing Community Edition installation directory, or extract the Pro package to a new directory.
  • Step 2: Update environment variables (if needed): If your system's PATH points to the old Community Edition bin folder, update it to point to the new Pro Edition bin directory instead.
  • Step 3: Verify the upgrade: Open a terminal and run flyway -v. The output should clearly state "Flyway Pro Edition" along with the version number—this confirms the upgrade worked.

Maven/Gradle Project Integration Upgrade

  • Step 1: Replace dependency coordinates: Swap out the Community Edition flyway-core dependency with the Pro Edition flyway-pro.
    For Maven (in pom.xml):
    <!-- Replace your existing flyway-core dependency -->
    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-pro</artifactId>
        <version>9.22.3</version> <!-- Use your desired Pro version number -->
    </dependency>
    
    For Gradle (in build.gradle):
    // Replace your existing flyway-core dependency
    implementation 'org.flywaydb:flyway-pro:9.22.3'
    
  • Step 2: Configure the Pro repository: To fetch the Pro dependency, add Flyway's dedicated repository to your build config.
    Maven:
    <repositories>
        <repository>
            <id>flyway-pro-repo</id>
            <url>https://repo.flywaydb.org/repo</url>
        </repository>
    </repositories>
    
    Gradle:
    repositories {
        maven { url 'https://repo.flywaydb.org/repo' }
    }
    
  • Step 3: Validate the dependency: Run mvn dependency:tree (Maven) or gradle dependencies (Gradle) to confirm that flyway-pro appears in your dependency tree instead of flyway-core.
Key Configuration Details

1. Where to configure the Pro Edition license?

The most universal way is in your flyway.conf file:

# Replace with your valid Pro license key from Flyway
flyway.licenseKey=your-pro-license-key-here

If you're using a build tool, you can also set it directly in the plugin configuration:

  • Maven plugin:
    <plugin>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-maven-plugin</artifactId>
        <version>9.22.3</version>
        <configuration>
            <licenseKey>your-pro-license-key-here</licenseKey>
            <!-- Add other configs like database connection details -->
        </configuration>
    </plugin>
    
  • Gradle plugin:
    flyway {
        licenseKey = 'your-pro-license-key-here'
        // Add other configs
    }
    

Note: Keep your license key secure—never commit it to public code repositories!

Flyway's version control is centered around migration script naming (e.g., V1__Create_users_table.sql where V1 is the version number). Additionally, you can control version behavior in flyway.conf:

# Specify the target version to migrate to
flyway.target=3
# Allow executing scripts with version numbers lower than the current migrated version (out-of-order migrations)
flyway.outOfOrder=true
# Automatically baseline existing databases with unmanaged objects
flyway.baselineOnMigrate=true

To set the version of Flyway Pro itself, define it in your build tool's dependency/plugin configuration (like the version numbers shown in the upgrade steps above).

3. Extra configuration to enable Pro's undo feature

Undo is a Pro-exclusive feature—here's how to set it up:

  • Confirm database support: Most mainstream databases (MySQL, PostgreSQL, SQL Server, etc.) support undo operations. Double-check that your database is on Flyway's supported list.
  • Enable undo in flyway.conf:
    flyway.undo.enabled=true
    
  • Write corresponding undo scripts: Undo scripts must match your migration scripts using the format U<version>__<description>.sql. For example, if you have V1__Create_users_table.sql, your undo script would be U1__Drop_users_table.sql (containing SQL like DROP TABLE users;).
  • Execute undo operations: Use flyway undo in the CLI to undo the last migration; to target a specific version, run flyway undo -target=1. For Maven, run mvn flyway:undo; for Gradle, run gradle flywayUndo.

内容的提问来源于stack exchange,提问作者Latika

火山引擎 最新活动