migration-rules

migration-rules is a cursor rule for Cursor from girijashankarj/cursor-handbook. It costs 0 tokens per session (459 once invoked), scanned A, original, MIT.

A set of rules for changing a database structure safely through migrations, which are versioned steps that add or alter tables and columns.

In plain words
What is it for?
Use it when creating or reviewing database migrations, checking compatibility, adding indexes, changing columns, and planning production rollouts.
Why use it?
It helps avoid data loss, broken application code, and downtime when database changes are deployed.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when creating or reviewing database migrations, checking compatibility, adding indexes, changing columns, and planning production rollouts.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/girijashankarj/cursor-handbook/migration-rules
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/girijashankarj/cursor-handbook

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-rules

README.md
[![agentmods](https://agentmods.dev/badge/rules/girijashankarj/cursor-handbook/migration-rules/github.svg)](https://agentmods.dev/rules/girijashankarj/cursor-handbook/migration-rules)
Your own site
<a href="https://agentmods.dev/rules/girijashankarj/cursor-handbook/migration-rules"><img src="https://agentmods.dev/badge/rules/girijashankarj/cursor-handbook/migration-rules/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for migration-rules

Your own site · 80×15
<a href="https://agentmods.dev/rules/girijashankarj/cursor-handbook/migration-rules"><img src="https://agentmods.dev/badge/rules/girijashankarj/cursor-handbook/migration-rules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 459 The whole file, excluding the scripts and references it only reads on demand.
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.00000 $0.00459
Opus 5.5 $0.00000 $0.00184
Sonnet 5.5 $0.00000 $0.00092
Haiku 4.5 $0.00000 $0.00046

Measured 1mo ago against content hash dee8c90b2b85, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

migration-rules 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 1mo 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.

.cursor/rules/database/migration-rules.mdc · 62 lines

What it actually says

Database Migration Rules

Migration Safety

Pre-Migration Checklist

  • Migration has both UP and DOWN functions
  • Tested against a copy of production data
  • No data loss in the migration
  • Backward compatible with current code
  • Performance tested for large tables
  • Reviewed by another developer

Safe Migration Patterns

-- SAFE: Adding a column with a default
ALTER TABLE orders ADD COLUMN priority VARCHAR(20) DEFAULT 'normal';

-- SAFE: Adding an index concurrently (PostgreSQL)
CREATE INDEX CONCURRENTLY idx_orders_priority ON orders(priority);

-- UNSAFE: Renaming a column (breaks existing queries)
-- Instead: Add new column → migrate data → update code → remove old column

-- UNSAFE: Changing column type directly
-- Instead: Add new column → migrate data → swap columns

Migration Naming

Format: YYYYMMDDHHMMSS_descriptive_action.sql

Examples:
  20260101120000_create_orders_table.sql
  20260102090000_add_priority_to_orders.sql
  20260103150000_create_idx_orders_user_id.sql

Zero-Downtime Migration Strategy

For production databases, follow this sequence:

  1. Expand: Add new columns/tables (backward compatible)
  2. Migrate: Backfill data to new structure
  3. Contract: Update code to use new structure
  4. Cleanup: Remove old columns/tables (after verification)

Rollback Plan

  • Every migration MUST have a rollback script
  • Test rollback in staging before production deployment
  • Keep rollback scripts for the last 10 migrations
  • Document manual steps if automated rollback isn't possible

Data Backfill

  • Use batch processing for large tables (1000-5000 rows per batch)
  • Include progress logging
  • Implement idempotent backfills (safe to re-run)
  • Run during low-traffic periods for large tables
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. 1mo ago First seen · 62 lines · 0 tokens per session scan A dee8c90b2b85

Subscribe to this mod's changes

migration-rules is a cursor rule published in the GitHub repository girijashankarj/cursor-handbook (33 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 459 tokens. 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.