more cleanup of the test suite so that we can run it against other databases. fixed...
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / TreeLike.pm
CommitLineData
c6d74d3e 1package # hide from PAUSE
2 DBICTest::Schema::TreeLike;
38a0b4ff 3
ff657a43 4use base qw/DBIx::Class::Core/;
38a0b4ff 5
6__PACKAGE__->table('treelike');
7__PACKAGE__->add_columns(
8 'id' => { data_type => 'integer', is_auto_increment => 1 },
8871d4ad 9 'parent_fk' => { data_type => 'integer' , is_nullable=>1},
cb561d1a 10 'name' => { data_type => 'varchar',
11 size => 100,
12 },
38a0b4ff 13);
14__PACKAGE__->set_primary_key(qw/id/);
5db49b9a 15__PACKAGE__->belongs_to('parent', 'TreeLike',
8871d4ad 16 { 'foreign.id' => 'self.parent_fk' });
17__PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent_fk' => 'self.id' });
38a0b4ff 18
89cf6a70 19## since this is a self referential table we need to do a post deploy hook and get
20## some data in while constraints are off
21
22 sub sqlt_deploy_hook {
23 my ($self, $sqlt_table) = @_;
24
25 $sqlt_table->add_index(name => 'idx_name', fields => ['name']);
26 }
38a0b4ff 271;