Mailglass.Migration (Mailglass v0.1.0)

Copy Markdown View Source

Public migration API for mailglass.

Adopters consume this via a single 8-line wrapper file that mix mailglass.gen.migration (Phase 7) emits:

defmodule MyApp.Repo.Migrations.AddMailglass do
  use Ecto.Migration
  def up, do: Mailglass.Migration.up()
  def down, do: Mailglass.Migration.down()
end

The wrapper stays stable across mailglass versions; per-version DDL lives in Mailglass.Migrations.Postgres.VNN modules, dispatched by Mailglass.Migrations.Postgres tracking the current version in the pg_class comment on mailglass_events.

Postgres-only at v0.1 per PROJECT.md (MySQL/SQLite out of scope).

Summary

Functions

Rolls back migrations down to the target version (default: 0).

Returns the currently-applied migration version (0 if none).

Runs all pending migrations up to the latest version.

Functions

down(opts \\ [])

(since 0.1.0)
@spec down(keyword()) :: :ok

Rolls back migrations down to the target version (default: 0).

migrated_version(opts \\ [])

(since 0.1.0)
@spec migrated_version(keyword()) :: non_neg_integer()

Returns the currently-applied migration version (0 if none).

This function is safe to call outside an Ecto.Migrator context — unlike up/1 / down/1, it does not rely on the migration runner process (it issues a single pg_catalog.obj_description query against the configured Repo and returns an integer).

up(opts \\ [])

(since 0.1.0)
@spec up(keyword()) :: :ok

Runs all pending migrations up to the latest version.