home / skills / tlabs-xyz / tbtc-v2-performance / backend-migrations
/.claude/skills/backend-migrations
This skill guides you through creating and maintaining safe, reversible database migrations for zero-downtime deployments and schema evolution.
npx playbooks add skill tlabs-xyz/tbtc-v2-performance --skill backend-migrationsReview the files below or copy the command above to add this skill to your agents.
---
name: Backend Migrations
description: Create and manage database migrations following best practices for reversibility, zero-downtime deployments, and safe schema changes. Use this skill when creating new database migrations, writing migration up/down methods, implementing schema changes (adding/removing tables, columns, indexes, constraints), performing data migrations or transformations, refactoring database structure, implementing backwards-compatible migrations, creating indexes on large tables, renaming database objects, or working with migration files in directories like migrations/, db/migrate/, alembic/versions/, or similar. Use when working with ORMs like Sequelize, TypeORM, Prisma, SQLAlchemy, ActiveRecord, Django ORM, or raw SQL migration files.
---
## When to use this skill
- When creating new database migration files
- When implementing migration up/down (or upgrade/downgrade) methods
- When adding, removing, or modifying database tables
- When adding, removing, or modifying database columns
- When creating, dropping, or modifying indexes or constraints
- When performing data migrations or transformations
- When refactoring database structure
- When implementing backwards-compatible schema changes
- When creating indexes on large tables (considering concurrent options)
- When renaming tables, columns, or other database objects
- When working with migration directories (migrations/, db/migrate/, alembic/versions/)
- When working with ORMs like Sequelize, TypeORM, Prisma, SQLAlchemy, ActiveRecord, Django ORM
- When writing raw SQL migration files
# Backend Migrations
This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle backend migrations.
## Instructions
For details, refer to the information provided in this file:
[backend migrations](../../../agent-os/standards/backend/migrations.md)
This skill helps create and manage database migrations that are safe, reversible, and compatible with zero-downtime deployment patterns. It guides authors to produce up/down (or upgrade/downgrade) methods, handle large-table operations safely, and maintain backward compatibility across releases. The focus is practical: avoid locking, enable rollbacks, and ensure predictable behavior across environments.
The skill inspects migration files and surrounding code to validate patterns: presence of reverse operations, transactional boundaries, and safe ordering of schema and data changes. It flags risky constructs (unbounded table scans, blocking DDL, destructive deletes) and recommends alternatives (chunked updates, concurrent index creation, feature-flagged rollouts). It tailors advice for common ORMs and raw SQL migration directories.
What if a migration cannot be fully reversible?
Document the irreversible parts clearly in the migration, provide a safe mitigation plan, and avoid deploying irreversible destructive changes during peak traffic. Prefer soft deletes or feature-flagged rollouts when possible.
How do I add an index without blocking production?
Use the database's concurrent or online index creation feature when available, create the index in a separate migration, and monitor progress. Avoid creating large indexes inside a transactional migration if the DB prohibits it.