migration-safety

migration-safety is a cursor rule for Cursor from nedcodes-ok/cursorrules-collection. It costs 592 tokens per session, scanned A, original, MIT.

A set of rules for changing database structure safely through versioned migration files. It covers rollback steps and staged changes that avoid taking a service offline.

In plain words
What is it for?
Use it to add or change tables and columns, plan backward-compatible deployments, test rollbacks, and handle indexes or renames safely.
Why use it?
It reduces the chance that a schema change will break running application versions or leave the database difficult to restore.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions Cursor.

Good fit Use it to add or change tables and columns, plan backward-compatible deployments, test rollbacks, and handle indexes or renames safely.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/migration-safety
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for migration-safety

README.md
[![agentmods](https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/migration-safety.svg)](https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/migration-safety)
Your own site
<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/migration-safety"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/migration-safety.svg" alt="Measured on agentmods" height="20"></a>
Per session 592 This file is loaded in full into every session.
When invoked 592 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00592 $0.00592
Opus 5 $0.00296 $0.00296
Sonnet 5 $0.00118 $0.00118
Haiku 4.5 $0.00059 $0.00059

Measured 4d ago against content hash 30b32d4920a6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

migration-safety scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules-mdc/practices/migration-safety.mdc · 58 lines

How it starts

The opening of the file, as written. The whole thing — 58 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Migration Safety Cursor Rules

You are an expert in safe database migration practices. Follow these rules:

Migration Structure

  • One migration per file, sequentially numbered or timestamped
  • Every migration has an up AND a down — no exceptions
  • Test the down migration before deploying the up
  • Migration files are immutable once applied — never edit, only append new migrations
  • Include a description comment at the top of each migration file

Backward-Compatible Changes (Safe to Deploy)

  • Adding a new table
  • Adding a nullable column (existing code ignores it)
  • Adding an index (CREATE INDEX CONCURRENTLY in PostgreSQL)
  • Adding a new enum value (if DB supports it without rewrite)
  • Widening a column type (int → bigint, varchar(50) → varchar(100))

Breaking Changes (Require Multi-Step)

  • Renaming a column: add new → backfill → deploy code using new → drop old
  • Removing a column: deploy code that ignores it → then drop in next migration
  • Changing column type: add new column → backfill → switch code → drop old
  • Renaming a table: same pattern as column rename
  • Never rename + drop in the same deploy as the code change

Zero-Downtime Pattern

  1. Migration adds new structure (column, table) — backward compatible
  2. Deploy code that writes to both old and new
  3. Backfill existing data from old to new
  4. Deploy code that reads from new only
  5. Migration removes old structure
  • Each step is a separate deploy. Never combine steps.

Rollback Plans

  • Before running any migration, verify you can roll back: run down migration on staging
  • For data migrations: backup the affected tables/rows before modifying
  • If a migration is irreversible (data deletion), flag it clearly and require manual approval
  • Keep the previous application version deployable for at least 1 hour post-migration

Anti-Patterns — Do NOT

  • ❌ Running ALTER TABLE on large tables without CONCURRENTLY (locks the table)
  • ❌ Adding a NOT NULL column without a DEFAULT (fails on existing rows)
  • ❌ Deploying code + migration atomically — if the migration fails, the code is broken
  • ❌ Using ORM auto-migration in production (Prisma db push, Django migrate without review)
  • ❌ Deleting migration files from the history — they're your audit trail
  • ❌ Running migrations during peak traffic

Read the full file on GitHub · 58 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 58 lines · 592 tokens per session scan A 30b32d4920a6

Subscribe to this mod's changes

migration-safety is a cursor rule published in the GitHub repository nedcodes-ok/cursorrules-collection (37 stars, last pushed 6mo ago), licensed MIT. It adds 592 tokens to every session, about $0.0030 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.