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:
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
PATHpoints to the old Community Editionbinfolder, update it to point to the new Pro Editionbindirectory 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-coredependency with the Pro Editionflyway-pro.
For Maven (inpom.xml):
For Gradle (in<!-- 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>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:
Gradle:<repositories> <repository> <id>flyway-pro-repo</id> <url>https://repo.flywaydb.org/repo</url> </repository> </repositories>repositories { maven { url 'https://repo.flywaydb.org/repo' } } - Step 3: Validate the dependency: Run
mvn dependency:tree(Maven) orgradle dependencies(Gradle) to confirm thatflyway-proappears in your dependency tree instead offlyway-core.
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!
2. Where to set version-related information?
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 haveV1__Create_users_table.sql, your undo script would beU1__Drop_users_table.sql(containing SQL likeDROP TABLE users;). - Execute undo operations: Use
flyway undoin the CLI to undo the last migration; to target a specific version, runflyway undo -target=1. For Maven, runmvn flyway:undo; for Gradle, rungradle flywayUndo.
内容的提问来源于stack exchange,提问作者Latika




