From 1f5342998b8fce7c5c365eb65b29da86bec0524d Mon Sep 17 00:00:00 2001 From: Bilal Dieumegard Date: Wed, 27 Nov 2024 18:10:49 +0100 Subject: [PATCH] Ajouts des models avec schema.prisma --- prisma/schema.prisma | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 prisma/schema.prisma diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..e3ef7ec --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,49 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? +// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +model User { + id Int @id @default(autoincrement()) + pseudo String @unique + nom String + prenom String + email String @unique + password String + canaux Canal[] @relation("UserCanaux") + messages Message[] + + @@map("users") // Table name in DB +} + +model Canal { + id Int @id @default(autoincrement()) + nom String + domaine String + users User[] @relation("UserCanaux") + messages Message[] + + @@map("canaux") // Table name in DB +} + +model Message { + id Int @id @default(autoincrement()) + user User @relation(fields: [userId], references: [id]) + userId Int + canal Canal @relation(fields: [canalId], references: [id]) + canalId Int + text String + createdAt DateTime @default(now()) + + @@map("messages") // Table name in DB +}