小编Rom*_*z C的帖子

尝试删除struct时出现Ecto约束错误

我有一个User模型,has_many医学信息和医学信息belongs_to用户.

当我尝试删除User具有相关记录(医疗信息)的时,Ecto给我以下错误:

 ** (Ecto.ConstraintError) constraint error when attempting to delete struct:

     * foreign_key: medical_informations_user_id_fkey

 If you would like to convert this constraint into an error, please
 call foreign_key_constraint/3 in your changeset and define the proper
 constraint name. The changeset has not defined any constraint.
Run Code Online (Sandbox Code Playgroud)

我试图foreign_key_constraint/3在两个模型中添加到我的默认变更集,但错误仍在继续.

database postgresql ecto phoenix-framework

2
推荐指数
1
解决办法
1705
查看次数

标签 统计

database ×1

ecto ×1

phoenix-framework ×1

postgresql ×1