Terminology could not be imported due strange DB foreign key failure

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • None
    • Affects Version/s: None
    • Component/s: TermPortal

      This is issue is a follow up to the fix of TRANSLATE-1472. But it happened only on www.translate5.net. After applying the fox for TRANSLATE-1472 tasks with terminology could not be imported any more. The following error message was logged:
       
      Something went wrong with tbx file parsing. Error message:SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`translate5Net`.`LEK_term_attributes`, CONSTRAINT `fk_LEK_term_attributes_2` FOREIGN KEY (`termId`) REFERENCES `LEK_terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE), query was: INSERT INTO `LEK_term_attributes` (`labelId`, `collectionId`, `termId`, `parentId`, `internalCount`, `language`, `name`, `attrType`, `attrDataType`, `attrTarget`, `attrId`, `attrLang`, `value`, `updated`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
       
      This is very strange since the inserted data / foreign key DID exists in the LEK_terms table.
      The solution was to drop and recreate the key. That solved that strange error.
       
      ALTER TABLE `LEK_term_attributes` DROP FOREIGN KEY `fk_LEK_term_attributes_2`;
      ALTER TABLE `LEK_term_attributes` ADD
      CONSTRAINT `fk_LEK_term_attributes_2` FOREIGN KEY (`termId`) REFERENCES `LEK_terms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
       

            Assignee:
            Thomas Lauria
            Reporter:
            Thomas Lauria
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: