Ajouts des models avec schema.prisma

This commit is contained in:
Bilal Dieumegard 2024-11-27 18:10:49 +01:00
parent 431c77f970
commit 1f5342998b

49
prisma/schema.prisma Normal file
View file

@ -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
}