From f9eff31eaf45176b400acd6ac8fd820ae8240075 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 3 Feb 2016 16:36:10 -0800 Subject: [PATCH] Add IF EXISTS to DROP INDEX (except under MySQL) --- Changes | 3 +++ DBSchema.pm | 4 ++-- DBSchema/Table.pm | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index 6177c17..8d02b37 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl module DBIx::DBSchema +0.46 unreleased + - Add IF EXISTS to DROP INDEX (except under MySQL) + 0.45 Wed May 6 22:17:33 PDT 2015 - MySQL does not support DEFAULT for TEXT/BLOB columns, closes: CPAN#58505 - doc: Add repository information diff --git a/DBSchema.pm b/DBSchema.pm index bb523b7..af5cfd0 100644 --- a/DBSchema.pm +++ b/DBSchema.pm @@ -3,12 +3,12 @@ package DBIx::DBSchema; use strict; use Storable; use DBIx::DBSchema::_util qw(_load_driver _dbh _parse_opt); -use DBIx::DBSchema::Table 0.08; +use DBIx::DBSchema::Table 0.12; use DBIx::DBSchema::Index; use DBIx::DBSchema::Column; use DBIx::DBSchema::ForeignKey; -our $VERSION = '0.45'; +our $VERSION = '0.46_01'; $VERSION = eval $VERSION; # modperlstyle: convert the string into a number our $DEBUG = 0; diff --git a/DBSchema/Table.pm b/DBSchema/Table.pm index ef51928..67e2eea 100644 --- a/DBSchema/Table.pm +++ b/DBSchema/Table.pm @@ -7,7 +7,7 @@ use DBIx::DBSchema::Column 0.14; use DBIx::DBSchema::Index; use DBIx::DBSchema::ForeignKey 0.13; -our $VERSION = '0.11'; +our $VERSION = '0.12'; our $DEBUG = 0; =head1 NAME @@ -631,8 +631,8 @@ sub sql_alter_table { warn "removing obsolete index $table.$old ON ( ". $old_indices{$old}->columns_sql. " )\n" if $DEBUG > 1; - push @r, "DROP INDEX $old". - ( $driver eq 'mysql' ? " ON $table" : ''); + push @r, "DROP INDEX $old ". + ( $driver eq 'mysql' ? " ON $table" : ' IF EXISTS'); } foreach my $new ( keys %new_indices ) { -- 2.11.0