1 package # hide from PAUSE
2 DBICTest::Schema::TreeLike;
7 use base qw/DBICTest::BaseResult/;
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',
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' });
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
25 sub sqlt_deploy_hook {
26 my ($self, $sqlt_table) = @_;
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']);