Add strict/warnings test, adjust all offenders (wow, that was a lot)
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / TreeLike.pm
1 package # hide from PAUSE
2     DBICTest::Schema::TreeLike;
3
4 use warnings;
5 use strict;
6
7 use base qw/DBICTest::BaseResult/;
8
9 __PACKAGE__->table('treelike');
10 __PACKAGE__->add_columns(
11   'id' => { data_type => 'integer', is_auto_increment => 1 },
12   'parent' => { data_type => 'integer' , is_nullable=>1},
13   'name' => { data_type => 'varchar',
14     size      => 100,
15  },
16 );
17 __PACKAGE__->set_primary_key(qw/id/);
18 __PACKAGE__->belongs_to('parent', 'TreeLike',
19                           { 'foreign.id' => 'self.parent' });
20 __PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent' => 'self.id' });
21
22 ## since this is a self referential table we need to do a post deploy hook and get
23 ## some data in while constraints are off
24
25  sub sqlt_deploy_hook {
26    my ($self, $sqlt_table) = @_;
27
28    ## We don't seem to need this anymore, but keeping it for the moment
29    ## $sqlt_table->add_index(name => 'idx_name', fields => ['name']);
30  }
31 1;