Manages database migrations for Tango.
Uses EctoEvolver for versioned migration tracking and SQL execution.
Usage
In your Phoenix application, create a migration:
mix ecto.gen.migration add_tango_tablesThen in the generated migration file:
defmodule MyApp.Repo.Migrations.AddTangoTables do
use Ecto.Migration
def up do
Tango.Migration.up()
end
def down do
Tango.Migration.down()
end
endVersioned Migrations
You can also specify a specific version:
def up do
Tango.Migration.up(version: 1)
endOr use a custom schema prefix:
def up do
Tango.Migration.up(prefix: "custom_schema")
end
Summary
Functions
Returns the current migration version supported by this library.
Rolls back migrations to the target version.
Returns the currently migrated version from the database.
Applies migrations up to the target version.
Functions
@spec current_version() :: pos_integer()
Returns the current migration version supported by this library.
@spec down(keyword()) :: :ok
Rolls back migrations to the target version.
Options
:prefix- Schema prefix. Defaults to"public".:version- Target version to roll back to. Defaults to0.
@spec migrated_version(keyword()) :: non_neg_integer()
Returns the currently migrated version from the database.
Returns 0 if no migrations have been applied.
@spec up(keyword()) :: :ok
Applies migrations up to the target version.
Options
:prefix- Schema prefix. Defaults to"public".:version- Target version. Defaults to2.