Let's describe the problem:
- I created a new phoenix app with
mix phx.new
- I configured a database connection within
{dev, test}.exs
(I'm mapping an existing database) - I created a context using
mix phx.gen.context
(which created a migration)
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.
Ecto.Migrator.migrations(Some.Repo)
return for you? – Ogdan[{:down, 20201111101131, "create_person"}]
– Shagbarkcreate_person
migration? Look here - to me it looks like a migration path can be configured per repo, so please check whatSome.Repo.config()[:priv]
gives you - chances are your migration sits somewhere in the different location... – OgdanSome.Repo.config()[:priv]
returnsnil
. – Shagbark