Migrations
Sometimes, it is necessary to refactor a data model after it has already been released to
production. The migrations
module provides a mechanism to either apply
and rollback
a
migration. This mechanism is limited in its opinions and feature set, since migrations are highly
contextual by their nature. Migration script authors are responsible for ensuring that their
migrations are either idempotent and safe to re-run, or for checking the migration log to
determine if a script has already been applied.
Migration Component Model
A migration script can be defined by implement the Migration
trait which specifies the following
interface.
A Migration
implementation can then be passed to the MigrationService
along with an Effect
enum. The Effect
enum specifies whether to apply or rollback the migration.
User code is required to coordinate the application of migrations, in which order, and to what effect.