On Saturday, May 2, 2020 at 2:59:38 PM UTC-7, Michael Monerau wrote:
>
> Hi,
>
> I usually consider putting a ON DELETE CASCADE & ON UPDATE CASCADE on 
> foreign keys to be a good practice. I'm happy to have the database-layer 
> ensure referential integrity.
>
> Reading some past discussions on this google group seems to confirm that. 
> (I would be glad to understand if/how it can be nuanced though)
>
> While reading the Sequel docs, I realized that the `create_join_table` 
> method does not include those cascading options on the foreign keys it 
> creates though (nor an option to include them).
>
> Is there a reason why it is unnecessary or should not be done in this case?
> Or maybe it is a place where the Sequel API could be extended?
>

In general ON DELETE CASCADE can significantly multiple the damage of an 
unexpected deletion.  A deletion of one row can result in deleting many 
other rows in other tables.  Maybe that is what you want, but I don't think 
it's a good default. There is a reason databases don't default to ON DELETE 
CASCADE.

If you want to create a join table with ON DELETE CASCADE, just use 
create_table instead of create_join_table.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/740b5df9-25f4-4d92-9f9b-a2b218c4727c%40googlegroups.com.

Reply via email to