Sunday, October 7, 2012

DBMigrate and References

Just wanted to blog about my issues using CFWheels DBMigrate with MySQL.
I am using MySQL 5.5 now, but up until recently had 5.1 on my local box and that meant tables defaulted to MyISAM.
I couldn't create foreign keys through DBMigrate on MyISAM tables. 
I would get errno 150 and errno 152 when attempting to create references.

Now that I've updated it's not so much of an issue anymore. But I am still having issues with removing references.

I can't seem to use dropReference or removeColumn to get rid of references, instead I have to
use a combination of:

dropForeignKey(table='videostatistics', keyName='videostatistics_ibfk_2');removeIndex(table='videostatistics', indexName='FK_videostatistics_agendaitems');
removeColumn(table='videostatistics', columnName='agendaitemid');


2 comments:

Unknown said...

Thanks Cathy, removing the index as well as the FK has solved this problem for me.. I couldn't work out why the FKs weren't being removed.

Thanks for posting!

CS said...

Glad it was helpful!