class

Lustra::Migration::Manager

Inherits Lustra::ErrorMessages < Reference < Object

The migration manager is a singleton, it load all the migrations, check which one are up and down, and can trigger one or multiple downgrade / upgrade of the database.

The migration system needs the creation of a table named __lustra_metadatas in your database. This table will be created automatically on the first initialization of the Migration Manager.

Constants

METADATA_VERSION = "1"

Used to migrate between metadata version, in case we need it in the future.

Class methods

instance

To access to the manager

Lustra::Migration::Manager.instance
Source

Instance methods

apply_all

Apply all the migrations not yet applied.

Source
apply_to(version, direction = :both)
Source
commited?(m : Lustra::Migration)

Return true if the migration has been commited (already applied into the database) or false otherwise

Source
current_version
Source
down(number : Int64) : Nil

Force down a migration; throw error if the mgiration is already down

Source
ensure_ready

Create if needed the metadata table to save the migrations.

Source
find(number)

Fetch the migration instance with the selected number

Source
load_existing_migrations

Fetch all the migrations already activated on the database.

Source
max_version
Source
migrations_up
Source
refresh
Source
reinit!

Force reloading the migration system Recheck all the current up migrations and the metadata table. This is useful if you access to the migration process through another program, or during specs

Source
up(number : Int64) : Nil

Force up a migration; throw error if the migration is already up

Source