elixirphoenix-frameworkecto

Phoenix prompts to run a migration that doesn't exist


Let's describe the problem:

I tried running the server for the first time but it told me that I have undeployed migrations.

there are pending migrations for repo: Some.Repo. 
Try running `mix ecto.migrate` in the command line to migrate it

Then I realized I don't need them since I already have the database so I deleted the migration file (/priv/repo/migrations/*) and tried again.

Now mix ecto.migrations show nothing, but it did not remove the server prompt. Then I found that ecto creates an additional table in the database for the migrations so I checked it and it was empty.

I dropped it and tried running the server again but the same message was shown.


To make sure it's not an Ecto problem I've prepared tests and they run just fine, the only problem is the migration prompt shown when I run the server.


I don't have any endpoints yet since I was planning to use GraphQL after I've verified that the models are working but that message is confusing.

Are there any hidden files for that migration or am I missing something else?

Stacktrace:

[error] #PID<0.451.0> running Some.Endpoint (connection #PID<0.449.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /
** (exit) an exception was raised:
    ** (Phoenix.Ecto.PendingMigrationError) there are pending migrations for repo: Some.Repo. Try running `mix ecto.migrate` in the command line to migrate it
        (phoenix_ecto 4.2.1) lib/phoenix_ecto/check_repo_status.ex:67: Phoenix.Ecto.CheckRepoStatus.check_pending_migrations!/2
        (phoenix_ecto 4.2.1) lib/phoenix_ecto/check_repo_status.ex:27: anonymous fn/3 in Phoenix.Ecto.CheckRepoStatus.call/2
        ...
[error] #PID<0.454.0> running Some.Endpoint (connection #PID<0.449.0>, stream id 2) terminated
Server: localhost:4000 (http)
Request: GET /favicon.ico
** (exit) an exception was raised:
    ** (Phoenix.Ecto.PendingMigrationError) there are pending migrations for repo: Some.Repo. Try running `mix ecto.migrate` in the command line to migrate it
        (phoenix_ecto 4.2.1) lib/phoenix_ecto/check_repo_status.ex:67: Phoenix.Ecto.CheckRepoStatus.check_pending_migrations!/2
        (phoenix_ecto 4.2.1) lib/phoenix_ecto/check_repo_status.ex:27: anonymous fn/3 in Phoenix.Ecto.CheckRepoStatus.call/2
        ...

UPDATE

After further investigation it seems that the project somehow stores the first ever migration generated by mix phx.new.context.

Whenever I re-create the database it prompts for the migration of this very context. I don't have any files mentioning that migration in my project.


Solution

  • I had this problem and it was only resolved by deleting the _build folder, nothing else worked, not ecto.reset nor deleting the migrations table. Elixir must be storing some state relating to migrations in the project somewhere.

    rm -rf _build/