Constraint error when attempting to delete struct

Maybe You could set the on_delete option between user and its addresses association.

By default, it will do nothing… Thus I think it is why You get this error.

For this to work, You could look at

https://hexdocs.pm/ecto/Ecto.Migration.html#references/2

and

https://hexdocs.pm/ecto/Ecto.Schema.html#has_one/3

This would be in your addresses migration

add :user_id, references("users"), on_delete: :delete_all

and in the schema

has_one :addresses, Assistant.Web.Address, on_delete: :delete_all

It is not tested, but it might help…

3 Likes