bar*_*ala 1 elixir ecto phoenix-framework
我们来描述一下问题:
mix phx.new{dev, test}.exs(我正在映射一个现有的数据库)mix phx.gen.context(它创建了一个迁移)的上下文我第一次尝试运行服务器,但它告诉我我有未部署的迁移。
there are pending migrations for repo: Some.Repo.
Try running `mix ecto.migrate` in the command line to migrate it
Run Code Online (Sandbox Code Playgroud)
然后我意识到我不需要它们,因为我已经有了数据库,所以我删除了迁移文件 ( /priv/repo/migrations/*) 并再次尝试。
现在mix ecto.migrations什么都不显示,但它没有删除服务器提示。然后我发现 ecto 在数据库中为迁移创建了一个额外的表,所以我检查了它,它是空的。
我放弃了它并尝试再次运行服务器,但显示了相同的消息。
为了确保这不是 Ecto 问题,我准备了测试并且它们运行得很好,唯一的问题是运行服务器时显示的迁移提示。
我还没有任何端点,因为我计划在验证模型正常工作后使用 GraphQL,但该消息令人困惑。
该迁移是否有任何隐藏文件,或者我是否遗漏了其他内容?
堆栈跟踪:
[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
...
Run Code Online (Sandbox Code Playgroud)
经过进一步调查,该项目似乎以某种方式存储了mix phx.new.context.
每当我重新创建数据库时,它都会提示迁移这个上下文。我的项目中没有任何文件提到该迁移。
小智 5
我遇到了这个问题,只能通过删除_build文件夹来解决,没有其他任何工作,ecto.reset也没有删除迁移表。Elixir 必须在项目中某处存储一些与迁移相关的状态。
rm -rf _build/
Run Code Online (Sandbox Code Playgroud)