pt-online-schema-change loses foreign keys
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Fix Released
|
High
|
Daniel Nichter | ||
2.0 |
Won't Fix
|
Undecided
|
Unassigned | ||
2.1 |
Fix Released
|
High
|
Daniel Nichter |
Bug Description
The use of CREATE TABLE LIKE is causing foreign keys to disappear.
Before:
CREATE TABLE `film_actor` (
`actor_id` smallint(5) unsigned NOT NULL,
`film_id` smallint(5) unsigned NOT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`actor_
KEY `idx_fk_film_id` (`film_id`),
CONSTRAINT `fk_film_
CONSTRAINT `fk_film_
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
After:
CREATE TABLE `film_actor` (
`actor_id` smallint(5) unsigned NOT NULL,
`film_id` smallint(5) unsigned NOT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`baron` int(11) DEFAULT NULL,
PRIMARY KEY (`actor_
KEY `idx_fk_film_id` (`film_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I believe that the solution needs to be retrieving the SHOW CREATE and sending it back to the server again with a different name.
Related branches
- Daniel Nichter: Approve
-
Diff: 226 lines (+96/-11)2 files modifiedbin/pt-online-schema-change (+44/-7)
t/pt-online-schema-change/basics.t (+52/-4)
Changed in percona-toolkit: | |
status: | Confirmed → In Progress |
assignee: | nobody → Daniel Nichter (daniel-nichter) |
I've pushed some code that solves this into the branch linked to this bug.