运行 使用非标准回购路径的外迁移

Run ecto migration with non-standard path of repo

我的混合应用程序中有一个 "dummy" 应用程序,因此,它的第一个迁移位于 test/dummy/priv/repo/migrations/20160323060044_create_user.exs

我想运行这个迁移,但是returns 11:19:20.647 [info] Already up,这让我很失望。

这是我的 test.exs:

config :ecto_state_machine, Dummy.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: System.get_env("USER"),
  password: "posgtres",
  database: "ecto_state_machine_test",
  pool_size: 10,
  port: 5432,
  priv: "test/dummy/priv/repo/"

这是我的迁移:

defmodule Dummy.Repo.Migrations.CreateUser do
  use Ecto.Migration

  def change do
    create table(:users) do
      add :state, :string, null: false
      add :confirmed_at, :datetime

      timestamps
    end
  end
end

我运行宁

MIX_ENV=test mix ecto.migrate -r Dummy.Repo

并变得烦人 already up 而不是迁移。我做错了什么?

我的尝试:

  1. 我尝试删除并重新创建数据库,但没有任何反应

  2. 我的另一轮是要求代码。我试图在我的 test.exsdev.exs 中实现它,但我收到`模块 Ecto.Migration 未加载且无法找到

    "test/dummy/priv/repo/migrations" |> Path.join("**/*.exs") |> Path.wildcard |> Enum.map(&Code.require_file/1)

  3. 我还尝试通过 MIX_ENV=test mix ecto.gen.migration f -r Dummy.Repo 创建一个假迁移,用引发异常的代码填充它,然后

    MIX_ENV=test mix ecto.migrate -r Dummy.Repo # => 12:49:00.932 [info] Already up

因此,它找不到存储库。悲伤,但真实

  1. 我还尝试加载 shell MIX_ENV=test,然后从第二种方法调用代码,然后 Mix.Task.run "ecto.migrate" ["-r", "Dummy.Repo"]。它返回 :noop 给我?

  2. Github 问题:https://github.com/elixir-lang/ecto/issues/1428

何塞瓦利姆评论 at github:

This is fixed in Ecto 2.0.0-rc. In previous versions, migrations would always have to be inside priv. We have removed this requirement in Ecto 2.0.