How to configure dev environment to fetch data from local dataset and migrate data to production dataset.
Last updated: Oct 29, 2021
Two newbie questions in one go:1/ How do I tell my dev environment I want to fetch data from my localhost studio instead of the deployed studio. 2/ How would I go about migrating data from my local studio to the deployed version.
Appreciating the help here very much :)
Oct 29, 2021, 10:04 AM
Hi Nicolas. One thing to distinguish is between studio code and datasets. Your studio code is what gets installed with
and deployed with
followed by outputting the files to a hosting environment). This studio is the structure where your content lake is displayed and manipulated, but which studio you use (local or deployed) has no impact on your data in the content lake. It is the vehicle rather than the passengers. What I think you’re asking is more about a distinction between datasets. More specifically, your project can have multiple datasets with separate content (though, as you hinted at, they can be synchronized). Some people might have separate staging and production datasets, or development and staging datasets. These datasets house your content lake and they are what you specify when you’re sourcing your data. They’re the passengers that will sit in your studio “vehicle”.
If that’s indeed the case, then question 1 might be “how do I tell my dev environment I want to fetch data from my development dataset instead of the production dataset?” There are a few ways to do this, with one being configuring your sanity.json file to select a dataset based on your environment. You can use environment variables to override your environment (so, for example, you could test your sanity.json file is set up correctly by running
SANITY_ACTIVE_ENV=production sanity start
, which should run your production dataset locally). For question 2, the question that follows may be “how would I migrate my data from a development dataset to a production dataset?” If that’s the case, there are a few different ways, with some exclusive to enterprise plans. However, on every plan there is the option to export (i.e., from dev) and import (i.e., to production). Details of that are here . If I’ve misunderstood your questions or you have additional ones, please let me know!