Coming from rails, I was used to using the on_delete: :restrict option in migrations for foreign keys.
Is there a similar way to do this in Ecto? I could only see :nothing, :delete_all and : nilify_all.
Does this need to be done at the application level instead?
1 Like
That’s the :nothing
option - no action is taken, so the error from the foreign key bubbles up.
3 Likes
That makes sense now I think about it! Thanks @michalmuskala
1 Like
For posterity, this :restrict
option now exists. Docs ATOW: https://hexdocs.pm/ecto_sql/Ecto.Migration.html#references/2
1 Like