Db migrate
Design and execute safe database migrations. Covers schema evolution, zero-downtime patterns, rollback strategies, and data backfills for SQL and NoSQL databases.From its SKILL.md
npx -y skills add roborracle/agent-workflow-kit --skill db-migrateAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.4 KB, as published. Nobody here has run it
Database Migration Manager
Migration Safety Protocol
Before Writing the Migration
- Classify the change — additive (safe), destructive (dangerous), or transformative (requires expand-contract)
- Check table size — large tables need batched operations to avoid locks
- Identify dependencies — foreign keys, views, triggers, stored procedures that reference the target
- Plan rollback — every migration must have a reverse migration
Migration Classification
| Type | Risk | Pattern |
|---|---|---|
| Add column (nullable) | Low | Direct ALTER |
| Add column (NOT NULL + default) | Medium | Add nullable → backfill → set NOT NULL |
| Remove column | High | Expand-contract (stop reading → deploy → drop) |
| Rename column | High | Add new → copy data → update code → drop old |
| Change column type | High | Add new column → backfill with cast → swap |
| Add index | Medium | CREATE INDEX CONCURRENTLY (Postgres) or equivalent |
| Drop table | Critical | Verify zero references → soft-delete first → drop after grace period |
Zero-Downtime Pattern: Expand-Contract
For any breaking schema change:
Phase 1 — Expand (backward compatible)
-- Add new column, keep old one
ALTER TABLE users ADD COLUMN full_name VARCHAR(255);
Phase 2 — Migrate (backfill data)
-- Batch update to avoid table locks
UPDATE users SET full_name = first_name || ' ' || last_name
WHERE full_name IS NULL
LIMIT 1000;
Phase 3 — Transition (code reads new, writes both)
- Deploy application code that writes to both columns
- Reads from new column with fallback to old
Phase 4 — Contract (remove old)
-- Only after all code uses new column
ALTER TABLE users DROP COLUMN first_name, DROP COLUMN last_name;
Migration File Template
-- Migration: [description]
-- Author: [name]
-- Date: [date]
-- Reversible: Yes/No
-- Estimated duration: [time on production data size]
-- Lock level: [none/row/table]
-- UP
[migration SQL]
-- DOWN (rollback)
[reverse SQL]
-- VERIFY (post-migration check)
[validation query that confirms success]
Pre-Flight Checklist
- Migration runs in a transaction (or is idempotent if it cannot)
- Rollback migration tested
- No full table locks on tables with >100K rows
- Indexes created CONCURRENTLY where supported
- Default values set at application level, not database level (for large tables)
- Verified on staging with production-sized dataset
- Backup confirmed before execution
Anti-Patterns
- Adding NOT NULL without a default on a large table (locks entire table)
- Running data migration in the same transaction as schema migration
- Dropping columns before all code paths stop referencing them
- Using ORM auto-migration in production without reviewing generated SQL
- Assuming migration duration from dev dataset size
Data Migration Patterns
- Backfill: Batch updates with LIMIT/OFFSET, sleep between batches
- Transform: ETL pipeline with progress tracking and resumability
- Seed: Idempotent INSERT ... ON CONFLICT DO NOTHING