OctaviusMigration

A migration written in Kotlin rather than in .sql.

Its version and description come from the class name, exactly as a file's do: V2__Add_indexes is version 2, V2_1__Add_indexes is version 2.1 - a class name cannot hold a ., so _ separates the parts there - and R__Rebuild_views is repeatable. Nothing on this interface says which migration it is, and that is the point: the scan reads the name and never constructs the class, so a migration that ran months ago runs none of your code at startup.

The class needs a constructor that takes no arguments, and is built once, immediately before it runs, then dropped. It is not a bean and holding one would buy nothing.

class V3__Backfill_provinces : OctaviusMigration {
override fun migrate(session: OctaviusSessionOperations) {
session.createNativeQuery("UPDATE provinces SET tribute = 0 WHERE tribute IS NULL").update()
}
}

Properties

Link copied to clipboard
open val checksum: Long?

A number that changes when this migration changes, or null - the default - for "do not check".

Link copied to clipboard

Whether to wrap this migration in a transaction. Read off the instance immediately before it runs.

Functions

Link copied to clipboard
abstract fun migrate(session: OctaviusSessionOperations)

Runs the migration.