Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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.


Comment on Re: DBIx::Class::Schema::Loader and on_delete/cascade_delete
Download Code
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?

    xoxo,
    Andy

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (19)
As of 2014-08-27 14:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (239 votes), past polls