Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

DB error on delete free shipping coupon

Vote:
 

Hey, 

We have a customer that has implemented unique coupon codes for optimizely. 

Inspiration for implementation: https://www.david-tec.com/2017/10/unique-vouchercoupon-codes-in-episerver-commerce-using-episerver-campaign/

Were we have experenced that we are getting an error from the SQL Server, if a customer is attempting to remove an added coupon. 

SQL error message: "The DELETE statement conflicted with the REFERENCE constraint \"FK_PromotionInformationShipment_PromotionInformationId\". The conflict occurred in database \"CBB.EpiServerCommerceDB\", table \"dbo.PromotionInformationShipment\", column 'PromotionInformationId'.\r\nThe statement has been terminated."

If i drop the foreign key and add it again with "ON DELETE CASCADE", it all works for me locally.

Is it an error that this table, doesn't already have cascade delete ? 

Versions:
EPiServer.CMS: 11.20.13
EPiServer.Commerce: 13.37.00



#336990
Feb 24, 2025 11:39
Vote:
 

Do you have the full stack trace? 

Yes FK_PromotionInformationShipment_PromotionInformationId should have ON DELETE CASCADE from the beginning 

#336997
Feb 25, 2025 10:44
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.