Does removing a schema delete its related documents in Sanity?

9 replies
Last updated: Jan 28, 2026
Hello. Sanity internal working question.
Does removing schema delete related documents?
AI Update

No, removing a schema in Sanity does not automatically delete related documents.

This is actually a deliberate design choice that Sanity considers a feature. When you remove or change a schema type in your Sanity Studio configuration, the existing documents in your Content Lake remain untouched. This helps prevent unintended data loss and gives you full control over how to handle existing content.

Why this matters

Sanity treats schema changes similar to how databases handle data model changes - they should be intentional, reproducible, and part of your development workflow. Your content model and your actual data are kept separate, so removing a document type from your schema won't cascade into deleting the actual documents.

What happens to "orphaned" documents

When you remove a schema type:

  • Documents with that _type still exist in your dataset
  • They just won't be accessible through Studio anymore (since there's no schema to render them)
  • They'll still show up in API queries
  • The sanity documents validate CLI command will report them as documents with a _type not covered in your schema configuration

How to handle documents after removing a schema

You have several options:

  1. Keep them - If you might need the data later, just leave them. They don't hurt anything.

  2. Delete them manually - Use the HTTP API or write a script to delete documents of that type.

  3. Migrate them - Use content migrations to transform them into a different document type or structure.

  4. Mark as deprecated - Before removing a schema, you can mark it as deprecated with a reason, which will show warnings in Studio but keep everything accessible.

This separation between schema and data gives you flexibility to evolve your content model without risking accidental data loss.

Show original thread
9 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?