lots of updates to make the test suite work with databases other than sqlite
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / TreeLike.pm
index 49abb69..b5b2763 100644 (file)
@@ -1,18 +1,27 @@
 package # hide from PAUSE 
     DBICTest::Schema::TreeLike;
 
-use base qw/DBIx::Class/;
-
-__PACKAGE__->load_components(qw/PK::Auto::SQLite Core/);
+use base qw/DBIx::Class::Core/;
 
 __PACKAGE__->table('treelike');
 __PACKAGE__->add_columns(
   'id' => { data_type => 'integer', is_auto_increment => 1 },
   'parent' => { data_type => 'integer' },
-  'name' => { data_type => 'varchar' },
+  'name' => { data_type => 'varchar',
+    size      => 100,
+ },
 );
 __PACKAGE__->set_primary_key(qw/id/);
 __PACKAGE__->belongs_to('parent', 'TreeLike',
                           { 'foreign.id' => 'self.parent' });
+__PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent' => 'self.id' });
+
+## since this is a self referential table we need to do a post deploy hook and get
+## some data in while constraints are off
+
+ sub sqlt_deploy_hook {
+   my ($self, $sqlt_table) = @_;
 
+   $sqlt_table->add_index(name => 'idx_name', fields => ['name']);
+ }
 1;