I have a table like so:
CREATE TABLE `Words` (
`wordId` int(11) NOT NULL AUTO_INCREMENT,
... snip! ...
`PartOfSpeechpartOfSpeechId` int(11) DEFAULT NULL,
PRIMARY KEY (`wordId`) USING BTREE,
KEY `fk_Words_PartOfSpeech` (`PartOfSpeechpartOfSpeechId`),
CONSTRAINT `fk_Words_PartOfSpeech` FOREIGN KEY (`PartOfSpeechpartOfSpeechId`) REFERENCES `PartOfSpeech` (`partOfSpeechId`) ON DELETE SET NULL ON UPDATE NO ACTION,
) ENGINE=InnoDB AUTO_INCREMENT=7306 DEFAULT CHARSET=utf8
I need to convert the PartOfSpeechpartOfSpeechId column into an enumerated value (ie keep it as an INT column, but remove the table it references entirely).
Trying to drop the PartOfSpeech table fails as one would expect, due to the FK on Words. To fix this, I've run ALTER TABLE Words DROP FOREIGN KEY fk_Words_PartOfSpeech
, using the name of the FK instead of the column as noted everywhere. I still get an error:
ERROR 1025 (HY000): Error on rename of './lexercise/#sql-1a5_263' to './lexercise/Words' (errno: 150)
On looking for the table Words, it has vanished. Gone. No idea where to. Presumably, MySQL's internal alter table code is creating a temp table and is failing to return it to its proper name/location.
What is going on here? How is it possible to lose a whole table on dropping a foreign key? My background is in Postgres, not sure how best to debug this.