@jujunjun110/db-table
Aデータベースにテーブルを追加・変更する。Prismaスキーマ変更 + マイグレーション + Repository生成
Install
agr install @jujunjun110/db-table --target claudeWrites 1 file into .claude/skills/, pinned to git-ee9ba21b.
- .claude/skills/db-table/SKILL.md
Document
description: データベースにテーブルを追加・変更する。Prismaスキーマ変更 + マイグレーション + Repository生成
DB テーブル追加・変更スキル
ユーザーが「〇〇テーブルを追加して」「〇〇カラムを追加して」と指示したときに適用する。
手順
1. Prisma スキーマ変更
apps/webapp/prisma/schema.prisma を編集:
- テーブル名は
@@map("snake_case_plural")でスネークケース複数形にマッピング - カラム名は
@map("snake_case")でスネークケースにマッピング idは@id @default(cuid())を使用- タイムスタンプは
@db.Timestamptz()を付与 - 日時カラムには
@map("snake_case")を付ける
2. マイグレーション作成
pnpm db:migrate
マイグレーション名の入力を求められたら、変更内容を簡潔に英語で入力する(例: add_jokes_table)。
3. Repository 生成
- Interface (
src/backend/domain/repositories/{name}.repository.ts)- ドメインモデル型のみ使用
- 実装 (
src/backend/infrastructure/repositories/prisma-{name}.repository.ts)- Prisma Client 経由で CRUD
- ORM 型 ↔ ドメインモデル変換を担当
4. Domain Model 生成
src/backend/domain/models/{name}.model.ts:
- Rich Domain Model(ファクトリメソッド
create()+reconstruct()) - バリデーションはモデル自身で行う
ルール
prisma db pushは使用禁止(必ずprisma migrate devを使う)- Repository interface にORM型を出さない
- 変更後に
pnpm verifyを実行
Trustgrade A
- passBody integrity
Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.
- passType matchnot applicable to this artifact type
Whether the artifact is really the kind of thing its metadata claims it is.
- passFreshness
How long since the source repository was last pushed to.
- passPrompt injection
Scans the artifact's own text for instructions aimed at your agent rather than at you.
- passLicense
Whether the source repository declares an SPDX license permissive enough to redistribute.
How the grade is calculated
Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:
- Aevery check passed
- Bone warning
- Ctwo warnings
- Dprompt injection or body integrity failed, or three warnings
- Fone of those failed, and something else is wrong
These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.
Versions
git-ee9ba21b22632026-07-31