本文へ移動
cccskills
無料GitHub で公開

migration-management

Manage database migrations and schema versioning. Use when planning migrations, version control, rollback strategies, or data transformations for any database paradigm.

インストール方法を見る

含まれるファイル(2)

  • SKILL.md6.5 KB
  • references/relational.md4.5 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Database Migration Management

Overview

Implement robust database migration systems with version control, rollback capabilities, and data transformation strategies. This skill covers universal migration methodology. For paradigm-specific tooling, see references.

When to Use

  • Schema versioning and evolution
  • Data transformations and cleanup
  • Adding/removing tables, columns, collections, or fields
  • Index creation and optimization
  • Migration testing and validation
  • Rollback planning and execution
  • Multi-environment deployments

Paradigm-Specific References

After reading the methodology below, read the reference matching your surface's Databases column in the surface stack map (.agents/instructions/tech-stack.md):

ParadigmReferenceExample Stores
Relationalreferences/relational.mdPostgreSQL, MySQL, SQLite
Documentreferences/document.mdMongoDB, Firestore, CouchDB
Graphreferences/graph.mdSurrealDB, Neo4j, ArangoDB

Universal Migration Principles

1. Bidirectional Migrations

Every migration must have both directions:

  • UP — applies the change
  • DOWN — reverses the change

If a migration cannot be reversed (e.g., data deletion), document this explicitly and require a backup before execution.

2. Migration Ordering

Migrations are sequentially ordered by timestamp or version number:

  • Timestamp format: YYYYMMDD_NNN_description (e.g., 20240115_001_add_phone_to_users)
  • Never reorder or renumber existing migrations
  • Never modify an already-executed migration — create a new one

3. Idempotency

Migrations should be idempotent where possible:

  • Use "IF NOT EXISTS" / "IF EXISTS" guards
  • Check for the presence of the change before applying it
  • Run pre-flight checks before destructive operations

4. Atomic Migrations

Each migration should be a single logical change:

  • One migration = one purpose (add column, create table, transform data)
  • Don't combine unrelated changes
  • Use transactions for multi-statement migrations where supported

Common Migration Patterns

Safe Schema Changes

OperationSafe?Strategy
Add nullable column✅ Always safeAdd with default or NULL
Add NOT NULL column⚠️ Requires backfillAdd nullable → backfill → add constraint
Rename column⚠️ Requires coordinationAdd new → copy data → update app → drop old
Drop column⚠️ Requires coordinationStop reading → deploy → drop column
Add index⚠️ Can lock tableUse concurrent/online index creation
Drop table🔴 DestructiveBackup first, confirm no references

Multi-Phase Migrations

For non-trivial schema changes (rename, type change, restructure):

  1. Phase 1: Expand — Add new structure alongside old
  2. Phase 2: Migrate — Copy/transform data to new structure
  3. Phase 3: Contract — Remove old structure after verification

This pattern prevents downtime and allows rollback at any phase.

Data Transformation Migrations

When transforming data (normalization, cleanup, format changes):

  1. Verify source data — Count records, check constraints
  2. Apply transformation — Batch for large datasets
  3. Validate results — Compare counts, spot-check values
  4. Document irreversibility — If rollback requires backup restore, say so

Rollback Strategies

Per-Migration Rollback

Every migration has a DOWN direction. Execute in reverse order:

  • Migration 5 DOWN
  • Migration 4 DOWN
  • Migration 3 DOWN
  • ... until target version reached

Point-in-Time Recovery

For data-destructive migrations:

  • Require backup before execution
  • Document the backup location
  • Test restore procedure before migration

Blue-Green Schema Changes

For zero-downtime migrations:

  • Run new schema alongside old
  • Application supports both schemas during transition
  • Cut over when new schema is verified
  • Drop old schema after observation period

Testing Migrations

Local Testing

  1. Fresh database — Run all migrations from scratch (empty → current)
  2. Incremental — Run only new migrations on a copy of production
  3. Rollback — Test DOWN migration after UP
  4. Data integrity — Verify constraints hold after migration

Staging Validation

  1. Restore production backup to staging
  2. Run migrations on staging
  3. Verify application works against migrated schema
  4. Run automated tests against staging
  5. Record migration timing for capacity planning

Pre-Production Checklist

  • Tested on local database
  • Tested on staging with production data copy
  • Rollback procedure tested
  • Backup verified before migration
  • Application code compatible with both old and new schema
  • Migration timing measured (acceptable for maintenance window?)
  • Long-running query impact assessed

Production Deployment

Safe Migration Checklist

  • Test migration on production-like database
  • Verify backup exists before migration
  • Schedule during low-traffic window
  • Monitor locks and long-running queries
  • Have rollback plan ready and tested
  • Document all changes
  • Run in transaction when possible
  • Verify data integrity after migration
  • Coordinate application code deployment with migration
  • Notify team of migration window

Post-Migration Verification

  1. Schema check — Verify new structures exist
  2. Data check — Verify data integrity constraints
  3. Application check — Verify application reads/writes correctly
  4. Performance check — Verify query performance hasn't degraded
  5. Monitoring — Watch error rates for 24 hours post-migration

Migration Tracking

Maintain a migration history table (or equivalent) that records:

  • Migration version/ID
  • Migration name/description
  • Execution timestamp
  • Duration
  • Checksum (to detect tampering)
  • Status (applied, rolled back, failed)

Resources

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Audit and improve web accessibility following WCAG 2.1 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible".

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Structured methodology for adversarial thinking — generating attack scenarios, abuse cases, race conditions, and security edge cases against specs and implementations. Produces spec-level gap items, not code-level fixes.

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Orchestrate multiple Antigravity skills through guided workflows for SaaS MVP delivery, security audits, AI agent builds, and browser QA.

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Manage API versioning and evolution with URL/header/query strategies, deprecation workflows, breaking change classification, sunset headers, and consumer-driven contract testing. Use when designing versioning strategy, deprecating endpoints, or evolving API contracts.

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

Analyzes codebase structure, data flow, module relationships, and key patterns to generate and maintain a living architecture document (ARCHITECTURE.md).

日本語の概要は準備中です。原文の説明を表示しています。

RepairYourTech/cfsa-antigravity62026年8月16日 更新

RepairYourTech のスキルをすべて見る

このスキルの問題を報告する