Need guidance on removing a field from the schema in an app using Sanity.io
11 replies
Last updated: Feb 8, 2024
L
Hey all, I have an app that is already being used. There's a field in some of the documents and this field is being removed from our schema now. Is there anything I need to do when it comes to the data that had been added already? Could someone point me to a place in the docs where I can find more information about it? Thanks!
Feb 8, 2024, 3:41 PM
This should help!
Feb 8, 2024, 5:24 PM
L
That's really helpful! Thanks
user M
!Feb 8, 2024, 6:02 PM
L
I think I celebrated too early š . I just tested this on my end and it doesn't seem to show anything on a field at least:
Even thought it seems to prevent the user from typing, it still allows them to focus on the input and doesn't give any feedback, which doesn't seem to be a good user experience.
title: "Title2", name: "title2", type: "string", deprecated: { reason: 'Title2 not used anymore.' }, readOnly: true // to prevent further edits
Feb 8, 2024, 6:18 PM
L
3.24.1
Feb 8, 2024, 6:24 PM
L
Ah, got it. I'll keep that in mind then...I'll push for the field removal though, since it's something that is probably more aligned with what the client wants to. Thanks for the help š¤
Feb 8, 2024, 6:30 PM
If you go that route just repurpose this script.
Feb 8, 2024, 6:32 PM
L
How does that
I assume I should create a token somewhere to attach it? I'm logged in my organization via sso if it matters.
--with-user-tokenassociate with my account? I'm getting an insufficient permissions error:
responseBody: '{\n' + ' "error": {\n' + ' "description": "Mutation failed: Insufficient permissions; permission \\"update\\" required",\n' + ' "items": [\n' + ' {\n' + ' "error": {\n' + ' "description": "Insufficient permissions; permission \\"update\\" required",\n' + ' "permission": "update",\n' + ' "type": "insufficientPermissionsError"\n' + ' },\n' + ' "index": 0\n' + ' }\n' + ' ],\n' + ' "type": "mutationError"\n' + ' }\n' + '}',
Feb 8, 2024, 7:19 PM
L
I managed to fix that by creating a token in the environment and providing that token once I'm creating the client. That works. Thanks!
Feb 8, 2024, 9:24 PM
It could have been that you were logged into a different account in the CLI. Using different providers creates different accounts.
Feb 8, 2024, 10:45 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.