mix mailglass.upgrade.v2_schema (Mailglass v2.0.0)

Copy Markdown View Source

Generates a Route B move migration that relocates mailglass's four core tables from public into a dedicated mailglass schema — the recommended upgrade path for adopters running the 1.x public install who are moving to mailglass 2.0.

The emitted migration is metadata-only and transactional:

  • SET LOCAL lock_timeout = '5s' so the move fails fast (SQLSTATE 55P03) rather than queueing behind a long reader holding ACCESS EXCLUSIVE — retry mix ecto.migrate off-peak.
  • CREATE SCHEMA IF NOT EXISTS "mailglass", then ALTER TABLE public.<t> SET SCHEMA "mailglass" for all four core tables (indexes, constraints, and sequences move with each table; the table comment survives the OID move).
  • the append-only immutability function does NOT move with the table (it is a distinct pg_proc object), so the migration drops and recreates it schema-qualified — byte-parity with the shipped fresh-install DDL, so a moved database is indistinguishable from a freshly-installed one.

A working down/0 reverses the move: it returns all four tables to public and restores the public-qualified function and trigger.

The task is idempotent — re-running it prints unchanged <path> and does not emit a second migration.

mix mailglass.upgrade.v2_schema

Options:

  • --schema <name> — target schema (default mailglass). Validated as a Postgres unquoted identifier before it is interpolated into the migration.

Summary

Functions

Returns the move-migration source for app_module as a string.

Functions

migration_body(app_module, opts \\ [])

@spec migration_body(
  String.t(),
  keyword()
) :: String.t()

Returns the move-migration source for app_module as a string.

Exposed so tests can assert the emitted body without a full filesystem run. Accepts :schema (default "mailglass"); the value is assumed pre-validated by run/1 via Mailglass.Identifier.validate!/2.