get_indices => 'values',
get_index => 'get',
add_index => 'set',
+ remove_index => 'delete',
},
default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
);
return $self->$orig($column->name, $column);
}
- around add_constraint(Constraint $constraint) {
+ around add_constraint(Constraint $constraint does coerce) {
my $name = $constraint->name;
if ($name eq '') {
my $idx = 0;
$self->$orig($name, $index)
}
- around add_sequence(Sequence $sequence) { $self->$orig($sequence->name, $sequence) }
+ around add_sequence(Sequence $sequence does coerce) { $self->$orig($sequence->name, $sequence) }
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) }
before name($name?) { die "Can't use table name $name, table already exists" if $name && $self->schema->exists_table($name) && $name ne $self->name }
multi method drop_column(Column $column, Int :$cascade = 0) {
- die "Can't drop non-existant table " . $column->name unless $self->exists_column($column->name);
+ die "Can't drop non-existant column " . $column->name unless $self->exists_column($column->name);
$self->remove_column($column->name);
}
multi method drop_column(Str $column, Int :$cascade = 0) {
- die "Can't drop non-existant table " . $column unless $self->exists_column($column);
+ die "Can't drop non-existant column " . $column unless $self->exists_column($column);
$self->remove_column($column);
}
+
+ multi method drop_index(Index $index) {
+ die "Can't drop non-existant index " . $index->name unless $self->exists_index($index->name);
+ $self->remove_index($index->name);
+
+ }
+
+ multi method drop_index(Str $index) {
+ die "Can't drop non-existant index " . $index unless $self->exists_index($index);
+ $self->remove_index($index);
+ }
}