원클릭으로
database-schema-design
Guide for designing database schemas with Prisma ORM. Use when creating or modifying database models.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Guide for designing database schemas with Prisma ORM. Use when creating or modifying database models.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Checklist for auditing and fixing accessibility issues (WCAG 2.1 AA compliance). Use when reviewing components or pages for accessibility.
Guide for creating RESTful API endpoints with validation and error handling. Use when implementing backend API routes.
Guide for implementing secure authentication with JWT and session management. Use when adding authentication to an application.
Guide for creating responsive layouts with CSS. Use when implementing responsive design or fixing layout issues.
Guide for consistent error handling across frontend and backend. Use when implementing error handling logic.
Guide for implementing form handling with React Hook Form and Zod validation. Use when creating forms with validation.
| name | database-schema-design |
| description | Guide for designing database schemas with Prisma ORM. Use when creating or modifying database models. |
Follow this process to design robust database schemas:
// schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
email String @unique
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
posts Post[]
profile Profile?
}
id String @id @default(cuid()) // Preferred: Collision-resistant IDs
// OR
id Int @id @default(autoincrement()) // For simple cases
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime? // For soft deletes
enum UserRole {
USER
ADMIN
MODERATOR
}
model User {
role UserRole @default(USER)
}
model User {
id String @id @default(cuid())
posts Post[]
}
model Post {
id String @id @default(cuid())
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
}
model User {
id String @id @default(cuid())
profile Profile?
}
model Profile {
id String @id @default(cuid())
userId String @unique
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Post {
id String @id @default(cuid())
tags Tag[]
}
model Tag {
id String @id @default(cuid())
posts Post[]
}
model Post {
id String @id @default(cuid())
title String
slug String @unique
authorId String
status String
createdAt DateTime @default(now())
// Composite index for common queries
@@index([authorId, status])
@@index([createdAt])
}
model User {
email String @unique
username String @unique
age Int @default(0)
@@unique([email, username]) // Composite unique
}
model User {
id String @id @default(cuid())
posts Post[]
}
model Post {
id String @id @default(cuid())
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
// Options: Cascade, SetNull, Restrict, NoAction
}
# Create migration
pnpm prisma migrate dev --name add_user_table
# Apply to production
pnpm prisma migrate deploy
# Generate client
pnpm prisma generate
# Reset database (dev only)
pnpm prisma migrate reset