Error 1005 when adding a foreign key constraint on mysql table
Posted
by luc
on Stack Overflow
See other posts from Stack Overflow
or by luc
Published on 2010-05-12T11:47:16Z
Indexed on
2010/05/17
9:00 UTC
Read the original article
Hit count: 183
Hello,
I have a problem when upgrading a django and mysql app with south.
I've tried to make a sql-based upgrade with the code generated by the django sqlall command and I have a similar problem.
Here is the sql code:
CREATE TABLE `programmations_basissupport` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`value` numeric(6, 0) NOT NULL
)
ALTER TABLE `programmations_concert` ADD `basis_support_id` integer AFTER program_status_id;
ALTER TABLE `programmations_concert` ADD CONSTRAINT `basis_support_id_refs_id_1e4ed8d7` FOREIGN KEY (`basis_support_id`) REFERENCES `programmations_basissupport` (`id`);
An error is raised when adding the FK constraint:
ERROR 1005 (HY000): Can't create table 'apidev_mnl.#sql-106e_632b00a' (errno: 150)
Does anybody have an idea?
Update: DEFAULT values where missing but even if I add the default='' in the django model, the creation of foreign keys fails.
Thanks for your help
© Stack Overflow or respective owner