install
source · Clone the upstream repo
git clone https://github.com/wrtnlabs/autobe
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/wrtnlabs/autobe "$T" && mkdir -p ~/.claude/skills && cp -r "$T/internals/template/realize/.claude/skills/fix-db" ~/.claude/skills/wrtnlabs-autobe-fix-db && rm -rf "$T"
manifest:
internals/template/realize/.claude/skills/fix-db/SKILL.mdsource content
Fix Database Schema Errors
Fix Prisma schema compilation errors according to code conventions.
FORBIDDEN
NEVER use:
- Prisma
types (use String with TypeScript union types instead)enum
Purpose
Fix compilation errors in Prisma schema files to ensure
npm run build:prisma passes.
Workflow
┌─────────────────────────────────────┐ │ Step 1: Run Build │ │ npm run build:prisma │ └───────────────┬─────────────────────┘ │ ▼ ┌─────────────────────────────────────┐ │ Step 2: Parse Errors │ │ - Syntax errors │ │ - Relation errors │ │ - Type errors │ └───────────────┬─────────────────────┘ │ ▼ ┌─────────────────────────────────────┐ │ Step 3: Fix by Convention │ │ Apply code conventions │ └───────────────┬─────────────────────┘ │ ▼ ┌─────────────────────────────────────┐ │ Step 4: Re-run Build │ │ Loop until 0 errors │ └─────────────────────────────────────┘
Step 1: Run Build
npm run build:prisma 2>&1
Capture all error output.
Step 2: Parse Errors
Common error types:
: Syntax error in decoratorError parsing attribute
: Invalid field typeError validating field
: Missing or invalid relationError validating relation
Step 3: Fix by Convention
Primary Key Convention
// Standard id String @id @db.Uuid
Timestamp Convention
created_at DateTime @db.Timestamptz updated_at DateTime @db.Timestamptz deleted_at DateTime? @db.Timestamptz
Foreign Key Convention
{parent}_id String @db.Uuid {parent} {prefix}_{parents} @relation(fields: [{parent}_id], references: [id], onDelete: Cascade)
Union Type Fields (NOT enum)
// DO NOT use Prisma enum status String // "active" | "inactive" defined in TypeScript // WRONG - Never do this // enum Status { ACTIVE INACTIVE }
Self-referential Relation
parent_id String? @db.Uuid parent {Model}? @relation("recursive", fields: [parent_id], references: [id], onDelete: Cascade) children {Model}[] @relation("recursive")
Index Convention
@@index([{parent}_id, status]) @@index([name(ops: raw("gin_trgm_ops"))], type: Gin)
Step 4: Verify
npm run build:prisma
Repeat Steps 2-4 until no errors.
Common Fixes
| Error Pattern | Fix |
|---|---|
| Missing relation | Add with fields and references |
| Invalid type | Use correct Prisma types (String, Int, DateTime, etc.) |
| Duplicate model | Remove duplicate or rename |
| Missing @@map | Add table name mapping |
| Enum error | Replace with String type |
Exit Condition
completes with no errorsnpm run build:prisma- All models properly defined
- All relations valid