AgentSkillsCN

Database Migration Skill

数据库迁移技能

SKILL.md
<!-- Template from Agentic Academy Full course: https://agentic-academy.dev/training/claude-code Created by Silvio Gobet | youtube.com/@silviogobet -->

name: db-migrate description: Safely handle database migrations with backup verification and rollback planning

Database Migration Skill

Safety Rules

  • ALWAYS backup before migrating
  • NEVER drop tables in production
  • Review generated SQL before execution

Workflow

  1. Check current migration status
  2. Generate migration file
  3. Review the changes
  4. Ask for confirmation
  5. Run migration
  6. Verify success

Pre-Migration Checklist

  • Database backup exists
  • Migration has been tested locally
  • Rollback plan documented
  • Team notified of migration

Commands by Framework

Prisma

bash
npx prisma migrate dev --name $ARGUMENTS
npx prisma migrate deploy  # Production

Django

bash
python manage.py makemigrations
python manage.py migrate

Rails

bash
rails db:migrate

Rollback Guidance

If migration fails:

  1. Check migration logs
  2. Run rollback command
  3. Restore from backup if needed
  4. Document what went wrong