Tuesday 3 April 2012

MySQL: ERROR 1005 ADD CONSTRAINT FOREIGN KEY

I couldn't figure this error out until I read Michael McLaughlin's Technical Blog:

decoding-1005-on-mysql

As suggested this was my problem:
The most common variation that I’ve run into is where the primary key column uses a int unsigned data type and the foreign key column uses an int data type. It’s quite nice that the InnoDB Engine stops this cold. Naturally, you fix it by changing the foreign key data type to match the int unsigned data type.
 Talk about saving your day!

No comments:

Post a Comment