Answers.Body: <p>Looks like in your CiviCRM system, <strong>Pending</strong> contribution recur status(/civicrm/admin/options/contribution_recur_status?reset=1) is either disabled or deleted.</p>
  <p>Before upgrading CiviCRM can you</p>
  <ol>
  <li>Enable the <strong>Pending</strong> Contribution recur status.</li>
  <li>Add <strong>Pending</strong> Contribution recur status if doesn't exist.</li>
  </ol>
  <p>Note: You may not be allowed to enable the status from GUI, Try using api explorer or mysql to enable it.</p>
  <p>Update:</p>
  <p>Looks like in your system Contribution Recur status is missing, run below query to add contribution recur status in your system</p>
  <pre><code>INSERT INTO `civicrm_option_group`  ( `name`, `title`, `is_active`, `is_reserved`, `is_locked` ) VALUES ('contribution_recur_status', 'Recurring Contribution Status', 1, 1, 1)
  ON DUPLICATE KEY UPDATE id=id;;
  
  SELECT @option_group_id_ps := MAX(id) FROM `civicrm_option_group` where name = 'contribution_recur_status';
  
  INSERT INTO `civicrm_option_value` (`option_group_id`, `label`, `value`, `name`, `weight`, `is_reserved`, `is_active`, `is_default`)
  SELECT @option_group_id_ps as option_group_id, `label`, value, ov.name, weight, ov.is_reserved, ov.is_active, is_default
  FROM civicrm_option_value ov
  INNER JOIN civicrm_option_group og
  ON og.id = ov.option_group_id AND og.name = 'contribution_status';
  
  SELECT @maxValue := MAX(CAST(value AS UNSIGNED))  FROM `civicrm_option_value` where option_group_id = @option_group_id_ps;
  SELECT @maxWeight := MAX(weight) FROM `civicrm_option_value` where option_group_id = @option_group_id_ps;
  
  INSERT INTO `civicrm_option_value` (
  `option_group_id`, `label`, `value`, `name`, `weight`, `is_reserved`, `is_active`, `is_default`
  )
  VALUES(
   @option_group_id_ps, 'Processing', @maxValue + 1, 'Processing', @maxWeight + 1, 1 , 1 , 0
  ),
  (
  @option_group_id_ps, 'Failing', @maxValue + 2, 'Failing', @maxWeight + 2, 1 , 1 , 0
  )
  ON DUPLICATE KEY UPDATE id=id;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-22T13:33:22.880Z
Answers.Text: Pending is in the list and enabled. Should I try removing it and adding it back?
Answers.UserDisplayName: Ben
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-22T13:38:45.863Z
Answers.Text: Can you run the query and paste the output on you question?
  
  ```SELECT cov.value, cov.label, cov.name, cov.is_active FROM civicrm_option_value cov
    INNER JOIN civicrm_option_group cog
      ON cog.id = cov.option_group_id
        AND cog.name = 'contribution_recur_status';```
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-22T13:44:17.443Z
Answers.Text: I have updated my answer, it is contribution recur status (NOT Contribution status)
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-22T13:51:12.000Z
Answers.Text: Thats getting closer to the issue. Going to: /civicrm/admin/options/contribution_recur_status?reset=1 results in this error message: Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred.
  getFieldValue failed
