Error On Rename
I was trying testing a migration script for mysql yesterday and I would make a change, then run the script, then drop the tables and constraints and then make a change to the script again and repeat. As soon as I got the foreign key constraints in place I suddenly got this error message when trying to clean up.
mysql> alter table registrationtoken_registrationtoken drop column licensescope_id ; ERROR 1025 (HY000): Error on rename of './mydb/#sql-389f_804' to './mydb/registrationtoken_registrationtoken' (errno: 150)
So then I tried removing the FK first and then I started getting this similar message.
mysql> alter table registrationtoken_registrationtoken drop foreign key licensescope_id_refs_id_1e76779c ; ERROR 1025 (HY000): Error on rename of './mydb/registrationtoken_registrationtoken' to './mydb/#sql2-389f-807' (errno: 152)
After poking around and then leaving the problem alone for a while I discovered this useful command for the InnoDB databases engine.
mysql> show innodb status;
This was most helpful in guiding me to the problem, which had to do with having changed the name of the FK earlier and not updating my script (i.e. misspelled foreign key). Mysql is awesome, but can have some useless errors. Glad I was able to find the show innodb status command to shed more light on ‘error on rename’.