module

Arcana::DB::Migrate

Tiny migration runner.

Walks db/migrations/*.sql in lexicographic order, applies any that haven't been recorded in the schema_migrations table, and tracks them as applied. Each migration runs in a transaction.

Filename convention: <timestamp>_<description>.sql, e.g. db/migrations/20260427_001_init_auth.sql

The leading numeric prefix determines order. The full filename is the unique key recorded in schema_migrations, so renames break things — don't rename applied migrations.

Constants

SCHEMA_TABLE_SQL = " CREATE TABLE IF NOT EXISTS schema_migrations (\n filename TEXT PRIMARY KEY,\n applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW()\n )"

Record table that tracks which migrations have been applied.

Class methods

default_dir

Default location for migration files. Prefer the install prefix (/usr/share/arcana/db/migrations) so packaged runs work from any CWD. Fall back to a CWD-relative path only when running inside a source checkout (detected via shard.yml).

Source
run(dir : String = default_dir) : Array(String)

Apply any pending migrations from the given directory. Returns the list of applied filenames (in order).

Source