manicanldes-backend/prisma/blog.prisma

36 lines
1.6 KiB
Plaintext

enum BlogState {
DRAFT
PUBLISHED
WITHDRAWN
}
model BlogArticle {
id String @id @default(uuid()) @db.Uuid
organizationId String @map("organization_id") @db.Uuid
createdById String @map("created_by_id") @db.Uuid
slug String @db.VarChar(100)
title String @db.VarChar(160)
summary String @db.VarChar(500)
body String
state BlogState @default(DRAFT)
version Int @default(0)
publishedContent Json? @map("published_content")
publicationVersion Int? @map("publication_version")
publishedAt DateTime? @map("published_at") @db.Timestamptz(3)
publishedById String? @map("published_by_id") @db.Uuid
withdrawnAt DateTime? @map("withdrawn_at") @db.Timestamptz(3)
withdrawnById String? @map("withdrawn_by_id") @db.Uuid
withdrawalReason String? @map("withdrawal_reason") @db.VarChar(500)
idempotencyKey String @map("idempotency_key") @db.Uuid
requestHash String @map("request_hash") @db.Char(64)
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz(3)
createdBy User @relation("BlogCreator", fields: [createdById, organizationId], references: [id, organizationId], onDelete: Restrict)
publishedBy User? @relation("BlogPublisher", fields: [publishedById, organizationId], references: [id, organizationId], onDelete: Restrict)
withdrawnBy User? @relation("BlogWithdrawer", fields: [withdrawnById, organizationId], references: [id, organizationId], onDelete: Restrict)
@@unique([organizationId, slug])
@@unique([organizationId, idempotencyKey])
@@index([organizationId, state, publishedAt, id])
@@index([organizationId, createdAt, id])
@@map("blog_articles")
}