ワンクリックで
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