db-migrate
Skill0 starsChanged 4 months agoMITView on GitHub
DBマイグレーションの適用一式。「マイグレーションして」「マイグレーションを適用して」「MCP接続してマイグレーション」「スキーマを反映して」「テーブルを追加したら反映して」などの依頼で起動。マイグレーションツールの自動検出→接続確認→破壊的変更の事前確認→適用→スキーマ検証→ローカル/Vercel両方の環境変数同期までを一括実行する。Supabase/Neon/Prisma/Drizzle対応。
- Reads credentials
- Deletes or force-pushes
12 other projects use a version of this.
Adopted by
Most recently taken up by
- suxrobGM/jobpilottheir own version, first seen Oct 3, 2026
- mgiovani/cc-arsenaltheir own version, first seen Sep 25, 2026
- pgnzbl-ux/crucibletheir own version, first seen Aug 27, 2026
- lfrodrigues/packt-claude-code-course-auththeir own version, first seen Jul 15, 2026
- Pradnyeshp/Claude-Skillstheir own version, first seen Jul 6, 2026
- amajorai/skillstheir own version, first seen May 29, 2026
Used with
Projects with it also use e2e and deploy.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- alexeykrol/claude-code-starter★ 194same name
- suxrobGM/jobpilot★ 81same name
- getsentry/abacus★ 77same name
- lfrodrigues/packt-claude-code-course-auth★ 9same name
- mgiovani/cc-arsenal★ 8same name
- mean-weasel/bullhorn★ 4same name
- pgnzbl-ux/crucible★ 4same name
- amajorai/skills★ 3same name
- vndee/engineering-skills★ 3same name
- Pradnyeshp/Claude-Skills★ 2same name
2 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- audit-refactorSkill
- responsive-fixSkill
- shipSkill
The file
Files
db-migrate — マイグレーション適用一式
「マイグレーションして」で、適用だけでなく検証と環境変数の同期まで終わらせるスキル。過去の頻出事故は「ローカルでは動くがVercelで env ZodError」「MCP認証が通らず手詰まり」の2つ。どちらもここで防ぐ。
全体フロー
1. ツールと対象の検出
2. 接続確認(MCP優先、ダメなら接続文字列でフォールバック)
3. 事前レビュー(破壊的変更の検出と確認)
4. 適用
5. 検証(スキーマ確認・型生成・typecheck)
6. 環境変数の同期(ローカル + Vercel)
7. 報告1. ツールと対象の検出
プロジェクトを調べて該当するものを特定する:
| 検出物 | ツール | 適用コマンド |
prisma/schema.prisma | Prisma | npx prisma migrate deploy(本番) / npx prisma migrate dev(開発) |
drizzle.config.* | Drizzle | npx drizzle-kit migrate(SQLファイル方式) / push(スキーマ直接) |
supabase/migrations/*.sql | Supabase CLI | npx supabase db push または SQL直接実行 |
migrations/*.sql(汎用) | 生SQL | MCPの run_sql_transaction か psql で順次適用 |
未適用のマイグレーションがどれかを必ず確認する(マイグレーション管理テーブル、prisma migrate status 等)。適用済みのものを二重適用しない。
2. 接続確認
優先順:
- MCPサーバー — Neon MCP(
mcp__Neon__run_sql等)や Supabase MCP が接続済みならそれを使う - 接続文字列 —
.env.local/.envから探す。よく使われる変数名:SUPABASE_DB_URL、DATABASE_URL、POSTGRES_URL、DIRECT_URL - どちらも無ければユーザーに確認する(Supabaseダッシュボード → Project Settings → Database → Connection string。マイグレーションには pooler(6543)ではなく direct(5432)を使う。poolerはprepared statement非対応でマイグレーションが失敗することがある)
MCP認証エラー時のフォールバック(過去に Unrecognized client_id で発生): MCPの再認証に時間を溶かさず、接続文字列での直接実行に即切り替える。
シークレット規律: 接続文字列・パスワードは出力・コミット・ログに絶対に平文で書かない。表示が必要な場合はパスワード部分を **** でマスクする。
3. 事前レビュー(破壊的変更の検出)
適用予定のSQL/スキーマ差分を読み、以下があれば適用前にユーザーへ確認する:
DROP TABLE/DROP COLUMN/TRUNCATE/ 大量DELETE- 型変更(
ALTER COLUMN ... TYPE)でデータ損失の可能性があるもの NOT NULL追加(既存行にNULLがあると失敗する → デフォルト値かバックフィルが必要)
破壊的変更がある場合はロールバック手段を先に用意する: Neonならブランチ作成(create_branch)、Supabaseなら対象テーブルのバックアップ(CREATE TABLE _backup_x AS SELECT ...)を提案。
非破壊(テーブル追加・カラム追加・インデックス追加)は確認なしで進めてよい。
4. 適用
- 検出したツールのコマンドで適用する。生SQLの場合はトランザクションで包む(
run_sql_transaction/BEGIN...COMMIT) - Neon MCPが使える場合の推奨フロー:
prepare_database_migration(一時ブランチで試行)→ 結果確認 →complete_database_migration - RLS(Row Level Security)を使うプロジェクトで新テーブルを作った場合、RLSポリシーの設定漏れがないか必ず確認する(ポリシー無しのテーブルは全ユーザーに見える/全く見えないの事故になる)
5. 検証
- スキーマ実体の確認:
describe_table_schema/\d/ information_schema で、意図したカラム・インデックス・制約が実際に入ったか確認 - 型の再生成(該当ツールがある場合):
npx prisma generate/npx supabase gen types typescript/ drizzleのスキーマ更新 typecheckを実行し、スキーマ変更でアプリ側の型が壊れていないか確認- 影響するテストがあれば実行
6. 環境変数の同期(最頻出の事故ポイント)
マイグレーションや新機能で環境変数が増えた場合、ローカルとVercelの両方に揃っているか確認する:
- コードが参照する環境変数を洗い出す(env検証スキーマ(Zod等)があればそれが正)
- ローカル:
.env.localに不足がないか - Vercel:
vercel env lsで不足を特定 → 不足分はvercel env add <NAME> productionで追加(値はユーザーに確認。チャットに貼られた値は使用後にマスクして扱う) - Vercel側に追加した場合は再デプロイしないと反映されないことを報告に含める
過去の実例:
ZodError: expected string, received undefined (SUPABASE_URL)はローカルにあってVercelに無いパターン。ビルドは env 検証で落ちる。
7. 報告
最後に1つのメッセージでまとめる:
- 適用したマイグレーション(ファイル名/内容の1行要約)
- スキーマ検証の結果(確認したテーブル・カラム)
- 環境変数の変更(どこに何を追加したか。値は書かない)
- ロールバック手段(バックアップテーブル名・Neonブランチ名など)
- 再デプロイの要否
コミット・プッシュ・デプロイはユーザーの指示または /ship で行う。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

