5.0.0 Migration

Hi Sebastian,

In the changelog, under version 5.0.0, the section about Migration:

5.0.0 - 2020-10-08

This feature adds custom IDs to the system. So far every ID like a content ID is globally unique. This means that you cannot create custom IDs and when a backup is restored you need to assign new ids, because the old IDs might be already in use.

With this version on, every ID is prefixed with the app id, meaning they are only unique within an app. This allows new endpoints for upserting contents and defininig custom ids for assets.

WARNING: MIGRATION

This version has to migrate a few mongo collections:

  • Events
  • States_AssetFolders
  • States_Assets
  • State_Contents_All
  • State_Contents_Published

This process will start automatically and can take a while. To be backwards compatible when you experience a bug, new collections are created. The new collection names are

  • Events2
  • States_AssetFolders2
  • States_Assets2
  • States_Contents_All2
  • States_Contents_Published2

(As you can see the collection names have been streamlined.)

If everything works fine for you, you can delete the old collections.

This last sentence is a bit ambigous to me.

Can you please clarify which collections I should delete?

1 Like

The old collections are:

  • Events
  • States_AssetFolders
  • States_Assets
  • State_Contents_All
  • State_Contents_Published
1 Like

Hi Sebastian,

Is there a way I can tell if the migration is done and has completed successfully apart from checking your apps and your content by doing a sanity test or some more extensive testing? Is there something in some logs perhaps?

What I can see here in my environment is that the site looks okay, Squidex admin UI looks and behaves ok, and the mongodb has the v2 collections. My latest squidex upgrade 5.5.0 has been running for 2 hours as we speak. The migration should be done by now or should I wait a while longer before deleting the old collections? I don’t want to mess anything up.

I also found some other collections that look like duplicates:

Old?:

  • States_RestoreState
  • Usages

New?:

  • States_RestoreState2
  • UsagesV2

Can I delete these as well?

Yes, but they are older.

1 Like

Thanks, did you see my previous reply?

Hi, the migration is running before the web server starts, so when you can reach your apps the migration should be done. You can also compare the collections to be sure.

So I ran these commands to drop the old collections and everything seems okay.

Update: Added State_Contents

db.Events.drop()
db.States_AssetFolders.drop()
db.States_Assets.drop()
db.State_Contents.drop()
db.State_Contents_All.drop()
db.State_Contents_Published.drop()
db.States_RestoreState.drop()
db.Usages.drop()

My db now looks like this:

mongodb:PRIMARY> show dbs
Squidex         0.570GB
SquidexAssets   1.309GB
SquidexContent  0.008GB
admin           0.000GB
config          0.000GB
local           0.549GB

mongodb:PRIMARY> use Squidex
switched to db Squidex
mongodb:PRIMARY> show collections
Events2
Identity_PersistedGrants
Identity_Roles
Identity_Users
Identity_XmlRepository
Key
Migration
Orleans_OrleansMembershipV2
Orleans_OrleansReminderV2
Projections_AssetStats
Projections_History
RequestLog
RuleEvents
RuleStatistics
States_Apps
States_AssetFolders2
States_Assets2
States_BackupState
States_EventConsumerState
States_Identity_Keys
States_Identity_Xml
States_Index_AppsByName
States_Index_AppsByUser
States_Index_RulesByApp
States_Index_SchemasByApp
States_Index_Tags
States_Repository
States_RestoreState2
States_UISettings
States_UsageTracker
States_XmlRepository
TextIndex
TextIndexerState
UsagesV2
fullText.chunks
fullText.files

mongodb:PRIMARY> use SquidexAssets
switched to db SquidexAssets
mongodb:PRIMARY> show collections
fs.chunks
fs.files

mongodb:PRIMARY> use SquidexContent
switched to db SquidexContent
mongodb:PRIMARY> show collections
State_Contents
States_Contents_All2
States_Contents_Published2

I also compared my current db schema (dbs and collections) to the default one created by Squidex 5.5.0:

mongodb:PRIMARY> show collections
Events2
Identity_PersistedGrants
Identity_Roles
Identity_Users
Migration
Orleans_OrleansReminderV2
Projections_History
RequestLog
RuleEvents
RuleStatistics
States_AssetFolders2
States_Assets2
States_EventConsumerState
States_Identity_Keys
States_Identity_Xml
States_Index_AppsByName
States_UsageTracker
TextIndex
UsagesV2

mongodb:PRIMARY> use SquidexContent
switched to db SquidexContent
mongodb:PRIMARY> show collections
States_Contents_All2
States_Contents_Published2

SquidexAssets db is not yet created for obvious reasons, no images have been uploaded yet.

From what I can see there are some differences. I believe the States_Index_XYZ get created as you start using some features in Squidex so these are okay and are supposed to be there. But the rest I’m kind of unsure about.

Sebastian, I would really appreciate it if you could help me spot any additional old collection(s) that I can delete if there are any?

Also, what about State_Contents, it looks suspicious to me? :slight_smile:

Yes, State_Contents is old as well, but the rest looks fine. As long as you do not delete the events, everything is fine because most other collection can be derived from that.

You mean the collection called Events2 ?

Yes, exactly. Squidex uses event sourcing. Everything that happens in the system is recorded as an event, therefore this is the only relevant collection.

Okay, got it, thanks!

I noticed the history for all of my content for all of my apps was missing after I deleted the old collections but then I ran the history event reset feature and the history started coming back online.

I guess it must have been stored or had some references to some of the older collections that I deleted?

And then when I ran the history reset event function Squidex replayed all those history events to recreate my content history?

Yes, exactly. The ids have been changed therefore the history items could not been assigned.

Ah, I see! It’s okay to close this thread now btw. Thanks a ton for all the help!!