Generates the host migration that installs or upgrades a library's tables.
$ mix phoenix_mountable.gen.migration MyLib.Migrations
The version the host is at is read from its existing migrations (the
highest MyLib.Migrations.up(version: n)), so it works before the
database is migrated. The new migration pins the latest version:
def up, do: MyLib.Migrations.up(version: 4)
def down, do: MyLib.Migrations.down(to: 2)It adds @disable_ddl_transaction and @disable_migration_lock when a
version needs them, and notes contract changes, irreversible versions and
backfills as comments. The file is created by mix ecto.gen.migration,
so it follows the host's Ecto conventions.
Libraries usually wrap it in a task of their own:
defmodule Mix.Tasks.MyLib.Gen.Migration do
use Mix.Task
@shortdoc "Generates the migration for MyLib"
def run(args), do: Mix.Task.run("phoenix_mountable.gen.migration", ["MyLib.Migrations" | args])
endOptions
-r,--repo— the repo (defaults to the app's:ecto_repos)--to— the version to migrate to. Defaults to the latest.--from— the version the host is at, when it cannot be read from its migrations (an existingup()without a version). Without it, the database is asked.--migrations-path— where to write the migration