Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added Games, Games_stats db models #18

Merged
merged 6 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- CreateTable
CREATE TABLE "Game" (
"game_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"start_time" TEXT NOT NULL,
"end_time" TEXT NOT NULL,
"end_reason" TEXT NOT NULL
);

-- CreateTable
CREATE TABLE "GameStats" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"game_id" INTEGER NOT NULL,
"player_id" INTEGER NOT NULL,
"size" REAL NOT NULL,
"num_eaten" INTEGER NOT NULL,
"num_ate" INTEGER NOT NULL,
CONSTRAINT "GameStats_game_id_fkey" FOREIGN KEY ("game_id") REFERENCES "Game" ("game_id") ON DELETE RESTRICT ON UPDATE CASCADE
);
18 changes: 18 additions & 0 deletions schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,21 @@ model User {
password String
username String @unique
}

model Game {
game_id Int @id @default(autoincrement())
start_time String
end_time String
end_reason String
game_stats GameStats[]
}

model GameStats {
id Int @id @default(autoincrement())
game_id Int
player_id Int
size Float
num_eaten Int
num_ate Int
games Game @relation(fields: [game_id], references: [game_id])
}