Save 36% for Black Friday! Learn more

New Discussion

Notifications

You’re not receiving notifications from this thread.

Foreign Key on_delete db Constraints Discussion

1
General

The add_foreign_key docs show all the various options for on_delete and others: https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_foreign_key

Hi Collin

Great episode, as ever: thank you

My question is "Why bother with the database constraints?". If the Rails associations allow you to specify (eg) "has_many :things, dependent: :nullify", why add the complexity of replicating this at the database level?

I'm sure there is a good reason, but it'd be great to know what it is

Join the discussion
Create an account Log in