I have a "dummy" app in my mix app, so, it's first migration is placed in test/dummy/priv/repo/migrations/20160323060044_create_user.exs
.
I want to run this migration, but it returns 11:19:20.647 [info] Already up
, and this disappoints me.
Here is my 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/"
Here is my migration:
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
I'm running
MIX_ENV=test mix ecto.migrate -r Dummy.Repo
and get annoying already up
instead of migration. What's I'm doing wrong?
My attempts:
I tried to drop and re-create database, nothing happened
My another turn was to require the code. I tried to implement this in my
test.exs
ordev.exs
, but I received `module Ecto.Migration is not loaded and could not be found"test/dummy/priv/repo/migrations" |> Path.join("**/*.exs") |> Path.wildcard |> Enum.map(&Code.require_file/1)
I also tried to create a fake migration by
MIX_ENV=test mix ecto.gen.migration f -r Dummy.Repo
, fill it with code which raise an exception, and than I hadMIX_ENV=test mix ecto.migrate -r Dummy.Repo # => 12:49:00.932 [info] Already up
So, it can't find a repo. Sad, but true
I also tried to load shell
MIX_ENV=test
, then invoke code from 2nd approach, thenMix.Task.run "ecto.migrate" ["-r", "Dummy.Repo"]
. it returned :noop to me?Github issue: https://github.com/elixir-lang/ecto/issues/1428
mix ecto.gen.migration create_user
? This should always place the transaction where Ecto can read it. – tkowalpriv
aspect (and consequently the troubleshooting was done), I finally came across your post of the exact same problem! If theecto.gen.migration
command works, then theecto.migrate
command should also work! – user4275029