Skip to content

How to fix database migration issues

By Éric St-Pierre, 2023-01-22

This article is part of the How to fix serie.

Recently we encountered the need to add the Commerce Cloud functionality to an existing Content Cloud project.  The DXP instance got provisioned to add the Commerce database and I brought back a copy of the database from DXP to our local development environment.  I installed everything that was missing to our solution, and when I launched the Commerce Catalog admin interface, I got the following error:

```Bash
Failed loading content with the url/uri: 
epi.cms.contentdata:///-1073741823__CatalogContent
```

As I covered in a previous article, this error can be fixed by running a database migration to have the database match the version of the installed Commerce Cloud NuGet package.

I tried to run the migration steps and got an issue.

The first error was on an indexer queue step.  The migration was having an error because it could not find the indexer configuration.  Turns out that I had this issue because I misplaced the settings in the appsettings.json configuration file.  The Commerce configuration keys must be placed under the "Episerver" node.

I fixed my setting file and updated my Commerce package, but I was still getting errors.  What I was looking for ways to rerun the migration steps, to make sure that all the right settings were in place.  I was not able to rerun the steps because it always retained the steps that were already completed from my previous run which had the error.

I searched online to see how I could rerun the migration and found the following

https://world.optimizely.com/forum/developer-forum/CMS/Thread-Container/2020/11/testing-re-running--migration-steps/

This forum thread explained how to reset the migration steps to be able to restart it from the first step.  For that, you need to delete the MigrationStepInfo from the tblBigTable table in your CMS database.

```cs
DELETE
  FROM [EPI_CMS_DATABASE].[dbo].[tblBigTable]
  WHERE [StoreName] = 'EPiServer.Commerce.Internal.Migration.MigrationStepInfo'
```

In my case, I had some steps that were done when I was on 14.7.1 and some steps on 14.9.0 (once I fixed my appsettings.json).  So, I remove the steps from the tblBigTable CMS database and was able to run the migration without any issues.

https://localhost/:xxxxx/EPiServer/Commerce/Migrate/index?autoMigrate=true

So, this is how you can restart your migration steps if you encounter any issues.