0

I have upgraded Magento from version 2.2.9 to 2.3.4 using the composer.

And run the setup: upgrade, then I am getting below error.

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (#sql-27b_17e, CONSTRAINT QUOTE_ITEM_PARENT_ITEM_ID_QUOTE_ITEM_ITEM_ID FOREIGN KEY (parent_item_id) REFERENCES quote_item (item_id) ON DELETE CASCADE), query was: ALTER TABLE quote_item MODIFY COLUMN item_id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT "Item ID", MODIFY COLUMN quote_id int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT "Quote ID", MODIFY COLUMN updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT "Updated At", MODIFY COLUMN product_id int(10) UNSIGNED NULL COMMENT "Product ID", MODIFY COLUMN store_id smallint(5) UNSIGNED NULL COMMENT "Store ID", MODIFY COLUMN parent_item_id int(10) UNSIGNED NULL COMMENT "Parent Item ID", MODIFY COLUMN discount_amount decimal(20, 4) NULL DEFAULT 0 COMMENT "Discount Amount", MODIFY COLUMN base_discount_amount decimal(20, 4) NULL DEFAULT 0 COMMENT "Base Discount Amount", MODIFY COLUMN tax_amount decimal(20, 4) NULL DEFAULT 0 COMMENT "Tax Amount", MODIFY COLUMN base_tax_amount decimal(20, 4) NULL DEFAULT 0 COMMENT "Base Tax Amount", MODIFY COLUMN row_total decimal(20, 4) NOT NULL DEFAULT 0 COMMENT "Row Total", MODIFY COLUMN base_row_total decimal(20, 4) NOT NULL DEFAULT 0 COMMENT "Base Row Total", MODIFY COLUMN row_total_with_discount decimal(20, 4) NULL DEFAULT 0 COMMENT "Row Total With Discount", MODIFY COLUMN base_tax_before_discount decimal(20, 4) NULL COMMENT "Base Tax Before Discount", MODIFY COLUMN tax_before_discount decimal(20, 4) NULL COMMENT "Tax Before Discount", MODIFY COLUMN price_incl_tax decimal(20, 4) NULL COMMENT "Price Incl Tax", MODIFY COLUMN base_price_incl_tax decimal(20, 4) NULL COMMENT "Base Price Incl Tax", MODIFY COLUMN row_total_incl_tax decimal(20, 4) NULL COMMENT "Row Total Incl Tax", MODIFY COLUMN base_row_total_incl_tax decimal(20, 4) NULL COMMENT "Base Row Total Incl Tax", MODIFY COLUMN discount_tax_compensation_amount decimal(20, 4) NULL COMMENT "Discount Tax Compensation Amount", MODIFY COLUMN base_discount_tax_compensation_amount decimal(20, 4) NULL COMMENT "Base Discount Tax Compensation Amount", MODIFY COLUMN gift_message_id int(11) NULL COMMENT "Gift Message ID", ADD CONSTRAINT QUOTE_ITEM_PARENT_ITEM_ID_QUOTE_ITEM_ITEM_ID FOREIGN KEY (parent_item_id) REFERENCES quote_item (item_id) ON DELETE CASCADE, ADD CONSTRAINT QUOTE_ITEM_QUOTE_ID_QUOTE_ENTITY_ID FOREIGN KEY (quote_id) REFERENCES quote (entity_id) ON DELETE CASCADE, ADD CONSTRAINT QUOTE_ITEM_STORE_ID_STORE_STORE_ID FOREIGN KEY (store_id) REFERENCES store (store_id) ON DELETE SET NULL

1
  • Surely as an Enterprise customer you can get support from Adobe? – paj Feb 6 '20 at 20:32
0

You need to run this query:

Select item_id from quote_item where parent_item_id is not null and parent_item_id in (select item_id from quote_item)

After that, the result will be updated and you need to fix it to parent_item_id = null.

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.