I have a parent, which has_many
children. Children have a restrict
constraint on the DB level: on_delete: :restrict
. Thus the error does not come as a surprise. The surprise part is later:
If you would like to stop this constraint violation from raising an
exception and instead add it as an error to your changeset, please
call `foreign_key_constraint/3` on your changeset with the constraint
`:name` as an option.
The changeset has not defined any constraint.
Now, how and where do I call foreign_key_constraint/3
when everything I do is actually Ecto.Repo.delete/2
for which no changeset is needed? I’d still prefer {:error, _something}
being returned rather than having an exception risen