Some testdb changes and alignment, preparing for test refactor branch
[dbsrgits/DBIx-Class.git] / 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 );
28 __PACKAGE__->set_primary_key('cdid');
29 __PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
30
31 __PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, { 
32     is_deferrable => 1, 
33 });
34
35 __PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
36 __PACKAGE__->has_many(
37     tags => 'DBICTest::Schema::Tag', undef,
38     { order_by => 'tag' },
39 );
40 __PACKAGE__->has_many(
41     cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
42 );
43
44 __PACKAGE__->might_have(
45     liner_notes => 'DBICTest::Schema::LinerNotes', undef,
46     { proxy => [ qw/notes/ ] },
47 );
48 __PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
49 __PACKAGE__->many_to_many(
50     producers_sorted => cd_to_producer => 'producer',
51     { order_by => 'producer.name' },
52 );
53
54 __PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre',
55     { 'foreign.genreid' => 'self.genreid' },
56     {
57         join_type => 'left',
58         on_delete => 'SET NULL',
59         on_update => 'CASCADE',
60
61     },
62 );
63
64 #__PACKAGE__->add_relationship('genre', 'DBICTest::Schema::Genre',
65 #    { 'foreign.genreid' => 'self.genreid' },
66 #    { 'accessor' => 'single' }
67 #);
68
69 1;