Database Migration Writer

Developer Toolscursor-vs-claude-codemigration_descriptionorm_nameschema_file_path

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.

Prompt
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

{{migration_description}}{{orm_name}}{{schema_file_path}}{{database_type}}{{row_count}}

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 OPTIMIZE

AI Optimization

One-click improvement with structure analysis and pattern suggestions.

VERSION DIFF

Version History

Track every edit. Compare versions side-by-side with word-level diffs.

ORGANIZE
Development
Code Review
Testing
Marketing

Folders & Tags

Organize your library with nested folders, tags, and drag-and-drop.

MCP
$ npm i -g @promptingbox/mcp
Claude · Cursor · ChatGPT

Use 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.