public class Flywaydb extends Object implements Jooby.Module
Run database migrations on startup and exposes a Flyway instance.
flyway.url = ... flyway.user = ... flyway.password = ...
{
use(new Flywaydb());
}
If for any reason you need to maintain two or more databases:
flyway.db1.url = "..." flyway.db1.locations = "db1/migration" flyway.db2.url = "..." flyway.db2.locations = "db2/migration"
{
use(new Flywaydb("flyway.db1"));
use(new Flywaydb("flyway.db2"));
}
Flyway looks for migration scripts at the db/migration classpath location.
We recommend to use Semantic versioning for naming the migration
scripts:
v0.1.0_My_description.sql v0.1.1_My_small_change.sql
It is possible to run Flyway commands on startup, default command is:
migrate.
If you need to run multiple commands, set the flyway.run property:
flyway.run = [clean, migrate, validate, info]
Configuration is done via application.conf under the flyway.* path.
There are some defaults setting that you can see in the appendix.
| Constructor and Description |
|---|
Flywaydb()
Creates a new
Flywaydb module, using flyway as property. |
Flywaydb(String name)
Creates a new
Flywaydb. |
| Modifier and Type | Method and Description |
|---|---|
com.typesafe.config.Config |
config() |
void |
configure(Env env,
com.typesafe.config.Config config,
com.google.inject.Binder binder) |
public Flywaydb(String name)
Flywaydb. The given name is use it to read flyway properties, keep in
mind that custom configuration will inherited all the properties from flyway.*.name - Name of the property with flyway properties.public Flywaydb()
Flywaydb module, using flyway as property.public void configure(Env env, com.typesafe.config.Config config, com.google.inject.Binder binder)
configure in interface Jooby.Modulepublic com.typesafe.config.Config config()
config in interface Jooby.ModuleCopyright © 2016. All rights reserved.