fix: Add missing Shops.layout migration #4609
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #4608 (hopefully also #4585)
Impact: minor
Type: bugfix
Issue
Migration 33 was added in v1.15.0 to change the "products" template name to "Products". It neglected to do this in the Shops collection, which also has layouts stored there. Depending on whether you are upgrading, whether your Packages collection is regenerated on startup, and what version your database is already on, this sometimes leads to the app starting as just a white screen with no errors in the console.
This is actually pretty likely to happen in an upgrade situation.
Solution
Adds another migration, covering what the first migration missed.
Other changes
I also made a couple minor fixes to migration 13. This was something I encountered while debugging. If any carts or orders do not have a
shipping
field set, then settingshipping.0.shopId
in the migration actually creates ashipping
object rather than an array. This is a known quirk of MongoDB. So I added a filter to run the migration only for documents that already have an array there.Since this has only caused problems in a weird artificial situation I created, I opted to only fix the existing migration rather than write a new one.
Breaking changes
None
Testing
This is easiest to test if you already have a database that's causing this issue. Otherwise, you can fake it by manually creating the problem in your database and then verify the migration fixes it:
layout
array and find the item withworkflow = "coreWorkflow"
. Changestructure.template
of that item to "products" (lowercase first letter).