prisma-rename-migrations

Guides safe Prisma database renames with hand-written migrations, transactions, and data sweeps.

Updated Jan 12, 2026
One-click install
npx skills add https://github.com/brandonarbini/arbini.family --skill prisma-rename-migrations-brandonarbini
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: prisma-rename-migrations
Source: https://github.com/brandonarbini/arbini.family/tree/main/.agents/skills/prisma-rename-migrations
Command: npx skills add https://github.com/brandonarbini/arbini.family --skill prisma-rename-migrations-brandonarbini

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Renaming a table, column, or enum in Prisma is dangerous because prisma migrate dev renders renames as DROP plus CREATE, destroying production data while every test still passes. This Skill provides the operational discipline to perform renames without losing rows or leaving the schema half-migrated. ## Core Features & Use Cases - Hand-written rename migrations: Replace generated DROP/CREATE pairs with explicit ALTER ... RENAME statements wrapped in a single transaction. - Preflight validation: Add header queries with expected row counts to catch drifted constraint and index names before deploy. - Persisted-string sweeps: Write idempotent migrations that update old spellings stored in audit columns, JSON keys, and cached aggregates, with replay tests against old-shape rows. - Deploy-window handling: Re-run sweeps after promotion and choose between in-place rename and expand/contract based on traffic tolerance. - Use Case: You renamed a Prisma model from Proposal to Suggestion and migrate dev produced a DROP TABLE. Use this Skill to hand-write the rename migration, sweep persisted strings, and plan the deploy safely. ## Quick Start Ask the AI to help write a safe Prisma migration for renaming a table or column without losing existing production data.

Frequently Asked Questions about prisma-rename-migrations

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

FAQPage Schema
How do I rename a table in Prisma without losing data?▼

Hand-write the migration using ALTER TABLE ... RENAME TO instead of letting prisma migrate dev generate it, since Prisma renders renames as DROP plus CREATE which deletes all rows. Wrap the statements in an explicit BEGIN/COMMIT transaction and commit it with the schema change.

Why does prisma migrate dev generate DROP TABLE for a rename?▼

Prisma's migration engine does not detect renames; it sees the old table removed and a new one added, so it emits DROP and CREATE statements. This is schema-correct but destroys every row, so renames must be hand-written.

Does Prisma wrap migrations in a transaction?▼

No, Prisma does not wrap a migration file in a transaction. A failure mid-file leaves the database half-renamed with no rollback, so you must add explicit BEGIN and COMMIT statements around all rename statements yourself.

Why do old values still appear after a column rename migration?▼

RENAME only changes the schema, not data. Audit columns, event types, JSON keys, and cached aggregates still store the old spelling, so you need a separate idempotent sweep migration that updates rows still in the old shape.

When should I use expand/contract instead of an in-place rename?▼

Use expand/contract when the deploy window outage is unacceptable, since in-place renames break the old code the moment the migration commits. Expand/contract adds the new name, dual-writes, backfills, switches reads, then drops the old name across multiple deploys.