6

I was running a 4.6 instance of CiviCRM and am attempting to upgrade to 4.7. Every time I initiate an upgrade, things work well until it reaches 4.7alpha stage of the upgrade. Then I get an error that I cannot drop mapping_id from the civicrm_action_schedule table. I've retried this several times with the same result. I checked and both the table and field exist in the original table. Any ideas about how to resolve this?

Here is a screenshot of the error:

Error Mssg

[EDIT: Adding searchable text from someone with the same issue to make this easier to find]

 * ERROR USERINFO: ALTER TABLE `civicrm_action_schedule` DROP FOREIGN KEY `FK_civicrm_action_schedule_mapping_id` [nativecode=1091 ** Can't DROP 'FK_civicrm_action_schedule_mapping_id'; check that column/key exists]
 * ERROR DEBUGINFO: ALTER TABLE `civicrm_action_schedule` DROP FOREIGN KEY `FK_civicrm_action_schedule_mapping_id` [nativecode=1091 ** Can't DROP 'FK_civicrm_action_schedule_mapping_id'; check that column/key exists]
#0 [internal function](): CRM_Core_Error::exceptionHandler(Object(DB_Error))
#1 /usr/share/drupal7/modules/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#2 /usr/share/drupal7/modules/civicrm/packages/DB.php(976): PEAR_Error->PEAR_Error("DB Error: not found", -4, 16, (Array:2), "ALTER TABLE `civicrm_action_schedule` DROP FOREIGN KEY `FK_civicrm_action_sch...")
#3 /usr/share/drupal7/modules/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-4, 16, (Array:2), "ALTER TABLE `civicrm_action_schedule` DROP FOREIGN KEY `FK_civicrm_action_sch...")
#4 /usr/share/drupal7/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -4, NULL, NULL, "ALTER TABLE `civicrm_action_schedule` DROP FOREIGN KEY `FK_civicrm_action_sch...", "DB_Error", TRUE)
#5 /usr/share/drupal7/modules/civicrm/packages/DB/mysql.php(895): DB_common->raiseError(-4, NULL, NULL, NULL, "1091 ** Can't DROP 'FK_civicrm_action_schedule_mapping_id'; check that column...")
#6 /usr/share/drupal7/modules/civicrm/packages/DB/mysql.php(328): DB_mysql->mysqlRaiseError()
#7 /usr/share/drupal7/modules/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("ALTER TABLE `civicrm_action_schedule` DROP FOREIGN KEY `FK_civicrm_action_sch...")
#8 /usr/share/drupal7/modules/civicrm/CRM/Utils/File.php(332): DB_common->query("ALTER TABLE `civicrm_action_schedule` DROP FOREIGN KEY `FK_civicrm_action_sch...")
#9 /usr/share/drupal7/modules/civicrm/CRM/Upgrade/Form.php(196): CRM_Utils_File::sourceSQLFile("mysql://root:asdf@localhost/civicrm?new_link=true", "-- Add new columns for multilingual purpose\nALTER TABLE `civicrm_action_sche...", NULL, TRUE)
#10 /usr/share/drupal7/modules/civicrm/CRM/Upgrade/Form.php(387): CRM_Upgrade_Form->source("-- Add new columns for multilingual purpose\nALTER TABLE `civicrm_action_sche...", TRUE)
#11 /usr/share/drupal7/modules/civicrm/CRM/Upgrade/Form.php(421): CRM_Upgrade_Form->processLocales("/usr/share/drupal7/modules/civicrm/CRM/Upgrade/Incremental/sql/4.7.alpha1.mys...", "4.7.alpha1")
#12 /usr/share/drupal7/modules/civicrm/CRM/Upgrade/Incremental/Base.php(80): CRM_Upgrade_Form->processSQL("4.7.alpha1")
#13 [internal function](): CRM_Upgrade_Incremental_Base::runSql(Object(CRM_Queue_TaskContext), "4.7.alpha1")
#14 /usr/share/drupal7/modules/civicrm/CRM/Queue/Task.php(88): call_user_func_array((Array:2), (Array:2))
#15 /usr/share/drupal7/modules/civicrm/CRM/Queue/Runner.php(214): CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))
#16 /usr/share/drupal7/modules/civicrm/CRM/Queue/Runner.php(168): CRM_Queue_Runner->runNext()
#17 /usr/share/drupal7/modules/civicrm/CRM/Upgrade/Headless.php(67): CRM_Queue_Runner->runAll()
#18 /usr/share/drupal7/modules/civicrm/drupal/drush/civicrm.drush.inc(707): CRM_Upgrade_Headless->run()
#19 [internal function](): drush_civicrm_upgrade_db()
#20 /usr/share/php/drush/includes/command.inc(334): call_user_func_array("drush_civicrm_upgrade_db", (Array:0))
#21 /usr/share/php/drush/includes/command.inc(208): _drush_invoke_hooks("civicrm-upgrade-db", (Array:0), "civicrm")
#22 [internal function](): drush_command()
#23 /usr/share/php/drush/includes/command.inc(175): call_user_func_array("drush_command", (Array:0))
#24 /usr/share/php/drush/drush.php(92): drush_dispatch((Array:27))
#25 /usr/share/php/drush/drush.php(61): _drush_bootstrap_and_dispatch()
#26 /usr/share/php/drush/drush.php(16): drush_main()
#27 {main}
WD php: PEAR_Exception: DB Error: not found in CRM_Core_Error::exceptionHandler() (line 913 of                                      [error]
/usr/share/drupal7/modules/civicrm/CRM/Core/Error.php).
Cannot modify header information - headers already sent by (output started at                                                       [warning]
/usr/share/drupal7/modules/civicrm/CRM/Upgrade/Headless.php:72) bootstrap.inc:1232
PEAR_Exception: DB Error: not found in CRM_Core_Error::exceptionHandler() (line 913 of /usr/share/drupal7/modules/civicrm/CRM/Core/Error.php).
Drush command terminated abnormally due to an unrecoverable error.                                                                  [error]
1

The SQL here isn't trying to drop the field - it's trying to drop the foreign key. So checking for the field isn't sufficient. You can look for foreign keys with:

SHOW CREATE TABLE civicrm_action_schedule;

This will give you the exact SQL statement needed to create the table as it currently exists, and will show foreign keys.

I have no idea how you ended up without the foreign key on that table. However, there's no harm in removing that statement from the upgrade SQL if that foreign key already doesn't exist. So after unzipping CiviCRM and before you run the database upgrade, edit <civicrmroot>/CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl and remove the offending SQL command (it's near the top!).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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