Home

Awesome

Flywaydb Cookbook

Cookbook Version linux win

Installs flywaydb and allows for execution of flyway commands via resource actions.

Connector/J Drivers

Requirements

Platforms

Usage

Use migrate, info, validate, baseline, or repair actions to install flywaydb (if not installed) and execute associated flyway command. An install action is also available if you just want to install flywaydb but not execute any flyway commands.

Attributes

Examples

Single migration using settings

flywaydb 'myapp' do
  flyway_conf(
    url: 'jdbc:mysql//localhost/mydb',
    user: 'root',
    locations: 'filesystem:/opt/myapp/db/migration',
    cleanDisabled: true
  )
  action :migrate
end

Single migration using file path

flywaydb 'myapp' do
  flyway_conf(
    '/opt/myapp/db/flyway.conf'
  )
  action :migrate
end

Multiple migrations using settings

flywaydb 'myapp' do
  flyway_conf(
    user: 'root',
    url: 'jdbc:mysql//localhost/mysql'
  )
  alt_conf([
    {
      schemas: 'custA',
      locations: 'filesystem:/opt/myapp/db/migration/core,/opt/myapp/db/migration/custA'
    },
    {
       schemas: 'custB',
       locations: 'filesystem:/opt/myapp/db/migration/core,/opt/myapp/db/migration/custB'
    }
  ])
  parameters(
    password: password   
  )
  action :migrate
end

Multiple migrations using file paths

flywaydb 'myapp' do
  flyway_conf(
    '/opt/myapp/db/flyway.conf'
  )
  alt_conf([
    '/opt/myapp/db/custA.conf',
    '/opt/myapp/db/custB.conf'
  ])
  parameters(
    password: password   
  )
  action :migrate
end

ChefSpec Matchers

This cookbook includes custom ChefSpec matchers you can use to test your own cookbooks.

Example Matcher Usage

expect(chef_run).to migrate_flywaydb('flyway').with(
  flyway_conf: {
      'user' => 'root',
      'url' => 'jdbc:mysql://localhost/mysql'
  }
  alt_conf: [
    {
      'schemas' => 'custA',
      'locations' => 'filesystem:/opt/myapp/db/migration/core,/opt/myapp/db/migration/custA'
    },
    {
      'schemas' => 'custB',
      'locations' => 'filesystem:/opt/myapp/db/migration/core,/opt/myapp/db/migration/custB'
    }
  ],
  parameters: {
      'password' => 'password'
  }
  debug: false,
  sensitive: true
)

Cookbook Matchers

Getting Help

Contributing

Please refer to CONTRIBUTING.

License

MIT - see the accompanying LICENSE file for details.