NeahNew/prisma/schema.prisma
2025-05-06 15:36:15 +02:00

181 lines
5.4 KiB
Plaintext

// 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"
binaryTargets = ["native", "linux-arm64-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(uuid())
email String @unique
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
calendars Calendar[]
events Event[]
mailCredentials MailCredentials[]
webdavCredentials WebDAVCredentials?
announcements Announcement[]
missions Mission[]
missionUsers MissionUser[]
uploadedAttachments Attachment[]
}
model Calendar {
id String @id @default(uuid())
name String
color String @default("#0082c9")
description String?
userId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
events Event[]
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
}
model Event {
id String @id @default(uuid())
title String
description String?
start DateTime
end DateTime
location String?
isAllDay Boolean @default(false)
calendar Calendar @relation(fields: [calendarId], references: [id], onDelete: Cascade)
calendarId String
userId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([calendarId])
@@index([userId])
}
model MailCredentials {
id String @id @default(uuid())
userId String
email String
password String? // Make password optional
host String
port Int
secure Boolean @default(true)
// OAuth Settings
use_oauth Boolean @default(false)
refresh_token String?
access_token String?
token_expiry DateTime?
// SMTP Settings
smtp_host String?
smtp_port Int?
smtp_secure Boolean? @default(false)
// Display Settings
display_name String?
color String? @default("#0082c9")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([userId, email])
@@index([userId])
}
model WebDAVCredentials {
id String @id @default(uuid())
userId String @unique
username String
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
}
model Announcement {
id String @id @default(uuid())
title String
content String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
authorId String
targetRoles String[]
@@index([authorId])
}
// Mission models
model Mission {
id String @id @default(uuid())
name String
logo String? // Stores the path to the logo in Minio
oddScope String[] // Categories / ODD scope
niveau String // Project Type / Niveau
intention String // Description / Intention
missionType String // Project location type / Type de mission
donneurDOrdre String // Volunteer Type / Donneur d'ordre
projection String // Duration / Projection
services String[] // Experience / Services
participation String? // Friendly Address / Participation
profils String[] // Level / Profils
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
creator User @relation(fields: [creatorId], references: [id], onDelete: Cascade)
creatorId String
attachments Attachment[]
missionUsers MissionUser[]
// External integration fields
leantimeProjectId String?
outlineCollectionId String?
rocketChatChannelId String?
giteaRepositoryUrl String?
penpotProjectId String?
@@index([creatorId])
}
model Attachment {
id String @id @default(uuid())
filename String // Original filename
filePath String // Path in Minio: user-${userId}/missions/${missionId}/attachments/${filename}
fileType String // MIME type
fileSize Int // Size in bytes
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
mission Mission @relation(fields: [missionId], references: [id], onDelete: Cascade)
missionId String
uploader User @relation(fields: [uploaderId], references: [id], onDelete: Cascade)
uploaderId String
@@index([missionId])
@@index([uploaderId])
}
model MissionUser {
id String @id @default(uuid())
role String // 'gardien-temps', 'gardien-parole', 'gardien-memoire', 'volontaire'
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
mission Mission @relation(fields: [missionId], references: [id], onDelete: Cascade)
missionId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
@@unique([missionId, userId, role])
@@index([missionId])
@@index([userId])
}