Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mix ecto.migrate: "migration runner process" #1298

Closed
Lemures opened this issue Mar 7, 2016 · 14 comments
Closed

mix ecto.migrate: "migration runner process" #1298

Lemures opened this issue Mar 7, 2016 · 14 comments

Comments

@Lemures
Copy link

Lemures commented Mar 7, 2016

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.

@josevalim
Copy link
Member

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

@josevalim
Copy link
Member

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!

@BennyHallett
Copy link

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

@codecakes
Copy link

codecakes commented Jun 30, 2016

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

@codecakes
Copy link

@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

@lleger
Copy link

lleger commented Feb 17, 2017

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.

@PabloGilvan
Copy link

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

@7stud
Copy link

7stud commented Dec 7, 2018

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

@wdiechmann
Copy link

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?

@OvermindDL1
Copy link
Contributor

@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.

@wdiechmann
Copy link

wdiechmann commented Sep 20, 2019

@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) :(

@OvermindDL1
Copy link
Contributor

OvermindDL1 commented Sep 20, 2019

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

@tomjoro
Copy link
Contributor

tomjoro commented Oct 3, 2019

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

@dkuku
Copy link
Contributor

dkuku commented Jan 15, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests