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 1 commit
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
18 changes: 18 additions & 0 deletions migrations/20240731095652_add_new_tables/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- CreateTable
CREATE TABLE "Games" (
"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 "Game_stats" (
"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 "Game_stats_game_id_fkey" FOREIGN KEY ("game_id") REFERENCES "Games" ("game_id") ON DELETE RESTRICT ON UPDATE CASCADE
);
yurijmikhalevich marked this conversation as resolved.
Show resolved Hide resolved
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 Games {
PlutoniumSoup marked this conversation as resolved.
Show resolved Hide resolved
game_id Int @id @default(autoincrement())
start_time String
end_time String
end_reason String
game_stats Game_stats[]
}

model Game_stats {
PlutoniumSoup marked this conversation as resolved.
Show resolved Hide resolved
id Int @id @default(autoincrement())
game_id Int
player_id Int
size Float
num_eaten Int
num_ate Int
games Games @relation(fields: [game_id], references: [game_id])
yurijmikhalevich marked this conversation as resolved.
Show resolved Hide resolved
}