Flyway Migrations#
Migrations#
- With
Flyway
all changes to the database are calledmigrations
.Migrations
can be eitherversioned
orrepeatable
.Versioned migrations
come in 2 forms:regular
andundo
. - Flyway Versioned Migrations have a
version
, adescription
and achecksum
. The version must be unique. The description is purely informative for you to be able to remember what each migration does. The checksum is there to detect accidental changes. Versioned migrations arethe most common type of migration
. They are applied in order exactly once. -
Optionally their effect can be undone by supplying an undo migration with the same version.
-
Flyway Repeatable Migrations have a
description
and achecksum
, but no version. Instead of being run just once, they are (re-)applied every time their checksum changes. - Within a single migration run, repeatable migrations are always applied last, after all pending versioned migrations have been executed. Repeatable migrations are applied in the order of their description.
-
By default both
versioned
andrepeatable migrations
can be written either in SQL (see Flyway SQL-based Migrations) or in Java and can consist of multiple statements. -
Flyway automatically discovers migrations on the
filesystem
and on the Javaclasspath
. -
To keep track of which migrations have already been applied when and by whom, Flyway adds a
schema history table
to your schema.
See Also#
- Flyway Versioned Migrations
- Flyway Repeatable Migrations
- Flyway SQL-based Migrations
- Database Migrations with Flyway