Add new column with a default to Artist, adjust tests as necessary (no functional...
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / Artist.pm
1 package # hide from PAUSE 
2     DBICTest::Schema::Artist;
3
4 use base 'DBIx::Class::Core';
5
6 __PACKAGE__->table('artist');
7 __PACKAGE__->source_info({
8     "source_info_key_A" => "source_info_value_A",
9     "source_info_key_B" => "source_info_value_B",
10     "source_info_key_C" => "source_info_value_C",
11 });
12 __PACKAGE__->add_columns(
13   'artistid' => {
14     data_type => 'integer',
15     is_auto_increment => 1,
16   },
17   'name' => {
18     data_type => 'varchar',
19     size      => 100,
20     is_nullable => 1,
21   },
22   rank => {
23     data_type => 'integer',
24     default_value => 13,
25   },
26 );
27 __PACKAGE__->set_primary_key('artistid');
28
29 __PACKAGE__->mk_classdata('field_name_for', {
30     artistid    => 'primary key',
31     name        => 'artist name',
32 });
33
34 __PACKAGE__->has_many(
35     cds => 'DBICTest::Schema::CD', undef,
36     { order_by => 'year' },
37 );
38 __PACKAGE__->has_many(
39     cds_unordered => 'DBICTest::Schema::CD'
40 );
41
42 __PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' );
43 __PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' );
44
45 __PACKAGE__->has_many(
46   artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap',
47   [ {'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'} ],
48   { cascade_copy => 0 } # this would *so* not make sense
49 );
50
51 sub sqlt_deploy_hook {
52   my ($self, $sqlt_table) = @_;
53
54
55   if ($sqlt_table->schema->translator->producer_type =~ /SQLite$/ ) {
56     $sqlt_table->add_index( name => 'artist_name', fields => ['name'] )
57       or die $sqlt_table->error;
58   }
59 }
60
61 1;