Prisma migrate safe

From ksmaster03/claude-canfly-skill · View interactive version

Prisma migrate safe is an AI agent skill from the GitHub repository ksmaster03/claude-canfly-skill. Change a Prisma schema and produce a migration safely — review the generated SQL, guard against destructive data loss, and ensure the migration is git-tracked so it actually ships. For any Prisma project. Trigger when the user types /prisma-migrate-safe or asks to "change the schema / add a column /

How to use this skill

Skill file

/prisma-migrate-safe — schema change that won't blow up prod

Prisma migrations have one infamous failure mode: an un-git-added migration.sql never reaches the prod box, and prisma migrate deploy silently no-ops it. This skill prevents that and the destructive-change traps.

Locate

Procedure

  1. Edit schema.prisma — make the model change. Match existing field naming, relations, and @map/@@map conventions already in the file.
  2. Generate the migration from the dir holding prisma/:

npx prisma migrate dev --name <verb_noun> (e.g. add_status_to_asset).

  1. READ the generated migration.sql before trusting it. Confirm it does what you intended and nothing more.
  2. Destructive-change gate 🔴 — if the SQL contains DROP COLUMN, DROP TABLE, a type change that truncates, or a new NOT NULL column without a default on a populated table: STOP. Surface it, propose a safe path (add nullable → backfill → enforce), and get the user's OK before continuing.
  3. git add prisma/migrations/ — the new folder + migration.sql MUST be staged. This is the #1 reason a migration "didn't run" in prod.
  4. Regenerate client if needed: npx prisma generate. Typecheck: npx tsc --noEmit.
  5. Prod: do NOT run migrate against prod by hand. Let it ship through your normal deploy path (prisma migrate deploy runs on the box).

Output

Report: schema diff summary, the migration name, the SQL verdict (safe / destructive-needs-plan), and confirmation that migrations are git-tracked.

Hard rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.