class Cql::Migrator
Reference
< Object
The Migrator
class is used to manage migrations and provides methods to apply, rollback, and redo migrations. The Migrator
class also provides methods to list applied and pending migrations. Example Creating a new migrator
Example Applying migrations
Constants
Log
Constructors
def new(schema : Schema)
(schema : Schema)
Class Methods
def migrations
def migrations=(migrations : Array(Migration.class))
(migrations : Array(Migration.class))
Instance Methods
def applied_migrations
Returns the applied migrations.
@return [Array(MigrationRecord)] Example Listing applied migrations
def down(steps : Int32 = Migrator.migrations.size)
(steps : Int32 = Migrator.migrations.size)
Rolls back the last migration.
@param steps [Int32] the number of migrations to roll back (default: 1) Example Rolling back migrations
def down_to(version : Int64)
(version : Int64)
Rolls back to a specific migration version.
@param version [Int64] the version to roll back to Example Rolling back to a specific version
def last
Returns the last migration. Example Listing the last migration
@return [Migration.class | Nil]
def pending_migrations
Returns the pending migrations.
@return [Array(MigrationRecord)] Example Listing pending migrations
def print_applied_migrations
Prints the applied migrations. Example Listing applied migrations
def print_pending_migrations
Prints the pending migrations. Example Listing pending migrations
def print_rolled_back_migrations(m : Array(Migration.class))
(m : Array(Migration.class))
Prints the rolled back migrations.
@param m [Array(Migration.class)] the migrations to print
@return [Nil] Example Listing rolled back migrations
def redo
Redoes the last migration. Example Redoing migrations
def repo
def rollback(steps : Int32 = 1)
(steps : Int32 = 1)
Rolls back the last migration.
@param steps [Int32] the number of migrations to roll back (default: 1) Example Rolling back migrations
def schema
def up(steps : Int32 = Migrator.migrations.size)
(steps : Int32 = Migrator.migrations.size)
Applies the pending migrations.
@param steps [Int32] the number of migrations to apply (default: all) Example Applying migrations
def up_to(version : Int64)
(version : Int64)
Applies migrations up to a specific version.
@param version [Int64] the version to apply up to Example Applying to a specific version
Last updated