MailglassInbound.Migration (MailglassInbound v2.0.0)

Copy Markdown View Source

Public migration API for mailglass_inbound.

Adopters consume this via a single 8-line wrapper file that mix mailglass.inbound.gen.migration emits:

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

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

Postgres-only at v2.0 per PROJECT.md (MySQL/SQLite out of scope). Inbound maintains its own independent version anchor — separate from core's mailglass_events anchor — so both packages can evolve independently even in a shared schema.

Summary

Functions

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

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

Runs all pending inbound migrations up to the latest version.

Functions

down(opts \\ [])

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

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

migrated_version(opts \\ [])

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

Returns the currently-applied inbound 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_class query against the configured Repo and returns an integer). Anchored on mailglass_inbound_records, not mailglass_events — the two packages maintain independent version lines.

up(opts \\ [])

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

Runs all pending inbound migrations up to the latest version.