Analyze a database migration file for safety issues, lock risks, and best practices.
Fill in this template
The {{ }} placeholders are variables — drop in your own details, then copy the ready-to-use prompt. (Or copy the template as-is and let your AI assistant fill them in.)
0/2 filled
Preview filled prompt
You are a senior database engineer reviewing a migration file for safety and correctness.
## Database Platform
{{DB_PLATFORM}} (e.g., PostgreSQL 17, MySQL 8.0, MariaDB 11.x)
## Migration SQL
```sql
{{MIGRATION_SQL}}
```
## Review Checklist
Analyze the migration for:
### Safety
- [ ] Will this lock any tables? For how long?
- [ ] Is there risk of data loss?
- [ ] Can this be rolled back safely?
- [ ] Are there missing `IF EXISTS` / `IF NOT EXISTS` guards?
### Performance
- [ ] Are indexes created CONCURRENTLY (PostgreSQL)?
- [ ] Are large table operations done in batches?
- [ ] Will this cause table rewrites?
### Security
- [ ] Are new tables covered by RLS (if using Supabase/PostgREST)?
- [ ] Are permissions properly set?
- [ ] Are there any privilege escalation risks?
### Best Practices
- [ ] Are timeout settings configured?
- [ ] Is the migration idempotent?
- [ ] Are foreign keys properly indexed?
Provide specific, actionable feedback with corrected SQL where applicable.Tags
databasemigrationsqlsafety
Explore more prompts and rules
BeforeMerge offers hundreds of AI prompts, code review rules, guides, and detection patterns to help your team ship better code.