Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Critical
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.3.0
-
Fix Version/s: 4.3.0
-
Component/s: Accounting Integration
-
Labels:
Description
Currently we are trying to add financial_type_id column NOT NULL to civicrm_payment_processor table with FK to civicrm_financial_type.id. If the DB being upgraded has one or more existing rows in civicrm_payment_processor table - you will get this FATAL error:
ALTER TABLE `civicrm_payment_processor` ADD CONSTRAINT `FK_civicrm_payment_processor_financial_type_id` FOREIGN KEY (`financial_type_id`) REFERENCES `civicrm_financial_type` (`id`) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm_42`., CONSTRAINT `FK_civicrm_payment_processor_financial_type_id` FOREIGN KEY (`financial_type_id`) REFERENCES `civicrm_financial_typ)]
DebugInfo
The upgrade script needs to insert reasonable defaults for financial types to be used in payment_processor table as well as the other tables where financial_type_is column is being added. Then all can be set to NOT NULL via a second ALTER TABLE command.
I've temporarily fixed this by changing column definition for civicrm_payment_processor.financial_type_id to DEFAULT NULL.