[GH-ISSUE #31] Failed to drop an indexed column #160

Open
opened 2026-03-07 20:41:41 +03:00 by kerem · 0 comments
Owner

Originally created by @djshen-ponddy on GitHub (Nov 4, 2016).
Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/31

If we drop an indexed column, its index is also dropped.
For example,
Source DB:

CREATE TABLE IF NOT EXISTS `aa` (
  `id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Target DB:

CREATE TABLE IF NOT EXISTS `aa` (
  `id` int(11) NOT NULL,
  `name` varchar(36) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `name_index` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Generated migration:

ALTER TABLE `aa` DROP `name`;
ALTER TABLE `aa` DROP INDEX `name_index`;

If we apply the migration, it fails with error message #1091 - Can't DROP 'name_index'; check that column/key exists

Originally created by @djshen-ponddy on GitHub (Nov 4, 2016). Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/31 If we drop an indexed column, its index is also dropped. For example, Source DB: ```sql CREATE TABLE IF NOT EXISTS `aa` ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ``` Target DB: ```sql CREATE TABLE IF NOT EXISTS `aa` ( `id` int(11) NOT NULL, `name` varchar(36) NOT NULL, PRIMARY KEY (`id`), KEY `name_index` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; ``` Generated migration: ```sql ALTER TABLE `aa` DROP `name`; ALTER TABLE `aa` DROP INDEX `name_index`; ``` If we apply the migration, it fails with error message `#1091 - Can't DROP 'name_index'; check that column/key exists `
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/DBDiff#160
No description provided.