| | 288 | sub drop_index_sql { |
| | 289 | my $ddl = shift; |
| | 290 | my ($class, $key) = @_; |
| | 291 | my $table_name = $class->table_name; |
| | 292 | |
| | 293 | my $props = $class->properties; |
| | 294 | my $indexes = $props->{indexes}; |
| | 295 | return q() unless exists($indexes->{$key}); |
| | 296 | |
| | 297 | if (ref $indexes->{$key} eq 'HASH') { |
| | 298 | my $idx_info = $indexes->{$key}; |
| | 299 | if ($idx_info->{unique} && $ddl->can_add_constraint) { |
| | 300 | return "ALTER TABLE $table_name DROP CONSTRAINT ${table_name}_$key"; |
| | 301 | } |
| | 302 | } |
| | 303 | |
| | 304 | return "DROP INDEX ${table_name}_$key"; |
| | 305 | } |
| | 306 | |