class MG::Migration

Defined in:

mg/migration.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(db : DB::Database, *, tag : String | Nil = nil, version_table : String = "mg_version", version_column : String = "mg_version", log : Log | Nil = nil) #

Instantiates a Migration object to migrate a DB.

  • tag: See Tags.
  • version_table: The name of the table to create to store the current schema version
  • version_column: The column in version_table that stores the current schema version

NOTE In SQLite, version_table and version_column are ignored, because we can use the built-in user_version pragma to store the version.


[View source]

Instance Method Detail

def migrate(*, to : Int32 = -1) #

Migrates to a specific version. When to is negative, migrates to the latest version available.


[View source]
def user_version #

Returns the current schema version.


[View source]
def versions #

Lists the available versions for the current migration.


[View source]