Search code examples
gatsbysanity

Old records still showing on Sanity


I have created a Sanity.io CMS, I have made some alterations to the schema after content had already been entered. The problem now is that the content is still saved somewhere inside the cms and I have no way to remove it.


Solution

  • There are several ways of deleting documents which are no longer visible in the Studio:

    • Make the Studio render the old documents, either by temporarily putting back the original schema, or defining a list using Structure Builder which will render the old docs
    • Write a script which queries for all documents by that type, and have the script delete them
    • Use the Sanity CLI to query for and later delete the documents, e.g. sanity documents query '*[_type == "unwantedType"]._id' and then sanity documents delete [list-of-unwanted-doc-ids]