Menu - Content Migration
Contents
Overview
This tool allows markets and operators to migrate content from Staging (test) environment to Production (live) environment independently. Content consists of (but is not limited to) menu, offers, rewards and loyalty information that show up in the guest app.
As our platforms continue to scale internationally, demand for Sanity content migrations has increased and has put more pressure on the engineering side as this was previously a technical task.
This tool grants the following benefits:
Brand/region content teams are now able to create, test, and push their own data within Sanity.
Automatically pulls in all references documents and assets preventing failed data migrations due to missing children references.
More tactical than the current implementation wherein we need to move documents by type - meaning if we want to move a single offer, we currently need to move all offer documents and all possible child reference document types.
Time to move data is reduced tremendously. To move one static page to production or QA, it now takes 10 seconds, where it used to take up to 20 mins (depending on dataset size).
You need a write token in order to use this tool. Contact a Sanity admin to generate one for you and DO NOT SHARE THIS TOKEN.
Using the Document Action
Content creators are already accustomed to using document actions such as Publish or Delete. The document action works in a similar fashion to these actions:
Paste in your token…
Select destination dataset (always move QA first and validate before moving to production)…
Scroll down and click the migrate button, and wait for the migration to finish. Do not close this window!
When the migration is complete you will see a success message, if it errors, please reach out to @Posk, Mitchell (Deactivated) in the #sanity-data-migration-owners slack channel.
Using the Tool
The Migration tool allows you to migrate multiple documents using a GROQ query, as opposed to only moving the currently viewed document (both tools also move children references). In terms of functionality, the actual migration tool works the same as the document action.
If you are unfamiliar with GROQ queries, you can see some of the most used patterns here.
Example of Queries to use for specific circumstances:
MIGRATES WHOLE MENU BUT DOES NOT INCLUDE OFFERS (images do not go down):
*[_id in ["feature-menu-singleton"]][0..10000]
MIGRATES ALL OFFERS (images do not go down):
*[_id in ["feature-offers-singleton"]][0..10000]
MIGRATES ALL STATIC PAGES:
*[_type in ["staticPage"]][0..10000]
PUSHES WHAT WE SHOW ON THE HOMEPAGE
*[_id in ["feature-home-page-singleton"]][0..10000]
UPDATES ONLY MARKETING TILES:
*[_type in ["marketingTile", "marketingTileGroup"]][0..10000]
MIGRATING BY TYPE OF DOCUMENT
*[_type in ["item"]][0..10000] -this migrates all items (all documents with type item)
*[_type in ["offers"]][0..10000] -this migrates all offers (all documents with type offer)
You can use the above query to query all types available. These are just 2 examples.
NEW LOYALTY OFFERS MIGRATION
*[_id in ["feature-loyalty-offers-ui-singleton"]][0..10000] -this migrates all offers added to Loyalty Offers UI
*[_type in ["systemwideOffer"]][0..10000] -this migrates all systemwide offers
*[_type in ["configOffer"]][0..10000] -this migrates all config offers
*[_type in ["offerTemplate"]][0..10000] -this migrates all offer templates