mirror of
https://github.com/detleph/server.git
synced 2026-09-04 23:45:00 +02:00
146 lines
3.8 KiB
Plaintext
146 lines
3.8 KiB
Plaintext
// Schema for the main database
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
model Event {
|
|
id Int @id @default(autoincrement()) // Primary key
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid // Public key
|
|
date DateTime
|
|
name String
|
|
description String
|
|
|
|
disciplines Discipline[]
|
|
admins Admin[]
|
|
organisations Organisation[]
|
|
campaign Campaign[]
|
|
}
|
|
|
|
model Campaign {
|
|
id Int @id @default(autoincrement())
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
start DateTime
|
|
expiresAt DateTime
|
|
|
|
links Link[]
|
|
event Event @relation(fields: [eventId], references: [id])
|
|
eventId Int @unique
|
|
}
|
|
|
|
model Link {
|
|
id Int @id @default(autoincrement())
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
link String
|
|
|
|
campaign Campaign @relation(fields: [campaignId], references: [id])
|
|
campaignId Int
|
|
group Group? @relation(fields: [groupId], references: [id])
|
|
groupId Int @unique
|
|
}
|
|
|
|
model Admin {
|
|
id Int @id @default(autoincrement())
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
name String
|
|
password String // TODO: Probably specify hash size (VarChar or some other type)
|
|
permission_level AdminLevel @default(STANDARD)
|
|
revision String
|
|
groups Group[]
|
|
|
|
event Event @relation(fields: [eventId], references: [id])
|
|
eventId Int
|
|
}
|
|
|
|
model Discipline {
|
|
id Int @id @default(autoincrement())
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
name String
|
|
minTeamSize Int
|
|
maxTeamSize Int
|
|
roles Role[]
|
|
|
|
teams Team[]
|
|
event Event @relation(fields: [eventId], references: [id])
|
|
eventId Int
|
|
}
|
|
|
|
model Role {
|
|
id Int @id @default(autoincrement())
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
name String
|
|
schema Json
|
|
|
|
participant Participant[]
|
|
discipline Discipline @relation(fields: [disciplineId], references: [id])
|
|
disciplineId Int
|
|
}
|
|
|
|
model Team {
|
|
id Int @id @default(autoincrement())
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
name String
|
|
|
|
participants Participant[] @relation(name: "participants")
|
|
discipline Discipline @relation(fields: [disciplineId], references: [id])
|
|
disciplineId Int
|
|
leader Participant? @relation(name: "leader", fields: [leaderId], references: [id])
|
|
leaderId Int @unique
|
|
}
|
|
|
|
model Participant {
|
|
id Int @id @default(autoincrement())
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
firstName String
|
|
lastName String
|
|
email String
|
|
gender Gender
|
|
|
|
group Group @relation(fields: [groupId], references: [id])
|
|
groupId Int
|
|
team Team @relation(name: "participants", fields: [teamId], references: [id])
|
|
teamId Int
|
|
leaderOf Team? @relation(name: "leader")
|
|
roles Role[]
|
|
|
|
}
|
|
|
|
model Organisation {
|
|
id Int @id @default(autoincrement())
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
name String
|
|
|
|
groups Group[]
|
|
event Event @relation(fields: [eventId], references: [id])
|
|
eventId Int
|
|
}
|
|
|
|
model Group {
|
|
id Int @id @default(autoincrement())
|
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
name String
|
|
user_limit Int @default(40)
|
|
level Int
|
|
|
|
oragnisation Organisation @relation(fields: [oragnisationId], references: [id])
|
|
oragnisationId Int
|
|
participants Participant[]
|
|
link Link?
|
|
admins Admin[]
|
|
}
|
|
|
|
enum AdminLevel {
|
|
STANDARD
|
|
ELEVATED
|
|
}
|
|
|
|
enum Gender {
|
|
MALE
|
|
FEMALE
|
|
OTHER
|
|
} |