Skip to content

Error Unique constraint violation found Checkout as Guest

After migrating the e-commerce server, at the time of payment the payment is made correctly, but as a response I get “Unique constraint violation found”, at the time of migration I got SQL errors:

#1
 ALTER TABLE `mg_quote_item` 
 MODIFY COLUMN `item_id` int(10) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT "Item ID", 
 ADD CONSTRAINT  PRIMARY KEY (`item_id`), 
 ADD CONSTRAINT `MG_QUOTE_ITEM_PARENT_ITEM_ID_MG_QUOTE_ITEM_ITEM_ID` FOREIGN KEY (`parent_item_id`) REFERENCES `mg_quote_item` (`item_id`)  ON DELETE CASCADE, 
 ADD CONSTRAINT `MG_QUOTE_ITEM_QUOTE_ID_MG_QUOTE_ENTITY_ID` FOREIGN KEY (`quote_id`) REFERENCES `mg_quote` (`entity_id`)  ON DELETE CASCADE, 
 ADD CONSTRAINT `MG_QUOTE_ITEM_STORE_ID_MG_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `mg_store` (`store_id`)  ON DELETE SET NULL, 
 ADD INDEX `MG_QUOTE_ITEM_PARENT_ITEM_ID` (`parent_item_id`), 
 ADD INDEX `MG_QUOTE_ITEM_PRODUCT_ID` (`product_id`), 
 ADD INDEX `MG_QUOTE_ITEM_QUOTE_ID` (`quote_id`), 
 ADD INDEX `MG_QUOTE_ITEM_STORE_ID` (`store_id`);
 #2
 ALTER TABLE `mg_quote_address_item` 
 MODIFY COLUMN `address_item_id` int(10) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT "Address Item ID", 
 ADD CONSTRAINT  PRIMARY KEY (`address_item_id`), 
 ADD CONSTRAINT `MG_QUOTE_ADDR_ITEM_QUOTE_ADDR_ID_MG_QUOTE_ADDR_ADDR_ID` FOREIGN KEY (`quote_address_id`) REFERENCES `mg_quote_address` (`address_id`)  ON DELETE CASCADE, 
 ADD CONSTRAINT `FK_3746D5963D7C5E849D00C50B04D014B8` FOREIGN KEY (`parent_item_id`) REFERENCES `mg_quote_address_item` (`address_item_id`)  ON DELETE CASCADE, 
 ADD CONSTRAINT `MG_QUOTE_ADDRESS_ITEM_QUOTE_ITEM_ID_MG_QUOTE_ITEM_ITEM_ID` FOREIGN KEY (`quote_item_id`) REFERENCES `mg_quote_item` (`item_id`)  ON DELETE CASCADE, 
 ADD INDEX `MG_QUOTE_ADDRESS_ITEM_QUOTE_ADDRESS_ID` (`quote_address_id`), 
 ADD INDEX `MG_QUOTE_ADDRESS_ITEM_PARENT_ITEM_ID` (`parent_item_id`), 
 ADD INDEX `MG_QUOTE_ADDRESS_ITEM_QUOTE_ITEM_ID` (`quote_item_id`),
 ADD INDEX `MG_QUOTE_ADDRESS_ITEM_STORE_ID` (`store_id`);
 #3
ALTER TABLE `mg_sales_payment_transaction` 
MODIFY COLUMN `transaction_id` int(10) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT "Transaction ID", 
ADD CONSTRAINT  PRIMARY KEY (`transaction_id`), 
ADD CONSTRAINT `MG_SALES_PAYMENT_TRANSACTION_ORDER_ID_MG_SALES_ORDER_ENTITY_ID` FOREIGN KEY (`order_id`) REFERENCES `mg_sales_order` (`entity_id`)  ON DELETE CASCADE, 
ADD CONSTRAINT `FK_DBC36626E185E30AB299A4F902A37036` FOREIGN KEY (`parent_id`) REFERENCES `mg_sales_payment_transaction` (`transaction_id`)  ON DELETE CASCADE, 
ADD CONSTRAINT `FK_8865038664B8790BA5CF44F85D464B11` FOREIGN KEY (`payment_id`) REFERENCES `mg_sales_order_payment` (`entity_id`)  ON DELETE CASCADE, 
ADD CONSTRAINT `MG_SALES_PAYMENT_TRANSACTION_ORDER_ID_PAYMENT_ID_TXN_ID` UNIQUE KEY (`order_id`,`payment_id`,`txn_id`),
ADD INDEX `MG_SALES_PAYMENT_TRANSACTION_PARENT_ID` (`parent_id`), 
ADD INDEX `MG_SALES_PAYMENT_TRANSACTION_PAYMENT_ID` (`payment_id`);

and I had to run the queries to be able to compile the project.

What I have found is that in the request {site}/rest/default/V1/carts/mine/payment-information always the cartdId is 2757
request after chekout

last record in the table

table structure

is something missing?

I use Magento 2.3.4