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.

Database migration patterns and safety rules. Apply when creating or editing migrations.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/girijashankarj/cursor-handbook/migration-rules
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.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
Origin unknown 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 $0.00000 $0.00459
Opus 5 $0.00000 $0.00230
Sonnet 5 $0.00000 $0.00092
Haiku 4.5 $0.00000 $0.00046

Measured today against content hash dee8c90b2b85, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 today.

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. today 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 (30 stars, last pushed 4d 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.