Ecto: mix ecto.migrate: "migration runner process"

Created on 7 Mar 2016  Â·  14Comments  Â·  Source: elixir-ecto/ecto

Hello,

Just started to use Elixir and Phoenix. I'm currently doing the simplest of thing for a web app but look like my ecto is acting up. Trying to migrate to my database.

I've try to reinstall my ecto deps.

Environment

  • Elixir version (elixir -v): 1.2.2
  • Database and version (PostgreSQL 9.4, MongoDB 3.2, etc.): pgsql 9.4
  • Ecto version (mix deps): 1.1.4
  • Operating system: Windows 10

    Current behavior

mix ecto.migrate

(RuntimeError) could not find migration runner process for #PID<0.46.0>
(ecto) lib/ecto/migration/runner.ex:70: Ecto.Migration.Runner.prefix/0
(ecto) lib/ecto/migration.ex:665: Ecto.Migration.__prefix__/1
(ecto) lib/ecto/migration.ex:270: Ecto.Migration.create/1
(stdlib) erl_eval.erl:669: :erl_eval.do_apply/6
(elixir) lib/code.ex:321: Code.load_file/2
(ecto) lib/ecto/migrator.ex:221: anonymous fn/4 in Ecto.Migrator.migrate/4
(elixir) lib/enum.ex:1088: Enum."-map/2-lists^map/1-0-"/2
(ecto) lib/mix/tasks/ecto.migrate.ex:63: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
(elixir) lib/enum.ex:604: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:604: Enum.each/2
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2

Expected behavior

well run would be a good behavior.

Most helpful comment

Hey Jose, I've just been speaking with gazler on irc about this, and I've had the same problem and resolved it.

It occurs when you try to do migration steps outside of the change function (or up/down functions i guess, I didnt try).

This migration replicates the issue:

defmodule Example.Repo.Migrations.Failure do
  use Ecto.Migration

  def change do
    create table(:testing) do
      add :name, :string
    end
  end

  create index(:testing, [:name])
end

Hope this helps you @Lemures

All 14 comments

Can you provide a simple app that reproduces the error? I am thinking you are using tasks or something of sorts in your migrations.

Please let me know if you can have a way to reproduce this because I cannot. :) I will gladly reopen the issue once we have a mechanism, thank you!

Hey Jose, I've just been speaking with gazler on irc about this, and I've had the same problem and resolved it.

It occurs when you try to do migration steps outside of the change function (or up/down functions i guess, I didnt try).

This migration replicates the issue:

defmodule Example.Repo.Migrations.Failure do
  use Ecto.Migration

  def change do
    create table(:testing) do
      add :name, :string
    end
  end

  create index(:testing, [:name])
end

Hope this helps you @Lemures

same here when a migration is created:
(btw, this was created as an umbrella project)

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

  def change do
    create table(:users) do
      add :name, :string
      add :username, :string, null: false
      add :password_hash, :string

      timestamps
    end
  end

  create unique_index(:users, [:username])
end

with model:

defmodule Rumbl.User do
  use Rumbl.Web, :model


  schema "users" do
    field :name, :string
    field :username, :string
    field :password, :string, virtual: true
    field :password_hash, :string

    timestamps
  end
end

throws backs:

mix ecto.migrate

** (RuntimeError) could not find migration runner process for #PID<0.71.0>
(ecto) lib/ecto/migration/runner.ex:70: Ecto.Migration.Runner.prefix/0
(ecto) lib/ecto/migration.ex:665: Ecto.Migration.prefix/1
(ecto) lib/ecto/migration.ex:270: Ecto.Migration.create/1
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(elixir) lib/code.ex:321: Code.load_file/2
(ecto) lib/ecto/migrator.ex:221: anonymous fn/4 in Ecto.Migrator.migrate/4
(elixir) lib/enum.ex:1183: Enum."-map/2-lists^map/1-0-"/2
(ecto) lib/mix/tasks/ecto.migrate.ex:69: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
(elixir) lib/enum.ex:651: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:651: Enum.each/2
(mix) lib/mix/task.ex:296: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2

@BennyHallett is correct:

doing this

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

  def change do
    create table(:users) do
      add :name, :string
      add :username, :string, null: false
      add :password_hash, :string

      timestamps
    end
    create unique_index(:users, [:username])
  end

  # create unique_index(:users, [:username])
end

fixes it and yields the expected:

10:53:44.183 [info] create table users

10:53:44.464 [info] create index users_username_index

10:53:44.510 [info] == Migrated in 3.2s

I ran into a similar issue. The problem was user error — I had a malformed migration — but I think it would be helpful if the error message provided a better hint.

@codecakes, @BennyHallett thank you guys, it solved my problem.

I had the same blasted problem in my migration file. Thanks for posting what was wrong!

The only fix I understand from the above is: make the index unique.

1) Is that correct?
2) what if I don't want a unique index?

@wdiechmann This issue doesn't have anything to do with a unique index, but rather that a migration didn't exist within a function. Can't run migration steps at the model level.

@OvermindDL1

hmm - then how come when I changed create index to create unique_index the migration ran effortlessly?

(I apologise for barking up the wrong tree - but find my error somewhat justified, apart from being a hopeless n00b obviously) :(

Sounds like a different error then. Should ask on the Elixir Forums.

I had forgot "def change" in my migration and that's the error I received - just as a hint.

I had forgot "def change" in my migration and that's the error I received - just as a hint.

I did "def change" but forgot to add "do" ant it yielded same error

Was this page helpful?
0 / 5 - 0 ratings