当我在 Doctrine 迁移中运行以下查询时,我看到以下错误:
ALTER TABLE crmpicco_course_version DROP FOREIGN KEY FK_C060B146DE13F470
Migration 20151209153121 failed during Execution.
Error An exception occurred while executing
'ALTER TABLE crmpicco_course_version DROP FOREIGN KEY FK_C060B146DE13F470':
SQLSTATE[HY000]: General error:
1025 Error on rename of './crmpicco_dev/crmpicco_course_version'
to './crmpicco_dev/#sql2-77c-b0a' (errno: 152)
这是我要更改的表:
CREATE TABLE `crmpicco_course_version` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`course_id` int(11) NOT NULL,
`updated_by_id` int(11) DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`start_date` datetime DEFAULT NULL,
`end_date` datetime DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `IDX_C060B146896DBBDE` (`updated_by_id`),
KEY `IDX_C060B146DE13F470` (`course_id`),
CONSTRAINT `FK_C060B146896DBBDE` FOREIGN KEY (`updated_by_id`) REFERENCES `crmpicco_user` (`id`),
CONSTRAINT `FK_C060B146DE13F470` FOREIGN KEY (`course_id`) REFERENCES `crmpicco_course` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
是什么阻止我成功删除这个外键?
当我运行时,SHOW ENGINE INNODB STATUS
我得到以下信息:
------------------------
LATEST FOREIGN KEY ERROR
------------------------
151209 16:25:42 Error IN dropping of a FOREIGN KEY CONSTRAINT of TABLE "crmpicco_dev"."crmpicco_course_version",
IN SQL command
ALTER TABLE crmpicco_course_version DROP FOREIGN KEY FK_C060B146DE13F470
Cannot find a CONSTRAINT WITH the given id "FK_C060B146DE13F470".