database-migrations-sql-migrations
SQLデータベースマイグレーションの習得
このスキルは、組み込みのロールバック手順と検証チェックを備えたPostgreSQL、MySQL、SQL Serverのゼロダウンタイムデータベースマイグレーションの実装を開発者に支援します。
スキルZIPをダウンロード
Claudeでアップロード
設定 → 機能 → スキル → スキルをアップロードへ移動
オンにして利用開始
テストする
「database-migrations-sql-migrations」を使用しています。 Create a zero-downtime migration to add a status column to orders table
期待される結果:
- Migration Analysis Report
- 1. Strategy: Expand-Contract Pattern
- 2. Phase 1 (Expand): Add nullable status column
- 3. Phase 2 (Migrate): Backfill status from state column in batches
- 4. Phase 3 (Contract): Drop old state column after code deploy
- 5. Validation: Row count match, no data loss
- 6. Rollback: Revert to snapshot if validation fails
「database-migrations-sql-migrations」を使用しています。 Write a rollback script for version 001 migration
期待される結果:
- Rollback Script for v001
- - Verify current version matches
- - Create pre-rollback backup
- - Execute down.sql migration
- - Remove migration record
- - Validate rollback success
セキュリティ監査
安全All 63 static findings are false positives. The skill provides legitimate SQL migration examples including PostgreSQL functions (gen_random_uuid, pg_sleep), database introspection queries (pg_indexes), and configuration references. No actual command injection, weak cryptography, or data exfiltration present. This is a benign database migration guidance skill.
中リスクの問題 (2)
低リスクの問題 (2)
品質スコア
作れるもの
ダウンタイムなしで新しい列を追加する
バッチを使用したデータバックフィルを含む расшир-контраクトパターンを使用して、本番環境の大きなテーブルにNOT NULL列を安全に追加します。
レガシー構造から新しい構造へのマイグレーション
ゼロデータ損失でレガシーから新しいスキーマへマイグレーションするために、二重書き込み同期を備えたブルーグリーンマイグレーションを使用します。
安全なロールバック手順の作成
失敗したマイグレーションから回復するための、移行前スナップショットと検証チェックを備えた自動化されたロールバックスクリプトを生成します。
これらのプロンプトを試す
Create a migration script to add a new column called email_verified (BOOLEAN, DEFAULT FALSE) to the users table in PostgreSQL. Include proper error handling.
Generate a zero-downtime migration strategy to convert a VARCHAR column to ENUM type in a production MySQL database with 10M+ rows.
Write a migration to move data from the legacy orders table to a new v2_orders table. Include pre-validation checks, batched backfill, and post-migration row count verification.
Create a full migration package for adding a JSONB metadata column to the products table. Include: forward migration SQL, rollback SQL, validation checks, and a shell script for execution with proper error handling.
ベストプラクティス
- 本番環境でマイグレーションを実行する前に、常にデータベースのスナップショットまたはバックアップを作成してください
- トランザクションブロック(BEGIN/COMMIT)を使用してマイグレーションステップの原子性を確保してください
- データ損失を検出するために移行前と移行後の行数を検証してください
- 本番環境をミラーしたステージング環境でマイグレーションをテストしてください
回避
- 移行前の検証なしに本番環境で直接マイグレーションを実行する
- PostgreSQLで大きなテーブルにCONCURRENTLYフラグなしでALTER TABLEを使用する
- 本番環境のスキーマ変更でロールバック手順をスキップする
- マイグレーション中の外部キー制約と参照整合性を考慮しない