← スキル一覧に戻る

db-migrate
by AppleLamps
⭐ 0🍴 0📅 2026年1月7日
SKILL.md
name: db-migrate description: Create database migration scripts following project patterns. Use when user mentions "migration", "add column", "alter table", "schema change", or "database update".
Database Migration
Create migration scripts for Neon PostgreSQL following project conventions.
Instructions
-
Read current schema:
prisma/schema.sqlfor table definitionssrc/lib/db.tsfor TypeScript interfaces
-
Create migration script in
scripts/directory:- Filename:
<action>-<description>.mjs(e.g.,add-views-column.mjs) - Use existing pattern from
scripts/add-summary-column.mjs
- Filename:
-
Migration script template:
import { neon } from '@neondatabase/serverless'; import { config } from 'dotenv'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); config({ path: join(__dirname, '..', '.env.local') }); const sql = neon(process.env.DATABASE_URL); async function migrate() { console.log('Running migration...'); await sql` ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name TYPE `; console.log('Migration complete!'); } migrate().catch(console.error); -
Update
src/lib/db.ts:- Add new fields to relevant interface
- Update query functions if needed
-
Update
prisma/schema.sql:- Add new column to CREATE TABLE statement
Examples
- "Add a views column to articles"
- "Create migration for user preferences table"
- "Add index on published_at"
Guardrails
- ALWAYS use
IF NOT EXISTSorIF EXISTSfor safety - NEVER use DROP TABLE without explicit confirmation
- Test migration on development database first
- Back up data before destructive operations:
curl localhost:3000/api/admin/articles/export
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です