]> Dogcows Code - chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate/blob - t/lib/DBICTest/Schema/CD.pm
fcd72028051a77ff181d98c4b5c2186290b7258b
[chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate] / t / lib / DBICTest / Schema / CD.pm
1 package # hide from PAUSE
2 DBICTest::Schema::CD;
3
4 use base 'DBIx::Class::Core';
5
6 __PACKAGE__->table('cd');
7 __PACKAGE__->add_columns(
8 'cdid' => {
9 data_type => 'integer',
10 is_auto_increment => 1,
11 },
12 'artist' => {
13 data_type => 'integer',
14 },
15 'title' => {
16 data_type => 'varchar',
17 size => 100,
18 },
19 'year' => {
20 data_type => 'varchar',
21 size => 100,
22 },
23 'genreid' => {
24 data_type => 'integer',
25 is_nullable => 1,
26 },
27 'single_track' => {
28 data_type => 'integer',
29 is_nullable => 1,
30 is_foreign_key => 1,
31 }
32 );
33 __PACKAGE__->set_primary_key('cdid');
34 __PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
35
36 __PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, {
37 is_deferrable => 1,
38 });
39
40 # in case this is a single-cd it promotes a track from another cd
41 __PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track' );
42
43 __PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
44 __PACKAGE__->has_many(
45 tags => 'DBICTest::Schema::Tag', undef,
46 { order_by => 'tag' },
47 );
48 __PACKAGE__->has_many(
49 cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
50 );
51
52 __PACKAGE__->might_have(
53 liner_notes => 'DBICTest::Schema::LinerNotes', undef,
54 { proxy => [ qw/notes/ ] },
55 );
56 __PACKAGE__->might_have(artwork => 'DBICTest::Schema::Artwork', 'cd_id');
57
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' },
62 );
63
64 __PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre',
65 { 'foreign.genreid' => 'self.genreid' },
66 {
67 join_type => 'left',
68 on_delete => 'SET NULL',
69 on_update => 'CASCADE',
70
71 },
72 );
73
74 #__PACKAGE__->add_relationship('genre', 'DBICTest::Schema::Genre',
75 # { 'foreign.genreid' => 'self.genreid' },
76 # { 'accessor' => 'single' }
77 #);
78
79 __PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
80
81 package DBICTest::Schema::CD::ResultSet;
82
83 use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
84
85
86 1;
This page took 0.035973 seconds and 3 git commands to generate.