Back to prompts
Write a safe, idempotent data migration script for the following scenario: Database: [PostgreSQL / MySQL / MongoDB / SQLite] Language: [Python / Node.js / Go / SQL only] What's changing: [describe the migration — e.g. adding a column / transforming data / moving to new schema / splitting a table] Current schema: [describe or paste the relevant parts] Target schema: [describe what it should look like after] Data volume: [approximate rows / documents affected] Can the app be offline during migration: [yes / no] The script must: 1. Be idempotent — safe to run multiple times without corrupting data 2. Run in a transaction (or batch transactions with rollback on error) 3. Include a dry-run mode that shows what would change without changing it 4. Log progress for large datasets 5. Validate data before and after the migration 6. Have a rollback procedure documented in comments Also provide: - Pre-migration checklist - How to verify the migration succeeded - Estimated runtime for the given data volume
How to use this prompt
- 1Copy the prompt using the button above.
- 2Open your AI tool (ChatGPT, Claude, Midjourney, etc.)
- 3Paste and customize any variables in the prompt.
- 4Generate your result.