Skip to content

bootique/bootique-flyway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build test deploy Maven Central

bootique-flyway

Provides Flyway migrations framework integration with Bootique. See usage example bootique-flyway-demo.

Setup

Add proper dependencies. Here is a Maven example:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.bootique.bom</groupId>
            <artifactId>bootique-bom</artifactId>
            <version>4.XX</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependency>
    <groupId>io.bootique.flyway</groupId>
    <artifactId>bootique-flyway</artifactId>
</dependency>

Unless you are using MySQL or PostgreSQL (those will work out of the box), you will also need to include DB-specific Flyway plugin as a dependency. Make sure you use the same version of the "plugin" as the Flyway version provided by Bootique. E.g.:

<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-database-snowflake</artifactId>
    <version>X.XX</version>
</dependency>

You can check the Maven Central repo for the list of supported "plugins".

Available commands

bootique-flyway provides 6 commands: Migrate, Clean, Info, Validate, Baseline and Repair that can be called via CLI options:

  -b, --baseline
       Baselines an existing database, excluding all migrations up to and including baselineVersion.

  --clean
       Drops all objects (tables, views, procedures, triggers, ...) in the configured schemas.The schemas are cleaned in the order specified by the schemas property.

  -i, --info
       Prints the details and status information about all the migrations.

  -m, --migrate
       Migrates the schema to the latest version. Flyway will create the metadata table automatically if it doesn't exist.

  -r, --repair
       Repairs the metadata table.

  -v, --validate
       Validate applied migrations against resolved ones (on the filesystem or classpath) to detect accidental changes that may prevent the schema(s) from being recreated exactly.

Configuration

YAML configuration file

flyway:
  locations:
    - bogus
  configFiles:
    - classpath:io/bootique/flyway/explicitNonDefaultMigrationConfigfile.conf
  dataSources:
    - test

Only three flyway options are recognized:

  • locations: a list of Flyway locations to look for Flyway migrations
  • configFiles: a list of Flyway configuration files (as custom config files, see https://flywaydb.org/documentation/commandline/)
  • dataSources: a list of JDBC connections

Using custom config files allows you to more easily run Flyway using a file for database connection settings (the Bootique YAML file) and application settings in a Flyway file.

Flyway configuration file

Here is a Flyway test configuration file: classpath:io/bootique/flyway/explicitNonDefaultMigrationConfigfile.conf.

flyway.locations = path/migration