aboutsummaryrefslogtreecommitdiffstats
path: root/backend/schema.prisma
blob: 3dda29d87c11b8cf1de80de0a2677f12ef93c708 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id       Int       @id @default(autoincrement())
  username String    @unique
  password String
  salt     String
  email    String    @unique
  sessions Session[]
  scores Score[]
  isAdmin Boolean
}

model Session {
  id        String   @id @default(cuid())
  userId    Int
  user      User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  createdAt DateTime @default(now())
  expiresAt DateTime
}

model Game {
  internalName   String  @id
  formattedName  String  @unique
  description    String
  scores Score[]
  charts Charts[]
}

model Score {
  id               Int     @id @default(autoincrement()) // This is the numerical score number (global)
  gameInternalName String
  chartId          String // Refers to the unqiue chart identifier
  userId           Int
  timestamp        BigInt // in UNIX milliseconds
  data             Json
  game   Game   @relation(fields: [gameInternalName], references: [internalName])
  user   User   @relation(fields: [userId], references: [id])
  chart  Charts @relation(fields: [chartId], references: [chartId])
}

model Charts {
  chartId          String  @id // platform-wide unique hash
  gameInternalName String
  title        String
  artist           String
  game   Game   @relation(fields: [gameInternalName], references: [internalName])
  scores Score[]
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage