elixir - “找不到#PID<0.94.0> 的迁移运行程序进程”是什么意思以响应混合ecto.migrate?
问题描述
我正在阅读有关 Phoenix 上下文的指南(https://hexdocs.pm/phoenix/contexts.html#thinking-about-design),在您运行的部分
mix ecto.gen.migration add_author_id_to_pages
然后在迁移中添加一些东西。这是完整的输出:
$ mix ecto.migrate
** (RuntimeError) could not find migration runner process for #PID<0.94.0>
(ecto_sql 3.5.3) lib/ecto/migration/runner.ex:100: Ecto.Migration.Runner.prefix/0
(ecto_sql 3.5.3) lib/ecto/migration.ex:1261: Ecto.Migration.__prefix__/1
(ecto_sql 3.5.3) lib/ecto/migration.ex:525: Ecto.Migration.create/1
priv/repo/migrations/20210120060822_add_author_id_to_pages.exs:10: (module)
(stdlib 3.13.2) erl_eval.erl:680: :erl_eval.do_apply/6
(elixir 1.11.2) lib/code.ex:1172: Code.compile_file/2
(ecto_sql 3.5.3) lib/ecto/migrator.ex:626: Ecto.Migrator.load_migration!/1
(elixir 1.11.2) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
(elixir 1.11.2) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
(ecto_sql 3.5.3) lib/ecto/migrator.ex:430: Ecto.Migrator.run/4
(ecto_sql 3.5.3) lib/ecto/migrator.ex:145: Ecto.Migrator.with_repo/3
这是迁移:
defmodule Hello.Repo.Migrations.AddAuthorIdToPages do
use Ecto.Migration
def change do
alter table(:pages) do
add :author_id, references(:authors, on_delete: :delete_all), null: false
end
end
create index(:pages, [:author_id])
end
解决方案
这是因为我在街区create index
外接到了电话。def change
将其更改为此有效:
defmodule Hello.Repo.Migrations.AddAuthorIdToPages do
use Ecto.Migration
def change do
alter table(:pages) do
add :author_id, references(:authors, on_delete: :delete_all), null: false
end
create index(:pages, [:author_id])
end
end
推荐阅读
- sql - 使用带多个条件 SQL 的左连接
- c# - 我在 c# 中使用 html 代码和 css 来设计按钮,但我不知道如何在单击后将其重定向到另一个页面(ASP.net)
- javascript - 在外部 html 页面中所做的更改不起作用
- css - Fontawesome5 图标不适用于 Drupal 8 中的伪代码
- rabbitmq - rabbitmq-server 没有启动(状态=64)
- python - PySpark-亚马逊评论情绪分析-RDD问题
- javascript - 如何在ajax中插入一个数组?
- ios - 我们在哪里可以在 Metal 中使用点坐标系
- java - JIRA客户端不断抛出一个现有的连接被远程主机异常强行关闭
- javascript - 由于未定义变量,函数调用出现错误