Skip to content
Snippets Groups Projects
schema.prisma 1.66 KiB
Newer Older
// 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 {
Yusuf Akgül's avatar
Yusuf Akgül committed
  provider = "postgresql"
Yusuf Akgül's avatar
Yusuf Akgül committed
model User {
Omar Kasbah's avatar
Omar Kasbah committed
  id              String      @id @default(dbgenerated()) @db.Uuid
  userName        String      @unique
  name            String?
  email           String?     @unique
  emailVerified   DateTime?
  image           String?

  Post            Post[]
  Comment         Comment[]
  Like            Like[]
Yusuf Akgül's avatar
Yusuf Akgül committed
}

model Post {
Omar Kasbah's avatar
Omar Kasbah committed
  id              String    @id @default(dbgenerated()) @db.Uuid
  createdAt       DateTime  @default(now())
  updatedAt       DateTime  @updatedAt
  content         String
  likeCount       Int?      @default(0)
  gameId          String?
  published       Boolean   @default(false)
  userId          String    @db.Uuid

  user            User      @relation(fields: [userId], references: [id], onDelete: Cascade)
  Comment         Comment[]
  Like            Like[]
Yusuf Akgül's avatar
Yusuf Akgül committed
}
Omar Kasbah's avatar
Omar Kasbah committed
  id        String @id @default(dbgenerated()) @db.Uuid
  postId    String @db.Uuid
  userId    String @db.Uuid

  post      Post   @relation(fields: [postId], references: [id], onDelete: Cascade)
  user      User   @relation(fields: [userId], references: [id], onDelete: Cascade)
Yusuf Akgül's avatar
Yusuf Akgül committed
}

model Comment {
Omar Kasbah's avatar
Omar Kasbah committed
  id        String   @id @default(dbgenerated()) @db.Uuid
Yusuf Akgül's avatar
Yusuf Akgül committed
  message   String
Omar Kasbah's avatar
Omar Kasbah committed
  postId    String   @db.Uuid
  userId    String   @db.Uuid
Yusuf Akgül's avatar
Yusuf Akgül committed
  createdAt DateTime @default(now())
  post      Post     @relation(fields: [postId], references: [id], onDelete: Cascade)
Omar Kasbah's avatar
Omar Kasbah committed
  user      User     @relation(fields: [userId], references: [id], onDelete: Cascade)
Yusuf Akgül's avatar
Yusuf Akgül committed
}