OctaviusMigrator
class OctaviusMigrator
Brings a database up to date with the migrations in this application.
val report = OctaviusMigrator(
dataSource,
MigratorConfig(
sqlLocations = listOf("db/migration"),
codePackages = listOf("com.roma.migrations")
)
).migrate()
logger.info { "Octavius: $report" }Content copied to clipboard
A run takes one session for its whole length and gives it back at the end. It holds an advisory lock from before the history table is looked at until after the last migration, so two instances of an application starting together produce one migration run and one wait, rather than a race.
There is no undo and there will not be one. A migration that turns out to be wrong is corrected by a migration that comes after it, which is the only correction that leaves every copy of the database in the same state.