update-epidatabase failing with SqlException

Vote:
 

Hi,

We're trying to upgrade our project from CMS 8.11 and Commerce 8.16 to CMS/Commerce 9.4. We've downloaded the NuGet packages and been able to build the solution successfully.

However, when we run the 'update-epidatabase' cmdlet we get an error.

The cmdlet is able to process the sql scripts in the 'EPiServer.CMS.Core.9.4.0' folder, but in the 'EPiServer.Commerce.Core.9.4.0' folder it stops at the file '7.0.7.0.sql' and throws an SqlException:

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_OrderGroupNote_OrderGroup". The conflict occurred in database "", table "dbo.OrderGroup", column 'OrderGroupId'.

Does anyone have any idea what the problem is, or how we can debug it further? Setting the -Verbose flag to true on the cmdlet doesn't give us anything helpful.

Lars

#142397
Dec 10, 2015 13:59
Vote:
 

Hi,

We're aware of this issue and I can say it was my fault. Upcoming version will fix this, but right now you can open this file:packages\EPiServer.Commerce.Core.9.4.0\tools\epiupdates_commerce\sql\7.0.7.0.sql and edit this 

--Delete orphaned notes
DELETE n FROM dbo.OrderGroupNote n
LEFT JOIN dbo.OrderGroup g ON n.OrderGroupId = g.OrderGroupId
WHERE n.OrderGroupId IS NULL

GO

to be this

--Delete orphaned notes
DELETE n FROM dbo.OrderGroupNote n
LEFT JOIN dbo.OrderGroup g ON n.OrderGroupId = g.OrderGroupId
WHERE g.OrderGroupId IS NULL

GO

Save it and now update-epidatabase would work fine.

Apologies for your inconvenience. 

Regards,

/Q

#142440
Dec 10, 2015 17:31
Vote:
 

Thanks, that solved it!

We encountered a new issue thought, but there's already another forum thread for that: http://world.episerver.com/forum/developer-forum/EPiServer-Commerce/Thread-Container/2015/11/upgrade-mediachase_ecf50_mdp_key-error/

Lars

#142460
Dec 11, 2015 10:07
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.