2

I want to upgrade my site (Drupal 7.54 to 7.55, then civicrm 4.7.16 to 4.7.20).

No problem on Drupal upgrade.

But for CiviCRM, when I run mysite/drupal/?q=civicrm/upgrade&reset=1 (after having replaced sites/all/civicrm directory content) :

  • upgrade to 4.7.17 runs OK
  • upgrade to 4.7.18 fails with the following error :

enter image description here

(BTW, civicrm_case table is empty on my site)

1
  • had same issue upgrading from 4.6 to 4.7 running that SQL code in phpmyadmin fixed it. THANKS!!!! ALTER TABLE civicrm_case ADD CONSTRAINT FK_civicrm_case_case_type_id FOREIGN KEY (case_type_id) REFERENCES civicrm_case_type (id) ON DELETE SET NULL; Commented Feb 22, 2018 at 21:06

3 Answers 3

1

It appears that the foreign key mentioned in the error message doesn't exist for some reason. I would probably go into MySQL and check. If it's not there, just create one with the same name on the civicrm_case table. Then try the upgrade again.

A MySQL statement to create the foreign key (from CiviCRM 4.5) is: ADD CONSTRAINT FK_civicrm_case_case_type_id FOREIGN KEY (case_type_id) REFERENCES civicrm_case_type (id) ON DELETE SET NULL;

2
  • Thank you Dave ; but, before I run this statement, how can I check that this foreign Key does not exist ? Actually, in my civicrm_case table, there is an UNSIGNED "case_type_id" field, commented as being "FK to civicrm_case_type.id" : isn't it already what is required ? (BTW, this table is empty) Commented Jun 21, 2017 at 7:08
  • Well, the easiest way would be to run the add constraint command. If it already exists, the add will fail with some message. No harm done. I have no idea why the FK doesn't exist, probably a prior upgrade failed somewhere along the way. If you want to really check for the constraint, here's how: stackoverflow.com/questions/4004205/…
    – DaveD
    Commented Jun 21, 2017 at 12:56
0

I had the very same problem and I had to fix it by running the following command:

ALTER TABLE civicrm_case
ADD CONSTRAINT FK_civicrm_case_case_type_id FOREIGN KEY (case_type_id) REFERENCES civicrm_case_type (id) ON DELETE SET NULL;

(taken from CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl).

1
  • I did it and it worked fine ; thank you to both of you Commented Jun 28, 2017 at 7:30
-1

had same issue upgrading from 4.6 to 4.7

running that SQL code in phpmyadmin fixed it. THANKS!!!!

ALTER TABLE civicrm_case ADD CONSTRAINT FK_civicrm_case_case_type_id FOREIGN KEY (case_type_id) REFERENCES civicrm_case_type (id) ON DELETE SET NULL;

3
  • 1
    This is not an Answer and should be added as a Comment
    – petednz - fuzion
    Commented Feb 26, 2018 at 2:18
  • Thanks for the info but I need 50 reputation before I have the ability to add a comment to other peoples answers. I am following the guidelines since I am affirming the solution that worked for me. your comment and downvote are not helpful to anyone. Commented Jun 18, 2018 at 17:27
  • Yep, I see that. Apologies. Trying to figure how I can convert your Answer to be a Comment only Onlyjob's Answer - then I can +1 your comment and help you get some reputation.
    – petednz - fuzion
    Commented Jun 18, 2018 at 20:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.