Subject: | Field in UNIQUE + CONSTRAINT can give invalid SQL |
If a field appears in both a UNIQUE constraint and a CONSTRAINT, SQL::Translator does not
realize that the UNIQUE implies an index, inserts an INDEX, passes through the UNIQUE, and
then MySQL barfs because you have 2 indexes with the same name.
With the two example files I provided, try this and note that the UNIQUE and INDEX are named
the same thing:
---------
$ sqlt-diff from.sql=MySQL to.sql=MySQL
This code is experimental, currently the new code only supports MySQL or
SQLite diffing. To add support for other databases, please patch the relevant
SQL::Translator::Producer:: module. If you need compatibility with the old
sqlt-diff, please use sqlt-diff-old, and look into helping us make this one
work for you
-- Convert schema 'from.sql' to 'to.sql':;
BEGIN;
SET foreign_key_checks=0;
CREATE TABLE `service_one_click` (
`id` integer(11) NOT NULL auto_increment,
`database_name` varchar(64) NOT NULL,
INDEX `database_name` (`database_name`),
PRIMARY KEY (`id`),
CONSTRAINT `service_one_click_fk_database_name` FOREIGN KEY (`database_name`)
REFERENCES `service_database` (`name`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8;
SET foreign_key_checks=1;
COMMIT;
---------
Note that if you change the UNIQUE in to.sql to an INDEX, SQL::Translator understands that
the index is already there.
Subject: | to.sql |
Message body not shown because it is not plain text.
Subject: | from.sql |
Message body not shown because it is not plain text.