around add_table(Table $table) {
die "Can't use table name " . $table->name if $self->exists_table($table->name) || $table->name eq '';
+ $table->schema($self);
$self->$orig($table->name, $table);
}
+
around add_view(View $view) { $self->$orig($view->name, $view) }
around add_procedure(Procedure $procedure) { $self->$orig($procedure->name, $procedure) }
around add_trigger(Trigger $trigger) { $self->$orig($trigger->name, $trigger) }
is => 'rw',
isa => Schema,
weak_ref => 1,
- required => 1,
);
has 'temporary' => (
around add_column(Column $column does coerce) {
die "Can't use column name " . $column->name if $self->exists_column($column->name) || $column->name eq '';
+ $column->table($self);
return $self->$orig($column->name, $column);
}
+
around add_constraint(Constraint $constraint) {
my $name = $constraint->name;
if ($name eq '') {
while ($self->exists_constraint('ANON' . $idx)) { $idx++ }
$name = 'ANON' . $idx;
}
+ $constraint->table($self);
$self->$orig($name, $constraint)
}
+
around add_index(Index $index does coerce) {
my $name = $index->name;
if ($name eq '') {
while ($self->exists_index('ANON' . $idx)) { $idx++ }
$name = 'ANON' . $idx;
}
+ $index->table($self);
$self->$orig($name, $index)
}
+
around add_sequence(Sequence $sequence) { $self->$orig($sequence->name, $sequence) }
multi method primary_key(Any $) { grep /^PRIMARY KEY$/, $_->type for $self->get_constraints }