Skip to content

Commit

Permalink
Add prisma and generate schema from the existing database
Browse files Browse the repository at this point in the history
  • Loading branch information
nhamonin committed Dec 15, 2024
1 parent ca2e73a commit 660314c
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 2 deletions.
142 changes: 141 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"type": "module",
"devDependencies": {
"eslint": "^8.23.1",
"prettier": "^2.7.1"
"prettier": "^2.7.1",
"prisma": "^6.0.1"
},
"dependencies": {
"@getvim/execute": "^1.0.0",
Expand Down
80 changes: 80 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
generator client {
provider = "prisma-client-js"
}

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

model match {
match_id String @db.VarChar(255)
player_id String @db.VarChar(255)
elo Int?
timestamp DateTime? @db.Timestamp(6)
kd Float?
kills Int?
hs Int?
map String? @db.VarChar(255)
game_mode String? @db.VarChar(255)
win Int?
score String? @db.VarChar(255)
player player @relation(fields: [player_id], references: [player_id], onDelete: Cascade, onUpdate: NoAction)
@@id([match_id, player_id])
@@unique([match_id, player_id], map: "match_player_id_unique")
}

model match_prediction {
id BigInt @id @default(autoincrement())
totalMatches BigInt? @default(0)
avgPredictions Float? @default(0) @db.Real
winratePredictions Float? @default(0) @db.Real
created_at DateTime @default(now()) @db.Timestamptz(6)
updated_at DateTime @default(now()) @db.Timestamptz(6)
}

model player {
player_id String @id @db.VarChar(255)
nickname String @db.VarChar(255)
elo Int
lvl Int
kd Json @db.Json
avg Json @db.Json
winrate Json @db.Json
hs Json @db.Json
highestElo Int?
highestEloDate DateTime? @db.Date
created_at DateTime @default(now()) @db.Timestamptz(6)
updated_at DateTime @default(now()) @db.Timestamptz(6)
previous_elo Int?
in_match Boolean? @default(false)
match match[]
}

model team {
chat_id BigInt @id
type String @db.VarChar(255)
username String? @db.VarChar(255)
first_name String? @db.VarChar(255)
title String? @db.VarChar(255)
name String? @db.VarChar(255)
settings Json @db.Json
created_at DateTime @default(now()) @db.Timestamptz(6)
updated_at DateTime @default(now()) @db.Timestamptz(6)
team_player team_player[]
}

model team_player {
chat_id BigInt
player_id String @db.VarChar(255)
team team @relation(fields: [chat_id], references: [chat_id], onDelete: Cascade, onUpdate: NoAction, map: "team_player_chat_id_foreign")
@@id([chat_id, player_id])
}

model temp_prediction {
match_id String @id @unique(map: "temp_prediction_match_id_unique") @db.VarChar(255)
predictions Json
created_at DateTime @default(now()) @db.Timestamptz(6)
}

0 comments on commit 660314c

Please sign in to comment.