This commit is contained in:
2025-07-19 12:21:46 +02:00
parent 12822dfdbf
commit 2e7957d0a0
86 changed files with 25573 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
-- CreateEnum
CREATE TYPE "StageType" AS ENUM ('ROUND_ROBIN', 'SINGLE_ELIM');
-- CreateTable
CREATE TABLE "Player" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"email" TEXT NOT NULL,
"registeredAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Player_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "AdminUser" (
"id" SERIAL NOT NULL,
"username" TEXT NOT NULL,
"passwordHash" TEXT NOT NULL,
CONSTRAINT "AdminUser_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "TournamentStage" (
"id" SERIAL NOT NULL,
"type" "StageType" NOT NULL,
"startedAt" TIMESTAMP(3),
"endedAt" TIMESTAMP(3),
CONSTRAINT "TournamentStage_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Match" (
"id" SERIAL NOT NULL,
"stageId" INTEGER NOT NULL,
"player1Id" INTEGER NOT NULL,
"player2Id" INTEGER NOT NULL,
"scheduledAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Match_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Result" (
"id" SERIAL NOT NULL,
"matchId" INTEGER NOT NULL,
"player1Score" INTEGER NOT NULL,
"player2Score" INTEGER NOT NULL,
"winnerId" INTEGER NOT NULL,
CONSTRAINT "Result_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Player_email_key" ON "Player"("email");
-- CreateIndex
CREATE UNIQUE INDEX "AdminUser_username_key" ON "AdminUser"("username");
-- CreateIndex
CREATE UNIQUE INDEX "Result_matchId_key" ON "Result"("matchId");
-- AddForeignKey
ALTER TABLE "Match" ADD CONSTRAINT "Match_stageId_fkey" FOREIGN KEY ("stageId") REFERENCES "TournamentStage"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Match" ADD CONSTRAINT "Match_player1Id_fkey" FOREIGN KEY ("player1Id") REFERENCES "Player"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Match" ADD CONSTRAINT "Match_player2Id_fkey" FOREIGN KEY ("player2Id") REFERENCES "Player"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Result" ADD CONSTRAINT "Result_matchId_fkey" FOREIGN KEY ("matchId") REFERENCES "Match"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Result" ADD CONSTRAINT "Result_winnerId_fkey" FOREIGN KEY ("winnerId") REFERENCES "Player"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Player" ADD COLUMN "passwordHash" TEXT;

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Player" ADD COLUMN "imageUrl" TEXT;

View File

@@ -0,0 +1,11 @@
/*
Warnings:
- A unique constraint covering the columns `[username]` on the table `Player` will be added. If there are existing duplicate values, this will fail.
*/
-- AlterTable
ALTER TABLE "Player" ADD COLUMN "username" TEXT;
-- CreateIndex
CREATE UNIQUE INDEX "Player_username_key" ON "Player"("username");

View File

@@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the column `email` on the `Player` table. All the data in the column will be lost.
*/
-- DropIndex
DROP INDEX "Player_email_key";
-- AlterTable
ALTER TABLE "Player" DROP COLUMN "email";

View File

@@ -0,0 +1,60 @@
/*
Warnings:
- You are about to drop the column `player1Id` on the `Match` table. All the data in the column will be lost.
- You are about to drop the column `player2Id` on the `Match` table. All the data in the column will be lost.
- You are about to drop the column `player1Score` on the `Result` table. All the data in the column will be lost.
- You are about to drop the column `player2Score` on the `Result` table. All the data in the column will be lost.
- Added the required column `team1Id` to the `Match` table without a default value. This is not possible if the table is not empty.
- Added the required column `team2Id` to the `Match` table without a default value. This is not possible if the table is not empty.
- Added the required column `team1Score` to the `Result` table without a default value. This is not possible if the table is not empty.
- Added the required column `team2Score` to the `Result` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "Match" DROP CONSTRAINT "Match_player1Id_fkey";
-- DropForeignKey
ALTER TABLE "Match" DROP CONSTRAINT "Match_player2Id_fkey";
-- DropForeignKey
ALTER TABLE "Result" DROP CONSTRAINT "Result_winnerId_fkey";
-- AlterTable
ALTER TABLE "Match" DROP COLUMN "player1Id",
DROP COLUMN "player2Id",
ADD COLUMN "team1Id" INTEGER NOT NULL,
ADD COLUMN "team2Id" INTEGER NOT NULL;
-- AlterTable
ALTER TABLE "Player" ADD COLUMN "teamId" INTEGER;
-- AlterTable
ALTER TABLE "Result" DROP COLUMN "player1Score",
DROP COLUMN "player2Score",
ADD COLUMN "team1Score" INTEGER NOT NULL,
ADD COLUMN "team2Score" INTEGER NOT NULL;
-- CreateTable
CREATE TABLE "Team" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"registeredAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Team_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Team_name_key" ON "Team"("name");
-- AddForeignKey
ALTER TABLE "Player" ADD CONSTRAINT "Player_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Match" ADD CONSTRAINT "Match_team1Id_fkey" FOREIGN KEY ("team1Id") REFERENCES "Team"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Match" ADD CONSTRAINT "Match_team2Id_fkey" FOREIGN KEY ("team2Id") REFERENCES "Team"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Result" ADD CONSTRAINT "Result_winnerId_fkey" FOREIGN KEY ("winnerId") REFERENCES "Team"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `pool` to the `Match` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Match" ADD COLUMN "pool" INTEGER NOT NULL;

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "TournamentStage" ADD COLUMN "tier" INTEGER;

View File

@@ -0,0 +1,23 @@
/*
Warnings:
- Added the required column `tournamentId` to the `TournamentStage` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "TournamentStage" ADD COLUMN "tournamentId" INTEGER NOT NULL;
-- CreateTable
CREATE TABLE "Tournament" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"date" TIMESTAMP(3) NOT NULL,
"location" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Tournament_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "TournamentStage" ADD CONSTRAINT "TournamentStage_tournamentId_fkey" FOREIGN KEY ("tournamentId") REFERENCES "Tournament"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Team" ADD COLUMN "logo" TEXT;

View File

@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"