Answers.Body: <p>This appears to be identical to <a href="https://issues.civicrm.org/jira/browse/CRM-12458" rel="nofollow noreferrer">CRM-12458</a>.  Which is unusual - most cases where you'd get this error were solved in <a href="https://issues.civicrm.org/jira/browse/CRM-11260" rel="nofollow noreferrer">CRM-11260</a> but there are still edge cases that can cause this.</p>
  
  <p>I would read those links in full - but my guess is you should edit <code>CRM/Upgrade/Incremental/php/FourThree.php</code>.  Remove the <a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Upgrade/Incremental/php/FourThree.php#L883-L886" rel="nofollow noreferrer">four highlighted lined at this link</a> - that is, lines 883-886.</p>
  
  <p>Since you're dropping a foreign key constraint that doesn't exist, there should be no difference as a result of removing these lines.  Note that you may have to remove some of the following lines if you get similar errors.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-20T14:32:08.860Z
Answers.Text: Thank you for the fast response. I did try commenting out those lines, and the upgrade failed with the exact same message. The only difference this time being, after I hit refresh to try and force the upgrade to continue, then another message occurred:
Answers.UserDisplayName: RowboTony
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-20T16:46:34.470Z
Answers.Text: The "Duplicate column name" suggests that perhaps you didn't restore the pre-upgrade database before trying again.  For that matter, that would also cause the original issue you're describing.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-20T21:13:58.627Z
Answers.Text: Thank you again for your guidance. I also attempted the upgrade with the previous version of the database restored from last weeks's pre-upgraded CiviCRM 4.2.8 (_to an new freshly created empty MySQL database_), and still receive the same error.  The 4.2.8 version is the oldest backup I have, so it seems something has already gone awry with the `FK_civicrm_membership_autorenewal_msg_id` in whatever backup database copies I have as well.  We'll stay with v4.2.20 for the time being. Thanks again!
Answers.UserDisplayName: RowboTony
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-20T22:59:58.450Z
Answers.Text: 4.2 is VERY old and has known security issues.  While you might have to deal with a handful of fields like this, my guess is that you don't have anything of value in the `civicrm_premiums.premiums_nothankyou_position` field.  If not, simply drop the column from your database schema and retry this.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-20T02:49:01.057Z
Answers.LastActivityDate: 2018-09-20T02:49:01.057Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I have successfully upgraded many other CiviCRM installations over the years, but I've been unable to work my  way through this issue so far.</p>
  
  <ul>
  <li>Ubuntu 14.04 </li>
  <li>MySQL 5.7.23 </li>
  <li>Apache/2.4.7</li>
  <li>PHP Version 5.6.37 </li>
  <li>Drupal 7.59 </li>
  <li>CiviCRM 4.2.20</li>
  </ul>
  
  <p>I am trying to upgrade CiviCRM 4.2.20 to 4.3.11. Ultimately the goal is to get to 4.6 LTS. I have tried repairing the CiviCRM schema (<em>this database has only 2 custom fields</em>), and I've also tried the <code>SET foreign_key_checks = 0;</code> work around on importing the db, but I've still been unsuccessful at upgrading. I always hit this error at the stage of:</p>
  
  <blockquote>
    <p>[Error: Upgrade DB to 4.3.alpha1]</p>
    
    <p>ALTER TABLE civicrm_membership_type DROP FOREIGN KEY
    FK_civicrm_membership_autorenewal_msg_id [nativecode=1091 ** Can't
    DROP 'FK_civicrm_membership_autorenewal_msg_id'; check that column/key
    exists]</p>
  </blockquote>
  
  <p>I found a helpful thread somewhere that suggesting that MySQL 5.5 may have been the culprit, so I upgraded to MySQL 5.7, and still get the exact same error regardless of MySQL version. I have a fresh export and backups, so every time I try something it is with a fresh working version of the database on 4.2.20. Any help is greatly appreciated!</p>
  
  <p>Thank you,<br>
  --Tony</p>
  
  <p><a href="https://i.sstatic.net/KjfrD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KjfrD.png" alt="Error: Upgrade DB to 4.3.alpha1"></a></p>
  
  <p><strong>Update</strong>
  <a href="https://civicrm.stackexchange.com/questions/26561/upgrade-to-civicrm-4-3-failing-on-drop-foreign-key?answertab=votes#tab-top">Based on Jon G's suggestion</a> I tried commenting out <a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Upgrade/Incremental/php/FourThree.php#L883-L886" rel="nofollow noreferrer">the offending lines</a> in <code>CRM/Upgrade/Incremental/php/FourThree.php</code>, reloaded a fresh database for upgrading, but still continued to receive the exact same error.  The only difference this time being, after I hit refresh to try and force the upgrade to continue, then another message occurred:</p>
  
  <blockquote>
    <p>ALTER TABLE civicrm_premiums ADD COLUMN
    premiums_nothankyou_position int(10) unsigned DEFAULT '1'
    [nativecode=1060 ** Duplicate column name
    'premiums_nothankyou_position']</p>
  </blockquote>
  
  <p>I couldn't grep any more lines to comment out of the <code>FourThree.php</code> upgrade file, and wasn't sure how this would affect database integrity. The suggested threads (<a href="https://issues.civicrm.org/jira/browse/CRM-12458" rel="nofollow noreferrer" title="CRM-12458">CRM-12458</a>, <a href="https://issues.civicrm.org/jira/browse/CRM-11260" rel="nofollow noreferrer" title="CRM-11260">CRM-11260</a>)  seem to relate, but I was ultimately unable to use the information to solve this issue, admittedly due to the lack in my technical understanding.</p>
  
