database-migration-safety

Plans and verifies idempotent database migrations for safe schema evolution on live data.

Updated Dec 24, 2025
One-click install
npx skills add https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1 --skill database-migration-safety-joyjoin-tech-limited
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: database-migration-safety
Source: https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1/tree/main/.github/skills/database-migration-safety
Command: npx skills add https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1 --skill database-migration-safety-joyjoin-tech-limited

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Schema changes on live databases risk data loss, broken constraints, and application outages when handled with blind schema pushes. This Skill provides a disciplined workflow for classifying changes, writing idempotent migration scripts, and verifying pre- and post-conditions so migrations converge safely. ## Core Features & Use Cases - Change Classification: Distinguishes additive changes (safe for db:push) from renames, backfills, and constraint tightening that require explicit migrations. - Idempotent Migration Design: Enforces DATABASE_URL guards, table/column existence checks, and re-run safety so scripts converge on the same final state. - Verification & Rollback Planning: Requires explicit precondition and postcondition checks, compatibility windows, and documented abort conditions. - Use Case: When renaming role columns to archetype columns on a production PostgreSQL database, use this Skill to inspect the live schema via Postgres MCP, write an expand-verify-contract migration, and confirm no old columns remain. ## Quick Start Ask the assistant to plan a safe migration for renaming a column or adding a uniqueness constraint on a table that already contains production data.

Frequently Asked Questions about database-migration-safety

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

FAQPage Schema
How do I safely rename a column in a production database?▼

Renaming a column on live data requires an explicit migration, not db:push. Inspect the live schema first, write an idempotent script that renames the shape, then verify no old columns remain and confirm application code no longer references the old name.

When should I use db:push vs an explicit migration?▼

Use db:push only for additive schema-only changes with no data transformation. Use an explicit migration when renaming fields, backfilling data, fixing duplicates, tightening constraints, or changing a contract that existing rows already violate.

How do I add a UNIQUE constraint when duplicate rows already exist?▼

Count duplicates first, then remove or consolidate them deterministically before adding the constraint. After the migration, verify the constraint exists and re-check that no duplicates remain, failing loudly if postconditions are not met.

What makes a database migration script idempotent?▼

An idempotent migration uses existence checks such as IF EXISTS or IF NOT EXISTS, verifies preconditions before modifying anything, and converges to the same final state on re-runs. It also guards with DATABASE_URL and skips safely on fresh databases.

Why does my migration succeed but the application still breaks?▼

The compatibility window was likely ignored. The schema changed safely while application code still assumes the old contract, so use an expand-verify-contract rollout where old code survives intermediate schema states before contracting.