diff --git a/migrations/20240731095652_add_new_tables/migration.sql b/migrations/20240731095652_add_new_tables/migration.sql new file mode 100644 index 0000000..7279071 --- /dev/null +++ b/migrations/20240731095652_add_new_tables/migration.sql @@ -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 +); diff --git a/schema.prisma b/schema.prisma index 8e01816..30f2e3c 100644 --- a/schema.prisma +++ b/schema.prisma @@ -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]) +} \ No newline at end of file