around add_column(Column $column) { $self->$orig($column->name, $column) }
around add_index(Index $index) { $self->$orig($index->name, $index) }
- around add_constraint(Constraint $constraint) { $self->$orig($constraint->name, $constraint) }
around add_sequence(Sequence $sequence) { $self->$orig($sequence->name, $sequence) }
+ around add_constraint(Constraint $constraint) {
+ my $name = $constraint->name;
+ if ($name eq '') {
+ my $index = 0;
+ while ($self->exists_constraint('ANON' . $index)) { $index++ }
+ $name = 'ANON' . $index;
+ }
+ $self->$orig($name, $constraint)
+ }
multi method primary_key(Any $) { grep /^PRIMARY KEY$/, $_->type for $self->get_constraints }
multi method primary_key(Str $column) { $self->get_column($column)->is_primary_key(1) }