I want to migrate one of my database from myisam to innodb. The main reason is to allow my application to honor referential integrity.
This is what I did
- Exported the current myisam database
- Dropped the database
- Switched to innodb database http://parasjain.net/2010/06/08/how-to-switch-to-innodb-database-in-mysql/
- Verified the engine switch, then created the new database
The referential integrity works now. For example, if I create Parent p1 and Child c1 and refer p1 in c1, I can't delete P1 as long as there is a child dependent on it.
So far so good
But the problem occurs when I import the old data from the exported dump
The problem is that the Referential Integrity is honored for the new data. But in my existing data if there is any relationship like p2 referred by c2 then I can delete p2 breaking the referential integrity. c2 is orphan now.
Is there any way of repairing/re-indexing the tables so that referential integrity is enforced on the existing data too?