This has bothered me for awhile. The way I’ve been renaming columns that have foreign keys thus far has been to first remove all the foreign key constraints on various tables, and their indexes… then I rename the column, then I re-add all the indexes and foreign keys on all the tables I removed.
This is very time-consuming… especially if I have tons of foreign keys to drop and re-add because it is being used in many tables in the database. Creating the migration files for these to run against the production database takes forever, and I gotta think there must be a way for mysql to be smarter than this.
Is there a simpler way? I need to maintain my data.
You can rename the fields with dependency check with a dbForge Studio for MySQL (get Cristmas discounts – 20% off, or try Express version ;-). I cannot say the it will be faster, but it will help you to rename these fields and recreate keys automatically in a few steps – just change its name in a Database Explorer and click on Refactor button in message box.