class

MG::Base

Inherits Reference < Object

All user defined versions must inherite from this class, and implement the up and down methods.

class CreateUser < MG::Base
  def up : String
    <<-SQL
    CREATE TABLE users (
      username TEXT NOT NULL,
      password TEXT NOT NULL,
      email TEXT NOT NULL
    );
    CREATE UNIQUE INDEX user_idx ON users (username);
    SQL
  end

  def down : String
    <<-SQL
    DROP TABLE users;
    SQL
  end
end

Class methods

versions

Lists all versions available. The versions are sorted by version number.

Source

Instance methods

after_down(db : DB::Connection)

Optional lifecycle method. Overwrite this method to execute Crystal code after running the down query.

Source
after_up(db : DB::Connection)

Optional lifecycle method. Overwrite this method to execute Crystal code after running the up query.

Source