Versioned migrations for this package's tables, in the shape
statifier_persistence's StatifierPersistence.Ecto.Migrations uses: the
host writes one ordinary migration that delegates here, and later
package versions ship higher-numbered migration modules the same call
picks up.
defmodule MyApp.Repo.Migrations.AddStatifierRouter do
use Ecto.Migration
def up, do: StatifierRouter.Migrations.up(prefix: "routing")
def down, do: StatifierRouter.Migrations.down(prefix: "routing")
endThe options are the two storage options of StatifierRouter.Config,
:table_prefix and :prefix, resolved the same way, plus :from and
:version:
:table_prefix- a string prefixed to every table name, default"statifier_router_". Pass the same value the host'sStatifierRouter.Configcarries.:prefix- the Postgres schema the tables live in, defaultnil. When it is set,up/1creates the schema if it does not exist anddown/1leaves it in place: dropping a schema the host may share is not this package's call.:fromand:version- where a call starts and where it ends, in both directions.up/1migrates fromfrom:(default: V01) up throughversion:(default: the newest this package knows), anddown/1rolls back fromfrom:(default: the newest) down throughversion:(default: V01, that is, everything).
A host already running an older version writes its next migration with
from: set to the first version it has not run, rather than re-running
V01's CREATE TABLE against tables that already exist. A host whose
first migration is capped with version: N caps its rollback to match
with from: N.
A fault in the options raises ArgumentError: a migration has no caller
to hand an {:error, reason} to.
StatifierRouter.Migrations.V01 records what the first version creates,
and StatifierRouter.Migrations.V02 what the second adds.
:from is inclusive: up(from: 2) runs V02, and a host already on
V01 that writes it gets the subscription table without V01's
CREATE TABLE running a second time (ADR-0007, section 6).
Summary
Functions
Rolls the tables back from from: (default: the newest version this
package knows) down through version: (default: V01, that is,
everything).
Migrates the tables from from: (default: V01) up through version:
(default: the newest).