StatifierPersistence.Ecto.Migrations (StatifierPersistence v0.1.0)

Copy Markdown View Source

Versioned migrations for this package's tables, in the Oban.Migration mold: the host writes one ordinary migration that delegates here, and later package versions ship higher-numbered migration modules the same call picks up.

The supported spelling reads the host's compiled configuration, so the DDL cannot drift from the generated schemas (ADR-0002 decision 3):

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

  def up, do: StatifierPersistence.Ecto.Migrations.up(for: MyApp.Persistence)
  def down, do: StatifierPersistence.Ecto.Migrations.down(for: MyApp.Persistence)
end

Alternatively, up/1 and down/1 accept the same literal options use StatifierPersistence.Ecto takes (:repo, :key, :table_prefix, :tables, :prefix), funneled through the same StatifierPersistence.Ecto.Config.new/1 - one resolver, both doors. The two spellings cannot be mixed in one call.

version: selects the target version. up/1 migrates from V01 through the target (default: the newest this package knows); down/1 rolls back from the newest through the target (default: V01, i.e. everything).

When prefix: names a Postgres schema, up/1 creates the schema if it does not exist; down/1 leaves the schema in place (dropping a schema the host may share is not this package's call).

Summary

Functions

Rolls the tables back from the newest version through version: (default: V01, i.e. everything). Takes the same options as up/1.

Migrates the tables up through version: (default: the newest).

Functions

down(opts)

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

Rolls the tables back from the newest version through version: (default: V01, i.e. everything). Takes the same options as up/1.

up(opts)

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

Migrates the tables up through version: (default: the newest).

Takes for: HostModule or the literal options use takes - see the moduledoc.