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" }

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.

Constructors

Link copied to clipboard
constructor(dataSource: DataSource, config: MigratorConfig = MigratorConfig())

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

What the run would do, without doing any of it.

Link copied to clipboard

Applies every migration this database has not run, in version order.