Database Migration Writer
Claude Code can read the current schema file, understand the ORM conventions, and generate both the migration code and SQL. Cursor handles this well with file references. The safety checklist prevents common migration pitfalls.
Write a database migration for the following change: Change: {{migration_description}} ORM: {{orm_name}} Current schema: (read from {{schema_file_path}}) Database: {{database_type}} Requirements: 1. Generate both the schema change (ORM model) and the raw SQL migration file 2. Handle the migration safely: - Add columns as nullable first if they'll be NOT NULL (backfill, then alter) - Use IF NOT EXISTS / IF EXISTS guards where supported - For column renames, use a two-step approach in prod (add new, migrate data, drop old) 3. Include a rollback/down migration 4. If adding indexes, consider: - CREATE INDEX CONCURRENTLY for large tables (PostgreSQL) - Composite index column ordering (most selective first) 5. If the table has RLS enabled, update policies if the new columns need them After writing the migration: - Estimate the impact on a table with {{row_count}} rows - Flag any operations that will lock the table - Note if this migration is backward-compatible with the current application code
Variables to customize
Why this prompt works
Claude Code can read the current schema file, understand the ORM conventions, and generate both the migration code and SQL. Cursor handles this well with file references. The safety checklist prevents common migration pitfalls.
What you get when you save this prompt
Your workspace unlocks powerful tools to iterate and improve.
AI Optimization
One-click improvement with structure analysis and pattern suggestions.
Version History
Track every edit. Compare versions side-by-side with word-level diffs.
Folders & Tags
Organize your library with nested folders, tags, and drag-and-drop.
$ npm i -g @promptingbox/mcpUse Everywhere
Access prompts from Claude, Cursor, ChatGPT & more via MCP integration.
Your prompts, organized
Save, version, and access your best prompts across ChatGPT, Claude, Cursor, and more.