Add unique constraints on columns referenced by foreign keys
[chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate] / t / lib / DBSchema / Result / Dvd.pm
1 package DBSchema::Result::Dvd;
2
3 # Created by DBIx::Class::Schema::Loader v0.03000 @ 2006-10-02 08:24:09
4
5 use strict;
6 use warnings;
7
8 use base 'DBIx::Class';
9 use overload '""' => sub {$_[0]->name}, fallback => 1;
10
11 __PACKAGE__->load_components(qw/IntrospectableM2M Core/);
12 __PACKAGE__->table('dvd');
13 __PACKAGE__->add_columns(
14 'dvd_id' => {
15 data_type => 'integer',
16 is_auto_increment => 1
17 },
18 'name' => {
19 data_type => 'varchar',
20 size => 100,
21 is_nullable => 1,
22 },
23 'imdb_id' => {
24 data_type => 'varchar',
25 size => 100,
26 is_nullable => 1,
27 },
28 'owner' => { data_type => 'integer' },
29 'current_borrower' => {
30 data_type => 'integer',
31 is_nullable => 1,
32 },
33
34 'creation_date' => {
35 data_type => 'datetime',
36 is_nullable => 1,
37 },
38 'alter_date' => {
39 data_type => 'datetime',
40 is_nullable => 1,
41 },
42 'twokeysfk' => {
43 data_type => 'integer',
44 is_nullable => 1,
45 },
46 );
47 __PACKAGE__->set_primary_key('dvd_id');
48 __PACKAGE__->add_unique_constraint(dvd_name => [qw(name)]);
49 __PACKAGE__->add_unique_constraint(dvd_twokeys => [qw(twokeysfk)]);
50 __PACKAGE__->belongs_to('owner', 'DBSchema::Result::User', 'owner');
51 __PACKAGE__->belongs_to('current_borrower', 'DBSchema::Result::User', 'current_borrower', { join_type => "LEFT" });
52 __PACKAGE__->has_many('dvdtags', 'Dvdtag', { 'foreign.dvd' => 'self.dvd_id' });
53 __PACKAGE__->has_many('viewings', 'DBSchema::Result::Viewing', { 'foreign.dvd_id' => 'self.dvd_id' });
54 __PACKAGE__->many_to_many('tags', 'dvdtags' => 'tag');
55 __PACKAGE__->might_have(
56 liner_notes => 'DBSchema::Result::LinerNotes', undef,
57 { proxy => [ qw/notes/ ] },
58 );
59 __PACKAGE__->add_relationship('like_has_many', 'DBSchema::Result::Twokeys', { 'foreign.dvd_name' => 'self.name' }, { accessor => 'multi', accessor_name => 'like_has_many' } );
60 __PACKAGE__->add_relationship('like_has_many2', 'DBSchema::Result::Twokeys_belongsto',
61 { 'foreign.key1' => 'self.twokeysfk' },
62 { accessor => 'multi' },
63 );
64
65 1;
66
This page took 0.035152 seconds and 4 git commands to generate.