0

I'm trying to upgrade a system from 5.66.2 to 5.67.3 & this is the second problem I've had with this system, both to do with mailings. BTW this system was installed in 2013 and there have been a couple of problems where database settings have differed from more recent implementations.

Here's the error:

Type    DB_Error
Code    -3
Message DB Error: constraint violation
Mode    16
UserInfo    UPDATE civicrm_mailing_event_queue q 
INNER JOIN civicrm_mailing_job job ON job.id = q.job_id 
SET q.mailing_id = job.mailing_id, q.is_test=job.is_test 
WHERE q.id >= 31 AND q.id <= 267217 AND q.mailing_id IS NULL 
[nativecode=1452 ** Cannot add or update a child row: a foreign key constraint 
fails (`dcmadmin_civicrm`.`civicrm_mailing_event_queue`, 
CONSTRAINT `civicrm_mailing_event_queue_ibfk_1` 
FOREIGN KEY (`mailing_id`) 
REFERENCES `civicrm_mailing` (`id`) ON DELETE SET NULL)]

Also this may be useful:

Civi\Core\Exception\DBQueryException: DB Error: constraint violation in 
/home/dcmadmin/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php on line 945
- DB_Error: DB Error: constraint violation in unknown on line unknown.

Can anyone help, please?

4
  • Is this the same as civicrm.stackexchange.com/questions/46045/… ?
    – Demerit
    Commented Dec 21, 2023 at 6:31
  • Almost - I had that problem so restored the database, ran the SQL to fix, and then ran the upgrade again last evening. The title of the first step that crashed was 'Update civicrm_mailing_event_queue to permit deleting records from civicrm_mailing_job' and this step is 'Backfill civicrm_mailing_event_queue to permit deleting records from civicrm_mailing_job'
    – Andy Clark
    Commented Dec 21, 2023 at 8:29
  • Looking at the foreign key constraints for civicrm_mailing_event_queue I see there are - none! This db was created in 2013 & has somehow missed out on db updates. One possible way to fix this is to delete all mailings, then add the FK constraints. Is that going to work? I'm thinking that simply adding the FK constraints with a lot of data might cause problems.
    – Andy Clark
    Commented Dec 21, 2023 at 14:13
  • It will be slow to add if there's lots of mailings but if you run it in the backend it shouldn't time out. If you do want to delete all mailings, you could just recreate the table completely to match a good db.
    – Demerit
    Commented Dec 21, 2023 at 14:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.