Commit | Line | Data |
8273e845 |
1 | package # hide from PAUSE |
c6d74d3e |
2 | DBICTest::Schema::TreeLike; |
38a0b4ff |
3 | |
4a233f30 |
4 | use warnings; |
5 | use strict; |
6 | |
660cf1be |
7 | use base qw/DBICTest::BaseResult/; |
38a0b4ff |
8 | |
9 | __PACKAGE__->table('treelike'); |
10 | __PACKAGE__->add_columns( |
11 | 'id' => { data_type => 'integer', is_auto_increment => 1 }, |
61177e44 |
12 | 'parent' => { data_type => 'integer' , is_nullable=>1}, |
cb561d1a |
13 | 'name' => { data_type => 'varchar', |
14 | size => 100, |
15 | }, |
38a0b4ff |
16 | ); |
17 | __PACKAGE__->set_primary_key(qw/id/); |
5db49b9a |
18 | __PACKAGE__->belongs_to('parent', 'TreeLike', |
61177e44 |
19 | { 'foreign.id' => 'self.parent' }); |
20 | __PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent' => 'self.id' }); |
38a0b4ff |
21 | |
89cf6a70 |
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 | |
64cdad22 |
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']); |
89cf6a70 |
30 | } |
38a0b4ff |
31 | 1; |