Upgrading from Sanity V1 to V3 without losing data
13 replies
Last updated: Feb 17, 2023
A
Hi - I two environments that appear to be quite dated and require updating. Upon running which 404's.
With research, I see that sanity is now on V3. The 2 sites really aren't that old so I'm a little shocked at how outdated they already are.
After a bit of googling, I can find details on how to upgrade from V2 to V3, but nothing mentioning V1.
Does anyone know if its possible to go from V1 to V3 without losing any data in the datasets and what changes I would have to make around the schema (is the documentation for V2->V3 still relevant to me)?
sanity upgrade, none of the packages update and I'm given a URL of
<https://www.sanity.io/changelog/studio?from=v1&to=v2>
With research, I see that sanity is now on V3. The 2 sites really aren't that old so I'm a little shocked at how outdated they already are.
After a bit of googling, I can find details on how to upgrade from V2 to V3, but nothing mentioning V1.
Does anyone know if its possible to go from V1 to V3 without losing any data in the datasets and what changes I would have to make around the schema (is the documentation for V2->V3 still relevant to me)?
Feb 16, 2023, 11:12 AM
If you’re still on V1, it sounds like it’s been at least 2 years since your projects were created! V1-V2 is the easiest of the two upgrades. I don’t believe there are any breaking changes between the two. You can go directly to V3 if you follow the migration guides.
You should note that any Studio migrations would have no effect on your data. Datasets exist separately from the Studio UI.
You should note that any Studio migrations would have no effect on your data. Datasets exist separately from the Studio UI.
Feb 16, 2023, 6:41 PM
A
Thanks for the reply
Is there any point or make it any easier to upgrade to V2 first, or makes no difference?
user M
- so the studio changes for V3 still follow the same dataset structure, just achieved a different way via the code base is what I’m hearing - is that fair to say?Is there any point or make it any easier to upgrade to V2 first, or makes no difference?
Feb 16, 2023, 7:32 PM
You’re exactly right! Going to V2 wouldn’t actually require any schema or config changes, if I recall correctly, so it won’t make the migration any easier doing that first. If you’re not in a place where you can do the full migration to V3, you could get away with upgrading to V2 then circling back for the final migration before the end of the year.
Feb 16, 2023, 7:39 PM
A
Ok great - and the migration is mainly just including the schema differently in the project, from what I gather (different file structure, includes, etc)?
Feb 16, 2023, 8:22 PM
If you don’t have any custom input components, you can basically init a new Studio, then just copy over your schema files and add your old project id and dataset names into
sanity.config.jsand
sanity.cli.js. It’ll take you about 10 mins! The time consuming parts are the custom input components and plugins.
Feb 16, 2023, 8:25 PM
A
Oh - interesting! I’ll have to revisit and review the projects in question as to whether I have custom inputs… I have a feeling I don’t so that’s very good to know.
I’ll give this a go and see what happens. Thanks so much for your help and info provided!
I’ll give this a go and see what happens. Thanks so much for your help and info provided!
Feb 16, 2023, 8:44 PM
A
So, I'm following the step by step guide on the site, and on the first run attempt, I'm getting errors from RXJS that modules
tap,
switchMapand
concatMapare not found.
Feb 17, 2023, 1:09 PM
A
I see its been a bit of a running theme from a quick search here in slack. I've attempted the ol' "delete node_modules and reinstall", no luck unfortunately
Feb 17, 2023, 1:13 PM
A
Tried the downgrade stated on this thread and it got me a little further, instead got this:
Feb 17, 2023, 1:20 PM
A
attempted a clean node_modules folder again, still no good.I've carried out the remainder of the guide as well. Seems I've hit a roadblock?
Feb 17, 2023, 1:37 PM
A
Strangely, ran
Though, I just reread your messages and you stated to init a new project
🤦 so i'll transfer over the files I created and see how I go.
sanity initin a new folder, which installed V3, and it worked. I noticed that it ran
npm install --legacy-peer-depsso I removed the node_modules from my original folder and tried that - still no good.
Though, I just reread your messages and you stated to init a new project
🤦 so i'll transfer over the files I created and see how I go.
Feb 17, 2023, 1:47 PM
A
Stuffed if I know what the issue was in trying to migrate from the existing project, but seems to have worked completely fine from a fresh one and bringing everything over.
Apologies for the string of messages - if anything, hopefully it has something in here that you may not have already been aware of.
Thanks again for your help!
Apologies for the string of messages - if anything, hopefully it has something in here that you may not have already been aware of.
Thanks again for your help!
Feb 17, 2023, 1:53 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.