【发布时间】:2016-11-09 00:18:34
【问题描述】:
我有一个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.
我尝试将foreign_key_constraint/3 添加到两个模型的默认变更集中,但错误仍然存在。
【问题讨论】:
标签: database postgresql phoenix-framework ecto