| 1 | package DBIO::Test::Schema::TreeLike; | ||
| 2 | # ABSTRACT: Test result class for the treelike table | ||
| 3 | |||
| 4 | 256 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 256 | our $VERSION = '0.900007'; | |
| 7 | |||
| 8 | 256 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 256 | ▶ | use base qw/DBIO::Test::BaseResult/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 256 | __PACKAGE__->table('treelike'); | |
| 13 | 256 | __PACKAGE__->add_columns( | |
| 14 | 'id' => { data_type => 'integer', is_auto_increment => 1 }, | ||
| 15 | 'parent' => { data_type => 'integer' , is_nullable=>1}, | ||
| 16 | 'name' => { data_type => 'varchar', | ||
| 17 | size => 100, | ||
| 18 | }, | ||
| 19 | ); | ||
| 20 | 256 | __PACKAGE__->set_primary_key(qw/id/); | |
| 21 | 256 | __PACKAGE__->belongs_to('parent', 'TreeLike', | |
| 22 | { 'foreign.id' => 'self.parent' }); | ||
| 23 | 256 | __PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent' => 'self.id' }); | |
| 24 | |||
| 25 | ## since this is a self referential table we need to do a post deploy hook and get | ||
| 26 | ## some data in while constraints are off | ||
| 27 | |||
| 28 | 0 | ▶ | sub sqlt_deploy_hook { |
|
Subroutine
sqlt_deploy_hook: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 29 | 0 | my ($self, $sqlt_table) = @_; | |
| 30 | |||
| 31 | ## We don't seem to need this anymore, but keeping it for the moment | ||
| 32 | ## $sqlt_table->add_index(name => 'idx_name', fields => ['name']); | ||
| 33 | } | ||
| 34 | 256 | 1; | |
| 35 | |||
| 36 | __END__ | ||