Letterbox.Migrations (Letterbox v0.1.0-rc.0)

Copy Markdown View Source

The table of Letterbox, in a migration of the app.

$ mix letterbox.gen.migration

writes a migration that pins the latest version:

defmodule MyApp.Repo.Migrations.AddLetterbox do
  use Ecto.Migration

  def up, do: Letterbox.Migrations.up(version: 1)
  def down, do: Letterbox.Migrations.down(to: 0)
end

The versions are PhoenixMountable.Migrations: tracked in the app's database (per prefix), and run on PostgreSQL and on SQLite. A later version of Letterbox that changes the table has a new version, and mix letterbox.gen.migration writes the migration that upgrades.

Version 1 makes letterbox_inbound: a message a row (Letterbox.Inbound), one for each provider's id (a webhook delivered twice is one message).

up/1 takes :version and :prefix (the schema of the table, in PostgreSQL); down/1 takes :to and :prefix.

Summary

Functions

:ok, {:pending, message} or {:outdated, message}. Takes :repo and :prefix.

Rolls the library's tables back to :to (default 0). Call it from a host migration.

The latest version of the library's schema.

The version the database is at (0 when not installed).

Runs deferred backfills to completion. Takes :repo and :prefix.

The version, compatibility and backfills of a database. Takes :repo and :prefix.

Migrates the library's tables up. Call it from a host migration.

Checks the tables against the library's schema. Takes :repo and :prefix.

Functions

check(opts)

:ok, {:pending, message} or {:outdated, message}. Takes :repo and :prefix.

down(opts \\ [])

Rolls the library's tables back to :to (default 0). Call it from a host migration.

latest_version()

The latest version of the library's schema.

migrated_version(opts \\ [])

The version the database is at (0 when not installed).

run_backfills(opts)

Runs deferred backfills to completion. Takes :repo and :prefix.

status(opts)

The version, compatibility and backfills of a database. Takes :repo and :prefix.

up(opts \\ [])

Migrates the library's tables up. Call it from a host migration.

verify(opts)

Checks the tables against the library's schema. Takes :repo and :prefix.