Recall.Migrator (Recall v0.1.0)

Copy Markdown View Source

Runs Ecto migrations against the Recall (Mnesia) adapter.

This is a thin stand-in for Ecto.Migrator. The stock migrator tracks which versions have run by querying schema_migrations with a string source (from(m in "schema_migrations", ...)), and this adapter refuses string-source queries — every Mnesia table must be backed by an Recall.Schema. So this migrator keeps the exact same execution engine (Ecto.Migration.Runner, which flushes a migration's create/alter/drop commands to the adapter's execute_ddl/3) but does version bookkeeping through the schema-backed Recall.SchemaMigration (Repo.all/insert/delete_all).

Use the mix tasks rather than calling this directly:

mix recall.migrate
mix recall.rollback --step 1

Options

  • :all — run all pending migrations (the default for :up)
  • :step — run N migrations in the given direction
  • :to — run up/down to (and including) a target version
  • :migrations_paths — list of directories holding migration files (defaults to Ecto.Migrator.migrations_path(repo))
  • :log — the Logger level for migration logs (defaults to :info)

Summary

Functions

Runs a single migration down. Returns :ok, or :already_down if its version is not recorded.

The versions that have been applied, ascending. Creates the schema_migrations table on first touch (via the adapter's first-touch Table.ensure/2).

Runs all migrations found under the repo's migrations path in direction. Returns the list of versions that ran.

Runs migrations found under paths in direction. Returns the versions that ran.

Runs a single migration up. Returns :ok, or :already_up if its version is already recorded.

Functions

down(repo, version, module, opts \\ [])

Runs a single migration down. Returns :ok, or :already_down if its version is not recorded.

migrated_versions(repo, opts \\ [])

The versions that have been applied, ascending. Creates the schema_migrations table on first touch (via the adapter's first-touch Table.ensure/2).

run(repo, direction, opts)

Runs all migrations found under the repo's migrations path in direction. Returns the list of versions that ran.

run(repo, paths, direction, opts)

Runs migrations found under paths in direction. Returns the versions that ran.

up(repo, version, module, opts \\ [])

Runs a single migration up. Returns :ok, or :already_up if its version is already recorded.