Skip to content

module Athena::ORM::Migrations #

Versions a database's schema through migrations, each a type that applies one change, and reverts it.

Require athena-orm/migrations to use them:

require "athena-orm/migrations"

class App::Migrations::Version20261014120000 < AORM::Migrations::AbstractMigration
  def description : String
    "Create the users table"
  end

  def up : Nil
    self.add_sql "CREATE TABLE users (id BIGINT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY (id))"
  end

  def down : Nil
    self.add_sql "DROP TABLE users"
  end
end

The version of a migration is the fully qualified name of its type, and migrations run in the order of their versions. See the migrations guide for how to configure, generate and execute them.

Constants#

Log = ::Log.for("athena.orm.migrations")#

Messages a migration writes via AbstractMigration#write, and warnings it raises via AbstractMigration#warn_if, are logged here.