gorrion

Gorrion — Ecto-like database migration library for Gleam.

Reads migration SQL from .sql files on disk, tracks applied migrations in a _schema_migrations table, and supports forward migration and rollback.

Usage

// Run all pending migrations
gorrion.migrate(db, "migrations")

// Roll back the most recent migration
gorrion.rollback(db, "migrations")

// Check migration status
gorrion.status(db, "migrations")

Values

pub fn migrate(
  db db: pog.Connection,
  migrations_dir dir: String,
) -> Result(Nil, types.MigrationError)

Run all pending migrations in version order.

pub fn rollback(
  db db: pog.Connection,
  migrations_dir dir: String,
) -> Result(Nil, types.MigrationError)

Roll back the most recently applied migration.

pub fn rollback_to(
  db db: pog.Connection,
  migrations_dir dir: String,
  target_version target: Int,
) -> Result(Nil, types.MigrationError)

Roll back all migrations down to (but not including) the target version.

pub fn status(
  db db: pog.Connection,
  migrations_dir dir: String,
) -> Result(types.MigrationStatus, types.MigrationError)

Get the current migration status: which are applied and which are pending.

Search Document