From: Ash Berlin Date: Wed, 6 Feb 2008 15:17:18 +0000 (+0000) Subject: Fix drop indexes for uniq constraints X-Git-Tag: v0.11008~339 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=74ca32cee1a50c5c166a0e3f8cc1ecdcfe76ad23;p=dbsrgits%2FSQL-Translator.git Fix drop indexes for uniq constraints --- diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm index 9b65bb7..22d0e37 100644 --- a/lib/SQL/Translator/Producer/MySQL.pm +++ b/lib/SQL/Translator/Producer/MySQL.pm @@ -502,7 +502,7 @@ sub alter_drop_constraint my $out = sprintf('ALTER TABLE %s DROP %s %s', $c->table->name, - $c->type, + $c->type eq FOREIGN_KEY ? $c->type : "INDEX", $qc . $c->name . $qc ); return $out; diff --git a/t/30sqlt-new-diff-mysql.t b/t/30sqlt-new-diff-mysql.t index fced6af..4f3ad16 100644 --- a/t/30sqlt-new-diff-mysql.t +++ b/t/30sqlt-new-diff-mysql.t @@ -53,7 +53,7 @@ SET foreign_key_checks=1; ALTER TABLE old_name RENAME TO new_name; ALTER TABLE employee DROP FOREIGN KEY FK5302D47D93FE702E; -ALTER TABLE person DROP UNIQUE UC_age_name; +ALTER TABLE person DROP INDEX UC_age_name; ALTER TABLE person DROP INDEX u_name; ALTER TABLE employee DROP COLUMN job_title; ALTER TABLE new_name ADD COLUMN new_field integer; @@ -98,7 +98,7 @@ SET foreign_key_checks=1; ALTER TABLE employee DROP COLUMN job_title; ALTER TABLE old_name RENAME TO new_name, ADD COLUMN new_field integer; -ALTER TABLE person DROP UNIQUE UC_age_name, +ALTER TABLE person DROP INDEX UC_age_name, ADD COLUMN is_rock_star tinyint(4) DEFAULT '1', CHANGE COLUMN person_id person_id integer(11) NOT NULL auto_increment, CHANGE COLUMN name name varchar(20) NOT NULL, @@ -165,7 +165,7 @@ SET foreign_key_checks=1; ALTER TABLE employee DROP FOREIGN KEY FK5302D47D93FE702E, DROP COLUMN job_title, ADD CONSTRAINT FK5302D47D93FE702E_diff FOREIGN KEY (employee_id) REFERENCES person (person_id); -ALTER TABLE person DROP UNIQUE UC_age_name, +ALTER TABLE person DROP INDEX UC_age_name, DROP INDEX u_name, ADD COLUMN is_rock_star tinyint(4) DEFAULT '1', CHANGE COLUMN person_id person_id integer(11) NOT NULL auto_increment,