sanity-migration-helper

Create, validate, and run Sanity CMS data migrations with dry-run and rollback.

2|Updated Apr 9, 2025
One-click install
npx skills add https://github.com/PP-Namias/Portfolio --skill sanity-migration-helper
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sanity-migration-helper
Source: https://github.com/PP-Namias/Portfolio/tree/main/.agents/skills/sanity-migration-helper
Command: npx skills add https://github.com/PP-Namias/Portfolio --skill sanity-migration-helper

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill streamlines the process of writing, validating, and running data migrations in Sanity, ensuring smooth and secure updates to your database.

Core Features & Use Cases

  • Migration Management: Create, validate, and execute migrations for your Sanity database.
  • Dry-Run & Rollback: Preview changes before applying them and undo migrations if needed.
  • Idempotent Migrations: Run migrations multiple times without causing issues.
  • Logging & Validation: Detailed logs and pre-execution validation to catch errors early.
  • Use Case: If you need to add a new field to all project documents in your Sanity instance, this Skill will help you automate the process, validate it, and run it safely.

Quick Start

Run the migration to add a new field to all projects with the command: node scripts/sanity-migration-helper.mjs run add-new-field.

Frequently Asked Questions about sanity-migration-helper

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely add a new field to all documents in Sanity CMS?

Adding a new field to all Sanity documents requires a data migration script that automates the update, validates the changes beforehand, and safely applies the modification to your database.

Can I preview changes before running a Sanity data migration?

You can preview changes before applying a Sanity data migration by utilizing the dry-run feature, allowing you to validate updates and catch potential errors before executing them on your database.

Do I need Node.js and Sanity CLI to execute database migrations?

You need both Node.js and the Sanity CLI installed to execute database migration scripts, because the process relies on running JavaScript modules locally to manage and validate your data updates.

What is an idempotent migration in Sanity and why does it matter?

An idempotent migration in Sanity is a database update script designed to run multiple times without causing errors or duplicate modifications, ensuring your data remains consistent even if execution fails and is retried.

How do I undo a data migration in Sanity CMS if something goes wrong?

To undo a data migration in Sanity CMS, you utilize the rollback feature to revert your database structure to its previous state, ensuring safe recovery from problematic updates or unexpected validation failures.

Are there limitations to automating Sanity database updates with scripts?

Limitations of automating Sanity database updates include strict dependencies on Node.js and Sanity CLI, the necessity of pre-execution validation to prevent errors, and the requirement for idempotent script design to support safe repeated executions.