Cursor Migration Helper
Added Apr 2, 2026
About This Prompt
This prompt generates comprehensive database and system migration plans with executable scripts that handle the full lifecycle from planning through verification. Migrations are among the riskiest operations in software development, and this prompt addresses that risk with transaction-safe scripts, rollback plans, validation queries, and gradual rollout strategies. The output includes idempotent migration scripts that can be safely re-run if interrupted, along with data validation to ensure nothing is lost or corrupted. This is essential for engineering teams migrating databases, upgrading frameworks, switching providers, or refactoring data models in production systems.
Variables to Customize
[SOURCE_SYSTEM]
The current system being migrated from
Example: MongoDB with Mongoose ODM
[TARGET_SYSTEM]
The system being migrated to
Example: PostgreSQL with Prisma ORM
[PROJECT_TYPE]
Type of application
Example: SaaS multi-tenant application
[CURRENT_FUNCTIONALITY]
What the current system manages
Example: user accounts, subscriptions, invoices, and activity logs
[DATA_VOLUME]
Approximate amount of data
Example: 2 million records across 15 collections
[LANGUAGE]
Programming language for migration scripts
Example: TypeScript with Node.js
[MIGRATION_CHALLENGES]
Specific challenges to address
Example: nested MongoDB documents need to be flattened into relational tables, ObjectId references need to map to integer foreign keys, and some fields have inconsistent data types
Tips for Best Results
- Always test the migration on a staging copy of production data before running it live
- Use the generated validation queries after every migration run to catch data integrity issues
- Plan for twice the estimated downtime as a safety margin
Example Output
# Migration Plan: MongoDB to PostgreSQL
## Pre-Migration Checklist
- [ ] Full MongoDB backup completed and verified
- [ ] Schema audit: 15 collections mapped to relational tables
- [ ] Dependency map: 23 services read from MongoDB, 8 write
## Schema Mapping
| MongoDB Collection | PostgreSQL Table | Key Transformations |
|---|---|---|
| users | users | ObjectId -> UUID, nested address -> addresses table |
| subscriptions | subscriptions | embedded plan -> FK to plans table |
## Migration Script (Phase 1: Users)
```typescript
async function migrateUsers(batchSize = 1000) {
const client = await pool.connect();
try {
await client.query('BEGIN');
...