Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: DBIx::Class::Schema::Loader and on_delete/cascade_delete

by tilly (Archbishop)
on Feb 15, 2012 at 18:51 UTC ( #954035=note: print w/replies, xml ) Need Help??

in reply to DBIx::Class::Schema::Loader and on_delete/cascade_delete

DBIx::Class::Schema::Loader is building your schema in a sensible manner.

If you delete a List, the database will correctly delete all of the associated Notifications. If you delete a Notification, cpan::DBIx::Class will correctly not delete the associated List. There is no need to delete Notifications in Perl given than the database already did it, and there is likewise no need to tell the database to not delete Lists, because it won't try to do that.

Note that it is more efficient to have on_delete => 'CASCADE' in the database rather than having to do a round trip through Perl to cascade deletes. However some users don't like it there because it makes it too easy to accidentally wipe all of your data when doing routine maintenance. I understand that making this optional is a feature request for a future version of DBIx::Class::Schema:::Loader.

Replies are listed 'Best First'.
Re^2: DBIx::Class::Schema::Loader and on_delete/cascade_delete
by petdance (Parson) on Feb 15, 2012 at 19:03 UTC

    Thanks, Ben. What confuses me is why they are set differently.

    The way I understand this is that cascade_delete => 0 tells DBIC that it's not necessary for DBIC to delete the notifications manually, because Postgres will have done it automatically. That makes sense.

    But then why is there the on_delete => "CASCADE" at the notification level? What does DBIC do with that bit of knowledge?


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://954035]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2021-09-28 19:28 GMT
Find Nodes?
    Voting Booth?

    No recent polls found