Removing schema field - handling existing document data

11 replies
Last updated: Jan 28, 2026
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!
AI Update

Good question! When you remove a field from your Sanity schema, the existing data in documents that have that field will not be automatically deleted. This is actually a feature designed to prevent unintended data loss.

What happens to the existing data?

The data remains in your documents in the Content Lake. Sanity treats schema changes as non-destructive by default - changing your schema doesn't cascade changes to existing content. This helps prevent breakage for applications that might still rely on that data.

What you should consider doing:

  1. Mark the field as deprecated first (optional but recommended for production projects)

    You can use the deprecated property in your schema to mark fields that shouldn't be used anymore:

    defineField({
      name: 'oldFieldName',
      type: 'string',
      deprecated: {
        reason: 'This field is no longer used'
      },
      readOnly: true // prevents further edits
    })
  2. Decide if you need to clean up the data

    You have a few options:

  3. Run a migration to remove the data (if needed)

    If you want to actually remove the field data from existing documents, you can create a migration script using sanity migration create and use the unset() helper function.

Where to find more information:

The main documentation page you want is: Migrating your schema and content

Also helpful:

The short version: you're safe to remove the field from your schema without worrying about data loss. The old data will just sit there harmlessly unless you explicitly remove it with a migration.

Show original thread
11 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?