treelike => [
{
'display' => 'treelike->treelike for parent',
- 'name' => 'treelike_fk_parent_fk', 'index_name' => 'treelike_idx_parent_fk',
+ 'name' => 'treelike_fk_parent', 'index_name' => 'treelike_idx_parent',
'selftable' => 'treelike', 'foreigntable' => 'treelike',
- 'selfcols' => ['parent_fk'], 'foreigncols' => ['id'],
+ 'selfcols' => ['parent'], 'foreigncols' => ['id'],
on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
},
],
]);
$schema->populate('TreeLike', [
- [ qw/id parent_fk name/ ],
+ [ qw/id parent name/ ],
[ 1, undef, 'root' ],
[ 2, 1, 'foo' ],
[ 3, 2, 'bar' ],
__PACKAGE__->table('treelike');
__PACKAGE__->add_columns(
'id' => { data_type => 'integer', is_auto_increment => 1 },
- 'parent_fk' => { data_type => 'integer' , is_nullable=>1},
+ 'parent' => { data_type => 'integer' , is_nullable=>1},
'name' => { data_type => 'varchar',
size => 100,
},
);
__PACKAGE__->set_primary_key(qw/id/);
__PACKAGE__->belongs_to('parent', 'TreeLike',
- { 'foreign.id' => 'self.parent_fk' });
-__PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent_fk' => 'self.id' });
+ { '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
--
CREATE TABLE treelike (
id INTEGER PRIMARY KEY NOT NULL,
- parent_fk integer NULL,
+ parent integer NULL,
name varchar(100) NOT NULL
);