Tags: <upgrade><database>
Title: Upgrade to CiviCRM 4.3 failing on DROP FOREIGN KEY
ThreadText: # Upgrade to CiviCRM 4.3 failing on DROP FOREIGN KEY
  
  (Asked by: username_0 on 2018-09-20)
  
  I have successfully upgraded many other CiviCRM installations over the years, but I've been unable to work my way through this issue so far.
  
  * Ubuntu 14.04
  * MySQL 5.7.23
  * Apache/2.4.7
  * PHP Version 5.6.37
  * Drupal 7.59
  * CiviCRM 4.2.20
  
  I am trying to upgrade CiviCRM 4.2.20 to 4.3.11. Ultimately the goal is to get to 4.6 LTS. I have tried repairing the CiviCRM schema (*this database has only 2 custom fields*), and I've also tried the `SET foreign_key_checks = 0;` work around on importing the db, but I've still been unsuccessful at upgrading. I always hit this error at the stage of:
  
  > [Error: Upgrade DB to 4.3.alpha1]
  >
  > ALTER TABLE civicrm\_membership\_type DROP FOREIGN KEY
  > FK\_civicrm\_membership\_autorenewal\_msg\_id [nativecode=1091 \*\* Can't
  > DROP 'FK\_civicrm\_membership\_autorenewal\_msg\_id'; check that column/key
  > exists]
  
  I found a helpful thread somewhere that suggesting that MySQL 5.5 may have been the culprit, so I upgraded to MySQL 5.7, and still get the exact same error regardless of MySQL version. I have a fresh export and backups, so every time I try something it is with a fresh working version of the database on 4.2.20. Any help is greatly appreciated!
  
  Thank you,  
  --Tony
  
  [![Error: Upgrade DB to 4.3.alpha1](https://i.sstatic.net/KjfrD.png)](https://i.sstatic.net/KjfrD.png)
  
  **Update**
  [Based on Jon G's suggestion](https://civicrm.stackexchange.com/questions/26561/upgrade-to-civicrm-4-3-failing-on-drop-foreign-key?answertab=votes#tab-top) I tried commenting out [the offending lines](https://github.com/civicrm/civicrm-core/blob/master/CRM/Upgrade/Incremental/php/FourThree.php#L883-L886) in `CRM/Upgrade/Incremental/php/FourThree.php`, reloaded a fresh database for upgrading, but still continued to receive the exact same error. The only difference this time being, after I hit refresh to try and force the upgrade to continue, then another message occurred:
  
  > ALTER TABLE civicrm\_premiums ADD COLUMN
  > premiums\_nothankyou\_position int(10) unsigned DEFAULT '1'
  > [nativecode=1060 \*\* Duplicate column name
  > 'premiums\_nothankyou\_position']
  
  I couldn't grep any more lines to comment out of the `FourThree.php` upgrade file, and wasn't sure how this would affect database integrity. The suggested threads ([CRM-12458](https://issues.civicrm.org/jira/browse/CRM-12458 "CRM-12458"), [CRM-11260](https://issues.civicrm.org/jira/browse/CRM-11260 "CRM-11260")) seem to relate, but I was ultimately unable to use the information to solve this issue, admittedly due to the lack in my technical understanding.
  
  **Tags:** upgrade, database
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-20. Score: 1
  
  This appears to be identical to [CRM-12458](https://issues.civicrm.org/jira/browse/CRM-12458). Which is unusual - most cases where you'd get this error were solved in [CRM-11260](https://issues.civicrm.org/jira/browse/CRM-11260) but there are still edge cases that can cause this.
  
  I would read those links in full - but my guess is you should edit `CRM/Upgrade/Incremental/php/FourThree.php`. Remove the [four highlighted lined at this link](https://github.com/civicrm/civicrm-core/blob/master/CRM/Upgrade/Incremental/php/FourThree.php#L883-L886) - that is, lines 883-886.
  
  Since you're dropping a foreign key constraint that doesn't exist, there should be no difference as a result of removing these lines. Note that you may have to remove some of the following lines if you get similar errors.
  
  > **Comments:**
  > **username_0**: Thank you for the fast response. I did try commenting out those lines, and the upgrade failed with the exact same message. The only difference this time being, after I hit refresh to try and force the upgrade to continue, then another message occurred:  
  > **username_1**: The "Duplicate column name" suggests that perhaps you didn't restore the pre-upgrade database before trying again.  For that matter, that would also cause the original issue you're describing.  
  > **username_0**: Thank you again for your guidance. I also attempted the upgrade with the previous version of the database restored from last weeks's pre-upgraded CiviCRM 4.2.8 (_to an new freshly created empty MySQL database_), and still receive the same error.  The 4.2.8 version is the oldest backup I have, so it seems something has already gone awry with the `FK_civicrm_membership_autorenewal_msg_id` in whatever backup database copies I have as well.  We'll stay with v4.2.20 for the time being. Thanks again!  
  > **username_1**: 4.2 is VERY old and has known security issues.  While you might have to deal with a handful of fields like this, my guess is that you don't have anything of value in the `civicrm_premiums.premiums_nothankyou_position` field.  If not, simply drop the column from your database schema and retry this.  
  
  ---
  
  