From: Justin Hunter Date: Sun, 12 Jul 2009 15:22:22 +0000 (-0700) Subject: don't create an index if one already exists (favor PRIMARY_KEY over UNIQUE) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e283ffd7efdf75de364f338d7ceb67ecc00d3395;p=dbsrgits%2FSQL-Translator-2.0-ish.git don't create an index if one already exists (favor PRIMARY_KEY over UNIQUE) --- diff --git a/lib/SQL/Translator/Parser/DBI.pm b/lib/SQL/Translator/Parser/DBI.pm index 35f0a36..43dd657 100644 --- a/lib/SQL/Translator/Parser/DBI.pm +++ b/lib/SQL/Translator/Parser/DBI.pm @@ -150,6 +150,7 @@ sub _add_indexes { $index_type = $index_col->{NON_UNIQUE} ? 'NORMAL' : 'UNIQUE'; push @index_cols, $index_col->{COLUMN_NAME}; } + return if $table->exists_index($index_name); my $index = Index->new({ name => $index_name, type => $index_type }); $index->add_column($table->get_column($_)) for @index_cols; $table->add_index($index);