Ecto.Migrator
This module provides the migration API.
Example
defmodule MyApp.MigrationExample do
use Ecto.Migration
def up do
"CREATE TABLE users(id serial PRIMARY_KEY, username text)"
end
def down do
"DROP TABLE users"
end
end
Ecto.Migrator.up(Repo, 20080906120000, MyApp.MigrationExample)
Summary↑
down(repo, version, module) | Runs a down migration on the given repository |
run(repo, directory, direction, opts) | Apply migrations in a directory to a repository with given strategy |
up(repo, version, module) | Runs an up migration on the given repository |
Types ↑
strategy :: [all: true, to: non_neg_integer, step: non_neg_integer]
Functions
Specs:
- down(Ecto.Repo.t, integer, Module.t) :: :ok | :missing_up | no_return
Runs a down migration on the given repository.
Specs:
- run(Ecto.Repo.t, binary, atom, strategy) :: [integer]
Apply migrations in a directory to a repository with given strategy.
A strategy must be pass as an option. The available strategy types are:
:all
runs all available iftrue
:step
runs the specific number of migrations:to
runs all until the supplied version is reached
Specs:
- up(Ecto.Repo.t, integer, Module.t) :: :ok | :already_up | no_return
Runs an up migration on the given repository.