Skip to content

7.4. Flyway Configuration

7.4.1. application.yml

yaml
spring:
  flyway:
    enabled: true
    locations: classpath:db/migration
    baseline-on-migrate: false
    validate-on-migrate: true
    out-of-order: false
SettingValueDescription
enabledtrueEnable automatic Flyway execution
locationsclasspath:db/migrationMigration file location
baseline-on-migratefalseDisable automatic baseline application on existing DB
validate-on-migratetrueVerify migration file integrity
out-of-orderfalseProhibit out-of-order migrations

7.4.2. Profile-specific Settings

yaml
# application-local.yml
spring:
  flyway:
    clean-disabled: false    # Allow clean only in local environment
yaml
# application-prod.yml
spring:
  flyway:
    clean-disabled: true     # Absolutely prohibit clean in production
    baseline-on-migrate: false

Required

flyway:clean must never be executed in a production environment. clean-disabled: true must always be configured.

7.4.3. Maven Plugin

Used for executing migrations independently in CI/CD or for applying the schema before jOOQ codegen.

xml
<plugin>
  <groupId>org.flywaydb</groupId>
  <artifactId>flyway-maven-plugin</artifactId>
  <configuration>
    <url>jdbc:postgresql://localhost:5432/flowin</url>
    <user>flowin</user>
    <password>flowin1234</password>
    <locations>
      <location>filesystem:src/main/resources/db/migration</location>
    </locations>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>${postgresql.version}</version>
    </dependency>
    <dependency>
      <groupId>org.flywaydb</groupId>
      <artifactId>flyway-database-postgresql</artifactId>
      <version>${flyway.version}</version>
    </dependency>
  </dependencies>
</plugin>
bash
# Execute migrations
mvn flyway:migrate

# Check migration status
mvn flyway:info

# Validate migrations
mvn flyway:validate

TIENIPIA QUALIFIED STANDARD