After running the command to upgrade the database I got a constraint violation error.
ERROR USERINFO: ALTER TABLE civicrm_case
ADD CONSTRAINT FK_civicrm_case_case_type_id
FOREIGN KEY (case_type_id
) REFERENCES civicrm_case_type
(id
) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails...
I tried adding the foreign key in the database but that did not work. I got this error: MySQL ERROR 1005: Can’t create table (errno: 150)
The Foreign Key exists on the my live site's db so I imported a db backup from the lives site. Ran the db update command again and got the same error.
How do I prevent the migration from deleting the foreign key?
This is my civicrm_case:
CREATE TABLE civicrm_case
(
id
int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique Case ID',case_type_id
int(10) unsigned NOT NULL COMMENT 'FK civicrm_case_type.id',subject
varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Short name of the case.',start_date
date DEFAULT NULL COMMENT 'Date on which given case starts.',end_date
date DEFAULT NULL COMMENT 'Date on which given case ends.',details
text COLLATE utf8_unicode_ci COMMENT 'Details about the meeting (agenda, notes, etc).',status_id
int(10) unsigned NOT NULL COMMENT 'Id of case status.',is_deleted
tinyint(4) DEFAULT '0', PRIMARY KEY (id
), KEYindex_case_type_id
(case_type_id
), KEYindex_is_deleted
(is_deleted
) ) ENGINE=InnoDB AUTO_INCREMENT=147 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;