Answers.Body: <p>UPDATE:  CRM-18526 fixes this issue - it's just been checked in.  To bypass this problem, upgrade to CiviCRM 4.7.8 or higher.</p>
  
  <p>John is correct about this being related to CRM-18345.  There are two problems with the upgrade code - and the <code>SET FOREIGN_KEY_CHECKS=0</code> others posted only solves one of them.</p>
  
  <p>I've <a href="https://issues.civicrm.org/jira/browse/CRM-18526" rel="nofollow">posted my analysis here</a>, and I expect that someone will fix this issue.  However, if you're experiencing this now and want to upgrade, here's what to do.  I'm assuming that folks reading this will feel comfortable editing a file on their server, but aren't generally comfortable playing around with MySQL constraints:</p>
  
  <p>First, restore your database to a state before the backup!</p>
  
  <p>When you upgrade, look at the error.  </p>
  
  <p><strong>Problem 1</strong>
  Does the SQL statement that failed have the words <code>DROP FOREIGN KEY</code> in it?  If so, the problem is that you don't have the foreign keys.  In this case, it's safe to delete the code that tries to remove the foreign key.  Open up the file <code>&lt;civicrmroot&gt;/CRM/Upgrade/Incremental/sql/4.7.5.mysql.tpl</code>.  Find the command <code>ALTER TABLE civicrm_mailing_event_queue DROP FOREIGN KEY FK_civicrm_mailing_event_queue_email_id</code> (or whichever command corresponds to the error you're getting) and delete it.  Reload the page and the upgrade will continue.  It's very likely that if you don't have one foreign key, you don't have all four - so expect to repeat this three times.  </p>
  
  <p><strong>Problem 2</strong> Does your SQL statement that failed have the words <code>ADD CONSTRAINT</code> in it?  If so, you've already encountered the problem this code is trying to fix - but the code doesn't work if you've already encountered the issue.  To resolve this, add the line <code>SET FOREIGN KEY CHECKS=0</code> on the line above the command that's giving you an error, and <code>SET FOREIGN KEY CHECKS=1</code> on the line directly below it.</p>
  
  <p>Don't forget - these commands are very similar, so if you think that this solution hasn't solved your problem, make sure you're looking at an identical error and not a very similar one!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-10T03:01:19.410Z
Answers.LastActivityDate: 2016-05-20T03:19:00.233Z
Answers.LastEditDate: 2016-05-20T03:19:00.233Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>This issue is related to this improvement that was made in a recent version:
  <a href="https://issues.civicrm.org/jira/browse/CRM-18345" rel="nofollow">https://issues.civicrm.org/jira/browse/CRM-18345</a></p>
  
  <p>The update function is deleting foreign key constraints - however it sounds like they were never set up in your database? You can inspect your database and check the status of the foreign keys as a test.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-09T15:38:32.480Z
Answers.LastActivityDate: 2016-05-09T15:38:32.480Z
Answers.UserDisplayName: John
Body: <p>We have attempted to upgrade the CiviCRM instance multiple times, but all attempts for that failed with the following error:</p>
  
  <blockquote>
    <p>ALTER TABLE <code>civicrm_mailing_event_queue</code> DROP FOREIGN KEY <code>FK_civicrm_mailing_event_queue_email_id</code> [nativecode=1091 ** Can't DROP 'FK_civicrm_mailing_event_queue_email_id'; check that column/key exists]</p>
  </blockquote>
  
  <p>I have followed multiple suggestions on the Internet of people experiencing similar (if not the same) issues, but this did not help either. For example, I have tried the following recommendation:</p>
  
  <blockquote>
    <p><a href="https://civicrm.stackexchange.com/questions/11318/unable-to-upgrade-to-4-7-6/11353">Unable to upgrade to 4.7.6</a></p>
  </blockquote>
  
  <p>but it did not resolve the issue. I have also followed the instructions here:</p>
  
  <blockquote>
    <p><a href="https://forum.civicrm.org/index.php?topic=29889.0" rel="nofollow noreferrer">https://forum.civicrm.org/index.php?topic=29889.0</a></p>
  </blockquote>
  
  <p>as well as the official documentation of CiviCRM here:</p>
  
  <blockquote>
    <p><a href="https://wiki.civicrm.org/confluence/display/CRMDOC/Ensuring+Schema+Integrity+on+Upgrades" rel="nofollow noreferrer">https://wiki.civicrm.org/confluence/display/CRMDOC/Ensuring+Schema+Integrity+on+Upgrades</a></p>
  </blockquote>
  
  <p>Here's my site profile link. <a href="https://mycivi.org/profile/snapshot/8yejn-Wwh0X-pHIht-GVWI3" rel="nofollow noreferrer">https://mycivi.org/profile/snapshot/8yejn-Wwh0X-pHIht-GVWI3</a></p>
  
  <p>Any suggestions on how to proceed?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-05-04T19:06:33.323Z
Comments.Text: Is this question incomplete? Anybody have any suggestions or insight on this issue? Am I supposed to provide any additional info?
Comments.UserDisplayName: V3rmie
Tags: <wordpress><upgrade>
Title: Upgrade Fails 4.7.4 - 4.7.6 in WP 4.5.1
ThreadText: # Upgrade Fails 4.7.4 - 4.7.6 in WP 4.5.1
  
  (Asked by: username_0 on 2016-04-29)
  
  We have attempted to upgrade the CiviCRM instance multiple times, but all attempts for that failed with the following error:
  
  > ALTER TABLE `civicrm_mailing_event_queue` DROP FOREIGN KEY `FK_civicrm_mailing_event_queue_email_id` [nativecode=1091 \*\* Can't DROP 'FK\_civicrm\_mailing\_event\_queue\_email\_id'; check that column/key exists]
  
  I have followed multiple suggestions on the Internet of people experiencing similar (if not the same) issues, but this did not help either. For example, I have tried the following recommendation:
  
  > [Unable to upgrade to 4.7.6](https://civicrm.stackexchange.com/questions/11318/unable-to-upgrade-to-4-7-6/11353)
  
  but it did not resolve the issue. I have also followed the instructions here:
  
  > <https://forum.civicrm.org/index.php?topic=29889.0>
  
  as well as the official documentation of CiviCRM here:
  
  > <https://wiki.civicrm.org/confluence/display/CRMDOC/Ensuring+Schema+Integrity+on+Upgrades>
  
  Here's my site profile link. <https://mycivi.org/profile/snapshot/8yejn-Wwh0X-pHIht-GVWI3>
  
  Any suggestions on how to proceed?
  
  **Tags:** wordpress, upgrade
  
  > **Comments:**
  > **username_0**: Is this question incomplete? Anybody have any suggestions or insight on this issue? Am I supposed to provide any additional info?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-05-10. Score: 5
  
  UPDATE: CRM-18526 fixes this issue - it's just been checked in. To bypass this problem, upgrade to CiviCRM 4.7.8 or higher.
  
  username_2 is correct about this being related to CRM-18345. There are two problems with the upgrade code - and the `SET FOREIGN_KEY_CHECKS=0` others posted only solves one of them.
  
  I've [posted my analysis here](https://issues.civicrm.org/jira/browse/CRM-18526), and I expect that someone will fix this issue. However, if you're experiencing this now and want to upgrade, here's what to do. I'm assuming that folks reading this will feel comfortable editing a file on their server, but aren't generally comfortable playing around with MySQL constraints:
  
  First, restore your database to a state before the backup!
  
  When you upgrade, look at the error.
  
  **Problem 1**
  Does the SQL statement that failed have the words `DROP FOREIGN KEY` in it? If so, the problem is that you don't have the foreign keys. In this case, it's safe to delete the code that tries to remove the foreign key. Open up the file `/CRM/Upgrade/Incremental/sql/4.7.5.mysql.tpl`. Find the command `ALTER TABLE civicrm_mailing_event_queue DROP FOREIGN KEY FK_civicrm_mailing_event_queue_email_id` (or whichever command corresponds to the error you're getting) and delete it. Reload the page and the upgrade will continue. It's very likely that if you don't have one foreign key, you don't have all four - so expect to repeat this three times.
  
  **Problem 2** Does your SQL statement that failed have the words `ADD CONSTRAINT` in it? If so, you've already encountered the problem this code is trying to fix - but the code doesn't work if you've already encountered the issue. To resolve this, add the line `SET FOREIGN KEY CHECKS=0` on the line above the command that's giving you an error, and `SET FOREIGN KEY CHECKS=1` on the line directly below it.
  
  Don't forget - these commands are very similar, so if you think that this solution hasn't solved your problem, make sure you're looking at an identical error and not a very similar one!
  
  
  ---
  
  ### Answer by username_2 on 2016-05-09. Score: 2
  
  This issue is related to this improvement that was made in a recent version:
  <https://issues.civicrm.org/jira/browse/CRM-18345>
  
  The update function is deleting foreign key constraints - however it sounds like they were never set up in your database? You can inspect your database and check the status of the foreign keys as a test.
  
  
  ---
  
  