From 08b20fdd272d524493fc9afb1b1a38912e8ccc5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Yusuf=20Akg=C3=BCl?= <s86116@bht-berlin.de>
Date: Tue, 30 May 2023 16:01:14 +0200
Subject: [PATCH] changed schema

---
 prisma/schema.prisma | 55 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 14 deletions(-)

diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 36c37ac..c3d6ef5 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -6,25 +6,52 @@ generator client {
 }
 
 datasource db {
-  provider = "sqlite"
+  provider = "postgresql"
   url      = env("DATABASE_URL")
 }
 
-model Message {
-  id        Int       @id @default(autoincrement())
-  author    String?
-  gameId    String?
-  title     String?
+model User {
+  id            String    @id @default(cuid())
+  userName      String    @unique
+  name          String?
+  email         String?   @unique
+  emailVerified DateTime?
+  image         String?
+  Post          Post[]
+  Comment       Comment[]
+  Like          Like[]
+}
+
+model Post {
+  id        String   @id @default(dbgenerated()) @db.Uuid
+  createdAt DateTime @default(now())
+  updatedAt DateTime @updatedAt
+
   content   String
-  likeCount Int?      @default(0)
-  sentAt    DateTime? @default(now())
-  updatedAt DateTime? @updatedAt
+  likeCount Int?    @default(0)
+  gameId    String?
+
+  published Boolean   @default(false)
+  userId    String
+  user      User      @relation(fields: [userId], references: [id])
+  Comment   Comment[]
+  Like      Like[]
 }
 
 model Like {
-  id      Int       @id @default(autoincrement())
-  postId  Int
-  author  String?
-  gameId  String?
-  likedAt DateTime? @default(now())
+  id     String @id @default(dbgenerated()) @db.Uuid
+  postId String
+  userId String
+  post   Post   @relation(fields: [postId], references: [id], onDelete: Cascade)
+  user   User   @relation(fields: [userId], references: [id], onDelete: Cascade)
+}
+
+model Comment {
+  id        String   @id @default(cuid())
+  message   String
+  postId    String
+  userId    String
+  createdAt DateTime @default(now())
+  post      Post     @relation(fields: [postId], references: [id], onDelete: Cascade)
+  user      User     @relation(fields: [userId], references: [id])
 }
-- 
GitLab