Answers.UserDisplayName: Ben
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-22T13:22:08.947Z
Answers.LastActivityDate: 2022-06-22T14:07:25.733Z
Answers.LastEditDate: 2022-06-22T14:07:25.733Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I have been handed responsibility for a CiviCRM site that is using 5.35.2 on Drupal 7 which fails to update. I'm 100% new to CiviCRM. Can anyone help me fix this issue?</p>
  <pre><code>[Error: core-issue#2487 Add / alter defaults for civicrm_contribution_recur]
  
  Error Field Error Value
  
  Type    DB_Error
  
  Code    -2
  
  Message DB Error: syntax error
  
  Mode    16
  
  UserInfo    ALTER TABLE `civicrm_contribution_recur` MODIFY COLUMN `start_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'The date the first scheduled recurring contribution occurs.', MODIFY COLUMN `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When this recurring contribution record was created.', MODIFY COLUMN `modified_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Last updated date for this record. mostly the last time a payment was received', MODIFY COLUMN `contribution_status_id` int(10) unsigned DEFAULT , MODIFY COLUMN `frequency_interval` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Number of time units for recurrence of payment.'; [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' MODIFY COLUMN `frequency_interval` int(10) unsigned NOT NULL DEFAULT 1 CO' at line 5]
  DebugInfo   ALTER TABLE `civicrm_contribution_recur` MODIFY COLUMN `start_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'The date the first scheduled recurring contribution occurs.', MODIFY COLUMN `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When this recurring contribution record was created.', MODIFY COLUMN `modified_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Last updated date for this record. mostly the last time a payment was received', MODIFY COLUMN `contribution_status_id` int(10) unsigned DEFAULT , MODIFY COLUMN `frequency_interval` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Number of time units for recurrence of payment.'; [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' MODIFY COLUMN `frequency_interval` int(10) unsigned NOT NULL DEFAULT 1 CO' at line 5]
  
  
  PEAR_Exception: DB Error: syntax error in /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php on line 922
  - DB_Error: DB Error: syntax error in unknown on line unknown
  Exception trace
  #   Function    Location
  0   CRM_Core_Error::exceptionHandler(Object(DB_Error))  /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:922
  1   PEAR_Error-&gt;__construct('DB Error: syntax…', -2, 16, Array, ' ALTER TAB…')  /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB.php:998
  2   DB_Error-&gt;__construct(-2, 16, Array, ' ALTER TAB…') /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:575
  3   PEAR-&gt;_raiseError(Object(DB_mysqli), null, -2, 16, Array, ' ALTER TAB…', 'DB_Error', true)  /home/findnm/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:223
  4   PEAR-&gt;__call('raiseError', Array)   /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB/common.php:1928
  5   DB_common-&gt;raiseError(-2, null, null, ' ALTER TAB…', '1064 ** You have…')   /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB/mysqli.php:936
  6   DB_mysqli-&gt;mysqliRaiseError()   /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB/mysqli.php:406
  7   DB_mysqli-&gt;simpleQuery(' ALTER TAB…')   /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB/common.php:1234
  8   DB_common-&gt;query(' ALTER TAB…') /home/ind/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php:2696
  9   DB_DataObject-&gt;_query(' ALTER TAB…')    /home/ind/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php:1829
  10  DB_DataObject-&gt;query(' ALTER TAB…') /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php:454
  11  CRM_Core_DAO-&gt;query(' ALTER TAB…', true)    /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php:1566
  12  CRM_Core_DAO::executeQuery(' ALTER TAB…')   /home/ind/public_html/sites/all/modules/civicrm/CRM/Upgrade/Incremental/php/FiveThirtySeven.php:138
  13  CRM_Upgrade_Incremental_php_FiveThirtySeven::updateDBDefaultsForContributionRecur(Object(CRM_Queue_TaskContext))    /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/Task.php:74
  14  CRM_Queue_Task-&gt;run(Object(CRM_Queue_TaskContext))  /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/Runner.php:201
  15  CRM_Queue_Runner-&gt;runNext(true) /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php:36
  16  CRM_Queue_Page_AJAX::{closure}()    /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/ErrorPolicy.php:89
  17  CRM_Queue_ErrorPolicy-&gt;call(Object(Closure))    /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php:38
  18  CRM_Queue_Page_AJAX::runNext()  /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php:279
  19  CRM_Core_Invoke::runItem(Array) /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php:69
  20  CRM_Core_Invoke::_invoke(Array) /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php:36
  21  CRM_Core_Invoke::invoke(Array)  /home/ind/public_html/sites/all/modules/civicrm/drupal/civicrm.module:458
  22  civicrm_invoke('upgrade', 'queue', 'ajax', 'runNext')   /home/ind/public_html/includes/menu.inc:527
  23  menu_execute_active_handler()   /home/ind/public_html/index.php:21
  24  {main}   
  </code></pre>
  <p>Thanks
  Bill</p>
  
Tags: <upgrade>
Title: update error - [Error: core-issue#2487 Add / alter defaults for civicrm_contribution_recur]
ThreadText: # update error - [Error: core-issue#2487 Add / alter defaults for civicrm_contribution_recur]
  
  (Asked by: username_0 on 2022-06-22)
  
  I have been handed responsibility for a CiviCRM site that is using 5.35.2 on Drupal 7 which fails to update. I'm 100% new to CiviCRM. Can anyone help me fix this issue?
  [Error: core-issue#2487 Add / alter defaults for civicrm_contribution_recur]
  
  Error Field Error Value
  
  Type    DB_Error
  
  Code    -2
  
  Message DB Error: syntax error
  
  Mode    16
  
  UserInfo    ALTER TABLE `civicrm_contribution_recur` MODIFY COLUMN `start_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'The date the first scheduled recurring contribution occurs.', MODIFY COLUMN `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When this recurring contribution record was created.', MODIFY COLUMN `modified_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Last updated date for this record. mostly the last time a payment was received', MODIFY COLUMN `contribution_status_id` int(10) unsigned DEFAULT , MODIFY COLUMN `frequency_interval` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Number of time units for recurrence of payment.'; [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' MODIFY COLUMN `frequency_interval` int(10) unsigned NOT NULL DEFAULT 1 CO' at line 5]
  DebugInfo   ALTER TABLE `civicrm_contribution_recur` MODIFY COLUMN `start_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'The date the first scheduled recurring contribution occurs.', MODIFY COLUMN `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When this recurring contribution record was created.', MODIFY COLUMN `modified_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Last updated date for this record. mostly the last time a payment was received', MODIFY COLUMN `contribution_status_id` int(10) unsigned DEFAULT , MODIFY COLUMN `frequency_interval` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Number of time units for recurrence of payment.'; [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' MODIFY COLUMN `frequency_interval` int(10) unsigned NOT NULL DEFAULT 1 CO' at line 5]
  
  
  PEAR_Exception: DB Error: syntax error in /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php on line 922
  - DB_Error: DB Error: syntax error in unknown on line unknown
  Exception trace
  #   Function    Location
  0   CRM_Core_Error::exceptionHandler(Object(DB_Error))  /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:922
  1   PEAR_Error->__construct('DB Error: syntax…', -2, 16, Array, ' ALTER TAB…')  /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB.php:998
  2   DB_Error->__construct(-2, 16, Array, ' ALTER TAB…') /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:575
  3   PEAR->_raiseError(Object(DB_mysqli), null, -2, 16, Array, ' ALTER TAB…', 'DB_Error', true)  /home/findnm/public_html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:223
  4   PEAR->__call('raiseError', Array)   /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB/common.php:1928
  5   DB_common->raiseError(-2, null, null, ' ALTER TAB…', '1064 ** You have…')   /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB/mysqli.php:936
  6   DB_mysqli->mysqliRaiseError()   /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB/mysqli.php:406
  7   DB_mysqli->simpleQuery(' ALTER TAB…')   /home/ind/public_html/sites/all/modules/civicrm/vendor/pear/db/DB/common.php:1234
  8   DB_common->query(' ALTER TAB…') /home/ind/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php:2696
  9   DB_DataObject->_query(' ALTER TAB…')    /home/ind/public_html/sites/all/modules/civicrm/packages/DB/DataObject.php:1829
  10  DB_DataObject->query(' ALTER TAB…') /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php:454
  11  CRM_Core_DAO->query(' ALTER TAB…', true)    /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/DAO.php:1566
  12  CRM_Core_DAO::executeQuery(' ALTER TAB…')   /home/ind/public_html/sites/all/modules/civicrm/CRM/Upgrade/Incremental/php/FiveThirtySeven.php:138
  13  CRM_Upgrade_Incremental_php_FiveThirtySeven::updateDBDefaultsForContributionRecur(Object(CRM_Queue_TaskContext))    /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/Task.php:74
  14  CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))  /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/Runner.php:201
  15  CRM_Queue_Runner->runNext(true) /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php:36
  16  CRM_Queue_Page_AJAX::{closure}()    /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/ErrorPolicy.php:89
  17  CRM_Queue_ErrorPolicy->call(Object(Closure))    /home/ind/public_html/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php:38
  18  CRM_Queue_Page_AJAX::runNext()  /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php:279
  19  CRM_Core_Invoke::runItem(Array) /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php:69
  20  CRM_Core_Invoke::_invoke(Array) /home/ind/public_html/sites/all/modules/civicrm/CRM/Core/Invoke.php:36
  21  CRM_Core_Invoke::invoke(Array)  /home/ind/public_html/sites/all/modules/civicrm/drupal/civicrm.module:458
  22  civicrm_invoke('upgrade', 'queue', 'ajax', 'runNext')   /home/ind/public_html/includes/menu.inc:527
  23  menu_execute_active_handler()   /home/ind/public_html/index.php:21
  24  {main}   
  
  Thanks
  Bill
  
  **Tags:** upgrade
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-06-22. Score: 1 | Accepted answer
  
  Looks like in your CiviCRM system, Pending contribution recur status(/civicrm/admin/options/contribution_recur_status?reset=1) is either disabled or deleted.
  Before upgrading CiviCRM can you
  
  Enable the Pending Contribution recur status.
  Add Pending Contribution recur status if doesn't exist.
  
  Note: You may not be allowed to enable the status from GUI, Try using api explorer or mysql to enable it.
  Update:
  Looks like in your system Contribution Recur status is missing, run below query to add contribution recur status in your system
  INSERT INTO `civicrm_option_group`  ( `name`, `title`, `is_active`, `is_reserved`, `is_locked` ) VALUES ('contribution_recur_status', 'Recurring Contribution Status', 1, 1, 1)
  ON DUPLICATE KEY UPDATE id=id;;
  
  SELECT @option_group_id_ps := MAX(id) FROM `civicrm_option_group` where name = 'contribution_recur_status';
  
  INSERT INTO `civicrm_option_value` (`option_group_id`, `label`, `value`, `name`, `weight`, `is_reserved`, `is_active`, `is_default`)
  SELECT @option_group_id_ps as option_group_id, `label`, value, ov.name, weight, ov.is_reserved, ov.is_active, is_default
  FROM civicrm_option_value ov
  INNER JOIN civicrm_option_group og
  ON og.id = ov.option_group_id AND og.name = 'contribution_status';
  
  SELECT @maxValue := MAX(CAST(value AS UNSIGNED))  FROM `civicrm_option_value` where option_group_id = @option_group_id_ps;
  SELECT @maxWeight := MAX(weight) FROM `civicrm_option_value` where option_group_id = @option_group_id_ps;
  
  INSERT INTO `civicrm_option_value` (
  `option_group_id`, `label`, `value`, `name`, `weight`, `is_reserved`, `is_active`, `is_default`
  )
  VALUES(
   @option_group_id_ps, 'Processing', @maxValue + 1, 'Processing', @maxWeight + 1, 1 , 1 , 0
  ),
  (
  @option_group_id_ps, 'Failing', @maxValue + 2, 'Failing', @maxWeight + 2, 1 , 1 , 0
  )
  ON DUPLICATE KEY UPDATE id=id;
  
  > **Comments:**
  > **username_0**: Pending is in the list and enabled. Should I try removing it and adding it back?  
  > **username_1**: Can you run the query and paste the output on you question?  ```SELECT cov.value, cov.label, cov.name, cov.is_active FROM civicrm_option_value cov   INNER JOIN civicrm_option_group cog     ON cog.id = cov.option_group_id       AND cog.name = 'contribution_recur_status';```  
  > **username_1**: I have updated my answer, it is contribution recur status (NOT Contribution status)  
  > **username_0**: Thats getting closer to the issue. Going to: /civicrm/admin/options/contribution_recur_status?reset=1 results in this error message: Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred. getFieldValue failed  
  
  ---
  
  