mirror of
https://github.com/detleph/server.git
synced 2026-09-04 08:36:06 +02:00
Update the main Prisma schema
- Added two distinct IDs (A private, serial PK and a public, UUIDv4-based, API ID) - Added default values - Applied some basic formatting (Field names, ...)
This commit is contained in:
+54
-40
@@ -1,5 +1,4 @@
|
|||||||
// This is your Prisma schema file,
|
// Schema for the main database
|
||||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "postgresql"
|
provider = "postgresql"
|
||||||
@@ -11,8 +10,10 @@ generator client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Event {
|
model Event {
|
||||||
id Int @id
|
id Int @id @default(autoincrement()) // Primary key
|
||||||
date DateTime
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid // Public key
|
||||||
|
date DateTime
|
||||||
|
|
||||||
disciplines Discipline[]
|
disciplines Discipline[]
|
||||||
admins Admin[]
|
admins Admin[]
|
||||||
organisations Oragnisation[]
|
organisations Oragnisation[]
|
||||||
@@ -20,66 +21,79 @@ model Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Admin {
|
model Admin {
|
||||||
id Int @id
|
id Int @id @default(autoincrement())
|
||||||
name String
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
password String
|
name String
|
||||||
level Int
|
password String // TODO: Probably specify hash size (VarChar or some other type)
|
||||||
event Event @relation(fields: [eventId], references: [id])
|
permission_level Int // TODO: Maybe extract into an enum
|
||||||
eventId Int
|
|
||||||
|
event Event @relation(fields: [eventId], references: [id])
|
||||||
|
eventId Int
|
||||||
}
|
}
|
||||||
|
|
||||||
model Campaign {
|
model Campaign {
|
||||||
id Int @id
|
id Int @id @default(autoincrement())
|
||||||
ends DateTime
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
limit Int @default(40)
|
expiresAt DateTime
|
||||||
curr Int @default(0)
|
user_limit Int @default(40)
|
||||||
links String[]
|
user_number Int @default(0)
|
||||||
group Group @relation(fields: [groupId], references: [id])
|
links String[]
|
||||||
Event Event @relation(fields: [eventId], references: [id])
|
|
||||||
eventId Int
|
group Group @relation(fields: [groupId], references: [id])
|
||||||
groupId Int
|
groupId Int
|
||||||
|
event Event @relation(fields: [eventId], references: [id])
|
||||||
|
eventId Int
|
||||||
}
|
}
|
||||||
|
|
||||||
model Discipline {
|
model Discipline {
|
||||||
id Int @id
|
id Int @id @default(autoincrement())
|
||||||
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
name String
|
name String
|
||||||
minteamsize Int
|
minTeamSize Int @default(1)
|
||||||
maxteamsize Int
|
maxTeamSize Int @default(1)
|
||||||
event Event @relation(fields: [eventId], references: [id])
|
|
||||||
eventId Int
|
teams Team[]
|
||||||
teams Teams[]
|
event Event @relation(fields: [eventId], references: [id])
|
||||||
|
eventId Int
|
||||||
}
|
}
|
||||||
|
|
||||||
model Teams {
|
model Team {
|
||||||
id Int @id
|
id Int @id @default(autoincrement())
|
||||||
name String
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
startdate DateTime
|
name String
|
||||||
|
|
||||||
participants Participant[]
|
participants Participant[]
|
||||||
discipline Discipline @relation(fields: [disciplineId], references: [id])
|
discipline Discipline @relation(fields: [disciplineId], references: [id])
|
||||||
disciplineId Int
|
disciplineId Int
|
||||||
}
|
}
|
||||||
|
|
||||||
model Participant {
|
model Participant {
|
||||||
id Int @id
|
id Int @id @default(autoincrement())
|
||||||
firstname String
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
lastname String
|
firstName String
|
||||||
|
lastName String
|
||||||
email String
|
email String
|
||||||
teams Teams @relation(fields: [teamsId], references: [id])
|
|
||||||
teamsId Int
|
team Team @relation(fields: [teamId], references: [id])
|
||||||
|
teamId Int
|
||||||
}
|
}
|
||||||
|
|
||||||
model Oragnisation {
|
model Oragnisation {
|
||||||
id Int @id
|
id Int @id @default(autoincrement())
|
||||||
name String
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
|
name String
|
||||||
|
|
||||||
groups Group[]
|
groups Group[]
|
||||||
Event Event @relation(fields: [eventId], references: [id])
|
event Event @relation(fields: [eventId], references: [id])
|
||||||
eventId Int
|
eventId Int
|
||||||
}
|
}
|
||||||
|
|
||||||
model Group {
|
model Group {
|
||||||
id Int @id
|
id Int @id @default(autoincrement())
|
||||||
name String
|
pid String @unique @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
Oragnisation Oragnisation @relation(fields: [oragnisationId], references: [id])
|
name String
|
||||||
|
|
||||||
|
oragnisation Oragnisation @relation(fields: [oragnisationId], references: [id])
|
||||||
oragnisationId Int
|
oragnisationId Int
|
||||||
Campaign Campaign[]
|
campaign Campaign[]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user