[Dbix-class] cascade deletion in multi-joined classes
Hideo Kimura
hide at hide-k.net
Mon Mar 6 00:16:26 CET 2006
Hi all,
I have classes mentioned below.
Then I tried:
my $schema = CD::Schema->connect('dbi:SQLite:cd.db');
$schema->resultset('Artists')->delete_all;
It will delete all artists and albums, but doesn't delete tracks.
Does not DBIx::Class support recursive cascade deletion?
Regards.
Hide
---
package CD::Schema::Artists;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/Core/);
__PACKAGE__->table('artists');
__PACKAGE__->add_columns(qw/ id name /);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->has_many('albums' => 'CD::Schema::Albums', 'artist');
1;
package CD::Schema::Albums;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/Core/);
__PACKAGE__->table('albums');
__PACKAGE__->add_columns(qw/ id artist title /);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->belongs_to('artist' => 'CD::Schema::Artists');
__PACKAGE__->has_many('tracks' => 'CD::Schema::Tracks', 'album');
1;
package CD::Schema::Tracks;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/Core/);
__PACKAGE__->table('tracks');
__PACKAGE__->add_columns(qw/ id album title /);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->belongs_to('album' => 'CD::Schema::Albums');
1;
More information about the Dbix-class
mailing list