schema.prisma 1.23 KB
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgres"
  url      = env("DATABASE_URL")
}

model User {
  id       String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid @unique
  email    String @unique
  name     String
  password String
  role     Role   @default(USER)

  posts    Post[]
  comments Comment[]
}

model Post {
  id        String   @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid @unique
  title     String 
  createdAt DateTime @default(now())
  private   Boolean  @default(true)
  author    User     @relation(fields: [authorId], references: [id])
  authorId  String   @db.Uuid
  level     Level    @default(MEDIUM)
  content   String

  comments Comment[]
}

model Comment {
  id        String   @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid @unique
  content   String
  createdAt DateTime @default(now())
  author    User     @relation(fields: [authorId], references: [id])
  authorId  String   @db.Uuid
  post      Post     @relation(fields: [postId], references: [id])
  postId    String   @db.Uuid
}

enum Level {
  LOW
  MEDIUM
  HIGH
}

enum Role {
  USER
  ADMIN
}