小编jam*_*svl的帖子

Elixir Ecto:如何创建自引用外键?

在Ecto迁移中,实现引用其自身表的外键的正确方法是什么?

例如,我想创建一个表,其中任何行都可以引用同一表中的“父”行。(一种处理分层数据的方法;还有许多其他方法。)

但是,当我在变更集中使用它时,运行时会出现很多错误mix ecto.migrate

create_if_not_exists table(:perms, prefix: :accts) do
  add :title, :string, size: 64, null: false
  add :description, :text
  add :parent_id, :integer, references(:perms)
end
Run Code Online (Sandbox Code Playgroud)

该错误消息始于(UndefinedFunctionError) undefined function Ecto.Migration.Reference.fetch/2 (Ecto.Migration.Reference does not implement the Access behaviour)GenServer终止之前。(这在ecto 1.1.5和2.0.0-beta2下发生。)

elixir ecto

3
推荐指数
1
解决办法
757
查看次数

标签 统计

ecto ×1

elixir ×1