Run Migration Skill
Migration Execution Checklist
Pre-Migration
- • Backup database
- • Test migration on staging environment
- • Review migration script for errors
- • Ensure rollback (down migration) works
- • Notify team of migration window
During Migration
bash
# Run migration npm run migrate:up # or python manage.py migrate # or npx prisma migrate deploy
Post-Migration
- • Verify schema changes applied
- • Run smoke tests
- • Check application functionality
- • Monitor error logs
- • Update schema documentation
If Migration Fails
bash
# Rollback migration npm run migrate:down # or python manage.py migrate <previous_version> # or npx prisma migrate reset
Migration Best Practices
- •Backwards Compatible: Ensure app works during migration
- •Transactional: Wrap in BEGIN/COMMIT
- •Idempotent: Safe to run multiple times
- •Tested: Test on staging first
- •Documented: Clear comments in migration
Example Migration
sql
-- Up migration BEGIN; ALTER TABLE users ADD COLUMN phone VARCHAR(20); CREATE INDEX idx_users_phone ON users(phone); COMMIT;
sql
-- Down migration BEGIN; DROP INDEX IF EXISTS idx_users_phone; ALTER TABLE users DROP COLUMN IF EXISTS phone; COMMIT;
Related Skills
- •
design_database_schema- Design schemas before migrating