1 package # hide from PAUSE
4 use base 'DBIx::Class::Core';
6 __PACKAGE__->table('cd');
7 __PACKAGE__->add_columns(
9 data_type => 'integer',
10 is_auto_increment => 1,
13 data_type => 'integer',
16 data_type => 'varchar',
20 data_type => 'varchar',
24 data_type => 'integer',
28 data_type => 'integer',
33 __PACKAGE__->set_primary_key('cdid');
34 __PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
36 __PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, {
40 # in case this is a single-cd it promotes a track from another cd
41 __PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track' );
43 __PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
44 __PACKAGE__->has_many(
45 tags => 'DBICTest::Schema::Tag', undef,
46 { order_by => 'tag' },
48 __PACKAGE__->has_many(
49 cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
52 __PACKAGE__->might_have(
53 liner_notes => 'DBICTest::Schema::LinerNotes', undef,
54 { proxy => [ qw/notes/ ] },
56 __PACKAGE__->might_have(artwork => 'DBICTest::Schema::Artwork', 'cd_id');
58 __PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
59 __PACKAGE__->many_to_many(
60 producers_sorted => cd_to_producer => 'producer',
61 { order_by => 'producer.name' },
64 __PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre',
65 { 'foreign.genreid' => 'self.genreid' },
68 on_delete => 'SET NULL',
69 on_update => 'CASCADE',
73 #This second relationship was added to test the short-circuiting of pointless
74 #queries provided by undef_on_null_fk. the relevant test in 66relationship.t
75 __PACKAGE__->belongs_to('genre_inefficient', 'DBICTest::Schema::Genre',
76 { 'foreign.genreid' => 'self.genreid' },
79 on_delete => 'SET NULL',
80 on_update => 'CASCADE',
81 undef_on_null_fk => 0,
86 #__PACKAGE__->add_relationship('genre', 'DBICTest::Schema::Genre',
87 # { 'foreign.genreid' => 'self.genreid' },
88 # { 'accessor' => 'single' }