lots of updates to make the test suite work with databases other than sqlite
[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 },
9 'parent' => { data_type => 'integer' },
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',
38a0b4ff 16 { 'foreign.id' => 'self.parent' });
af4cd3e5 17__PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent' => '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;