Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sanity.io, is any way to to change field type painlessly?

I have quite a lot documents in the sanity.io with completed fields. There is a need to change field type. And here are the problem:

enter image description here

Now I need to rewrite this field from old to the new and delete old field in each document. But it is expensive for me, I have a lot of documents. Is there any way to move data from one field to another once for all documents?

like image 439
kizoso Avatar asked Sep 13 '25 06:09

kizoso


1 Answers

this is a great question! There's currently no way to do this through the studio user interface, but it's possible to write a data migration script that does this. Please see the example here: https://www.sanity.io/docs/migrating-data#migrate-using-the-api

This example is for renaming a field, but I believe it should be possible to modify it for changing the type name as well.

like image 159
bjoerge Avatar answered Sep 15 '25 19:09

bjoerge