Skip to content

Commit

Permalink
Added Games, Games_stats db models
Browse files Browse the repository at this point in the history
  • Loading branch information
PlutoniumSoup committed Jul 31, 2024
1 parent 04e9303 commit 03d09e8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
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
);
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 {
game_id Int @id @default(autoincrement())
start_time String
end_time String
end_reason String
game_stats Game_stats[]
}

model Game_stats {
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])
}

0 comments on commit 03d09e8

Please sign in to comment.