All skills
Skillintermediate
/rollback - Rollback Database Migration
Roll back the most recent database migration or to a specific version.
Claude Code Knowledge Pack7/10/2026
Overview
/rollback - Rollback Database Migration
Roll back the most recent database migration or to a specific version.
Steps
- Identify the current migration version from the migrations table
- List recent migrations with their status (applied, pending, failed)
- If no target version specified, default to rolling back the last applied migration
- Read the down migration logic for the target migration
- Check for data loss risks: dropping tables, removing columns with data
- Warn the user about any irreversible changes and data loss potential
- Ask for explicit confirmation before proceeding with rollback
- Execute the down migration within a transaction
- Verify the migration table is updated to reflect the rollback
- Run a schema diff to confirm the rollback matches the expected state
- Report: migration rolled back, current version, tables affected
Rules
- Always warn about potential data loss before executing rollback
- Require explicit user confirmation for destructive rollbacks
- Use transactions to ensure atomic rollback (all or nothing)
- Never rollback in production without a backup confirmation
- Log the rollback action with timestamp and reason
- Verify foreign key constraints are satisfied after rollback
- Test the rollback on a development database first when possible