Creates and upgrades Imison's tables in the host's database, one version at a time.
The host app wraps it in an Ecto migration of its own:
defmodule MyApp.Repo.Migrations.AddImison do
use Ecto.Migration
def up, do: Imison.Migration.up(version: 1)
def down, do: Imison.Migration.down(version: 1)
endup() without a version migrates to the latest version. Versions already
applied are skipped, so running a version twice changes nothing. When a
release ships a new version, the host adds one more migration:
def up, do: Imison.Migration.up(version: 2)
def down, do: Imison.Migration.down(version: 2)down(version: n) rolls back every applied version down to and including n;
down() removes all of Imison's tables.
Prefixes
The tables go in the public schema unless prefix: names another, which
is created when missing:
def up, do: Imison.Migration.up(prefix: "private")
def down, do: Imison.Migration.down(prefix: "private")
Summary
Callbacks
Migrates Imison's tables down to and including :version (default: the first).
Returns the version Imison's tables are migrated to, 0 when they don't exist.
Migrates Imison's tables up to :version (default: the latest).
Functions
Rolls back every applied version down to and including :version (default: the first).
Returns the version Imison's tables are migrated to, 0 when they don't exist.
Applies every version not yet applied, up to :version (default: the latest).
Callbacks
@callback down(keyword()) :: :ok
Migrates Imison's tables down to and including :version (default: the first).
@callback migrated_version(keyword()) :: non_neg_integer()
Returns the version Imison's tables are migrated to, 0 when they don't exist.
@callback up(keyword()) :: :ok
Migrates Imison's tables up to :version (default: the latest).
Functions
@spec down(keyword()) :: :ok
Rolls back every applied version down to and including :version (default: the first).
Imison.Migration.down()
Imison.Migration.down(version: 2)
Imison.Migration.down(prefix: "private")
@spec migrated_version(keyword()) :: non_neg_integer()
Returns the version Imison's tables are migrated to, 0 when they don't exist.
Outside a migration, pass the repo:
Imison.Migration.migrated_version(repo: MyApp.Repo)
@spec up(keyword()) :: :ok
Applies every version not yet applied, up to :version (default: the latest).
Imison.Migration.up()
Imison.Migration.up(version: 1)
Imison.Migration.up(prefix: "private")