Updated Schema Field Name - How to Delete Property with the Old Name

2 replies
Last updated: May 17, 2020
Hello! I updated a field name on my schema and saved a record to that field for a saved document so now I have properties for both the old and newly named field in that document. Is there a way to delete the property with the old name or would I have to delete the whole document? Thanks!
May 17, 2020, 2:07 AM
Never mind I just found the alert in Sanity studio that says "Found 1 unknown fields" where it allows you to unset it!
May 17, 2020, 2:24 AM
Exactly! Glad you found it 🙂
In case you run into this issue for a large number of documents in the future, there is another approach using a script instead. It’s slightly more technical but can prevent you from having to edit a large number of documents. I’ll just leave it here in case you ever need it:
https://github.com/sanity-io/sanity-recipes/blob/master/snippets/renameField.js
May 17, 2020, 9:11 AM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in