cancel
Showing results for 
Search instead for 
Did you mean: 

bin/magento setup:upgrade shows General error: 1823 Failed to add the foreign key constraint

Highlighted

bin/magento setup:upgrade shows General error: 1823 Failed to add the foreign key constraint

Hi,

I've copied historical sales/order data tables from CE 2.3.3 to a fresh installation of CE 2.3.4 database. Namely the following tables of the data tables. This made historical sales/order data available in new magento admin area. Now whenever I run bin/magento setup:upgrade command in CLI the following is displayed:

Schema creation/updates:
SQLSTATE[HY000]: General error: 1823 Failed to add the foreign key constraint 'database_name/QUOTE_STORE_ID_STORE_STORE_ID' to system tables, query was: ALTER TABLE `quote` MODIFY COLUMN `store_id` smallint(5) UNSIGNED NOT NULL DEFAULT 0 COMMENT "Store ID", MODIFY COLUMN `orig_order_id` int(10) UNSIGNED NULL DEFAULT 0 COMMENT "Orig Order ID", MODIFY COLUMN `customer_id` int(10) UNSIGNED NULL COMMENT "Customer ID", MODIFY COLUMN `customer_tax_class_id` int(10) UNSIGNED NULL COMMENT "Customer Tax Class ID", MODIFY COLUMN `customer_group_id` int(10) UNSIGNED NULL DEFAULT 0 COMMENT "Customer Group ID", MODIFY COLUMN `reserved_order_id` varchar(64) NULL COMMENT "Reserved Order ID", MODIFY COLUMN `gift_message_id` int(11) NULL COMMENT "Gift Message ID", ADD CONSTRAINT `QUOTE_STORE_ID_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `store` (`store_id`) ON DELETE CASCADE

 

sales_bestsellers_aggregated_daily
sales_bestsellers_aggregated_monthly
sales_bestsellers_aggregated_yearly
sales_creditmemo
sales_creditmemo_comment
sales_creditmemo_grid
sales_creditmemo_item
sales_invoice
sales_invoiced_aggregated
sales_invoiced_aggregated_order
sales_invoice_comment
sales_invoice_grid
sales_invoice_item
sales_order
sales_order_address
sales_order_aggregated_created
sales_order_aggregated_updated
sales_order_grid
sales_order_item
sales_order_payment
sales_order_status_history
sales_order_tax
sales_order_tax_item
sales_payment_transaction
sales_refunded_aggregated
sales_refunded_aggregated_order
sales_shipment
sales_shipment_comment
sales_shipment_grid
sales_shipment_item
sales_shipment_track
sales_shipping_aggregated
sales_shipping_aggregated_order
quote
quote_address
quote_address_item
quote_id_mask
quote_item
quote_item_option
quote_payment
quote_shipping_ratesequence_invoice_1sequence_order_1sequence_shipment_1sequence_creditmemo_1

 

Should I worry about this or is there anything that should be done to avoid this.

 

Thank you in advance.

2 REPLIES 2
Highlighted

Re: bin/magento setup:upgrade shows General error: 1823 Failed to add the foreign key constraint

Hello @cham_tale,

 

You can copy or move database tables to another version as you describe.

 

You must upgrade your Magento version with old version database.

 

Thank you

Hiren Patel

 

-----

Problem solved - Click on Kudos and Accept as Solution .

Highlighted

Re: bin/magento setup:upgrade shows General error: 1823 Failed to add the foreign key constraint

You should run this command: 

update quote set store_id = 0 where store_id not in (select store_id from store)

Please let me know if it works or give me a Like, Accept as a Solution!