From: Ed J Date: Sat, 29 Feb 2020 00:38:41 +0000 (+0000) Subject: alter_drop_constraint drop constraint, not index X-Git-Tag: v1.61~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ae95e48e16c26a573063628ea56c2d54040e88f9;p=dbsrgits%2FSQL-Translator.git alter_drop_constraint drop constraint, not index --- diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm index c8586a9..9e06b54 100644 --- a/lib/SQL/Translator/Producer/MySQL.pm +++ b/lib/SQL/Translator/Producer/MySQL.pm @@ -716,7 +716,7 @@ sub alter_drop_constraint push @out, $c->type; } else { - push @out, ($c->type eq FOREIGN_KEY ? $c->type : "INDEX"), + push @out, ($c->type eq FOREIGN_KEY ? $c->type : "CONSTRAINT"), $generator->quote($c->name); } return join(' ',@out); diff --git a/t/30sqlt-new-diff-mysql.t b/t/30sqlt-new-diff-mysql.t index 25064d4..ee6674e 100644 --- a/t/30sqlt-new-diff-mysql.t +++ b/t/30sqlt-new-diff-mysql.t @@ -64,7 +64,7 @@ ALTER TABLE old_name RENAME TO new_name; ALTER TABLE employee DROP FOREIGN KEY FK5302D47D93FE702E; -ALTER TABLE person DROP INDEX UC_age_name; +ALTER TABLE person DROP CONSTRAINT UC_age_name; ALTER TABLE person DROP INDEX u_name; @@ -127,7 +127,7 @@ ALTER TABLE employee DROP COLUMN job_title; ALTER TABLE old_name RENAME TO new_name, ADD COLUMN new_field integer NULL; -ALTER TABLE person DROP INDEX UC_age_name, +ALTER TABLE person DROP CONSTRAINT UC_age_name, ADD COLUMN is_rock_star tinyint(4) NULL DEFAULT 1, CHANGE COLUMN person_id person_id integer(11) NOT NULL auto_increment, CHANGE COLUMN name name varchar(20) NOT NULL, @@ -196,7 +196,7 @@ 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 INDEX UC_age_name, +ALTER TABLE person DROP CONSTRAINT UC_age_name, DROP INDEX u_name, ADD COLUMN is_rock_star tinyint(4) NULL DEFAULT 1, ADD COLUMN value double(8, 2) NULL DEFAULT 0.00,