Testing things out
This commit is contained in:
24
prisma/migrations/20240914203650_auth/migration.sql
Normal file
24
prisma/migrations/20240914203650_auth/migration.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "UserAuth" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"providerId" INTEGER NOT NULL,
|
||||
"value" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "UserAuth_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "AuthProvider" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"providerValue" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "AuthProvider_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UserAuth" ADD CONSTRAINT "UserAuth_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UserAuth" ADD CONSTRAINT "UserAuth_providerId_fkey" FOREIGN KEY ("providerId") REFERENCES "AuthProvider"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `email` to the `User` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "email" TEXT NOT NULL;
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[providerId,value]` on the table `UserAuth` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "UserAuth_providerId_value_key" ON "UserAuth"("providerId", "value");
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[providerValue]` on the table `AuthProvider` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "AuthProvider_providerValue_key" ON "AuthProvider"("providerValue");
|
||||
@@ -2,130 +2,135 @@
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid(7))
|
||||
name String
|
||||
created DateTime @default(now())
|
||||
userRoles UserRole[]
|
||||
auth UserAuth[]
|
||||
tournamntsAdministrating Tournament[] @relation("admins")
|
||||
tournamentsModerating Tournament[] @relation("moderators")
|
||||
Tournament Tournament[]
|
||||
Player Player[]
|
||||
id String @id @default(uuid(7))
|
||||
name String
|
||||
email String
|
||||
created DateTime @default(now())
|
||||
userRoles UserRole[]
|
||||
auth UserAuth[]
|
||||
tournamntsAdministrating Tournament[] @relation("admins")
|
||||
tournamentsModerating Tournament[] @relation("moderators")
|
||||
Tournament Tournament[]
|
||||
Player Player[]
|
||||
}
|
||||
|
||||
model UserAuth {
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
provider AuthProvider @relation(fields: [providerId], references: [id])
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
provider AuthProvider @relation(fields: [providerId], references: [id])
|
||||
providerId Int
|
||||
value String
|
||||
value String
|
||||
|
||||
@@unique(name: "providerIdAuthValue", [providerId, value])
|
||||
}
|
||||
|
||||
model AuthProvider {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
providerValue String
|
||||
userAuth UserAuth[]
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
providerValue String @unique
|
||||
userAuth UserAuth[]
|
||||
}
|
||||
|
||||
model UserRole {
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
role Role @relation(fields: [roleId], references: [id])
|
||||
roleId Int
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
role Role @relation(fields: [roleId], references: [id])
|
||||
roleId Int
|
||||
|
||||
@@id([userId, roleId])
|
||||
@@id([userId, roleId])
|
||||
}
|
||||
|
||||
model Role {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
userRoles UserRole[]
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
userRoles UserRole[]
|
||||
}
|
||||
|
||||
model Tournament {
|
||||
id String @id @default(uuid(7))
|
||||
name String
|
||||
slug String?
|
||||
creator User @relation(fields: [creatorUserId], references: [id])
|
||||
creatorUserId String
|
||||
created DateTime @default(now())
|
||||
admins User[] @relation("admins")
|
||||
moderators User[] @relation("moderators")
|
||||
events Event[]
|
||||
id String @id @default(uuid(7))
|
||||
name String
|
||||
slug String?
|
||||
creator User @relation(fields: [creatorUserId], references: [id])
|
||||
creatorUserId String
|
||||
created DateTime @default(now())
|
||||
admins User[] @relation("admins")
|
||||
moderators User[] @relation("moderators")
|
||||
events Event[]
|
||||
}
|
||||
|
||||
model Event {
|
||||
id String @id @default(uuid(7))
|
||||
game Game @relation(fields: [gameId], references: [id])
|
||||
gameId Int
|
||||
entrants EventPlayer[]
|
||||
title String
|
||||
phases Phase[]
|
||||
tournament Tournament @relation(fields: [tournamentId], references: [id])
|
||||
tournamentId String
|
||||
created DateTime @default(now())
|
||||
id String @id @default(uuid(7))
|
||||
game Game @relation(fields: [gameId], references: [id])
|
||||
gameId Int
|
||||
entrants EventPlayer[]
|
||||
title String
|
||||
phases Phase[]
|
||||
tournament Tournament @relation(fields: [tournamentId], references: [id])
|
||||
tournamentId String
|
||||
created DateTime @default(now())
|
||||
}
|
||||
|
||||
enum PhaseType {
|
||||
DOUBLE_ELIM
|
||||
SINGLE_ELIM
|
||||
ROUND_ROBIN
|
||||
DOUBLE_ELIM
|
||||
SINGLE_ELIM
|
||||
ROUND_ROBIN
|
||||
}
|
||||
|
||||
model Phase {
|
||||
id String @id @default(uuid(7))
|
||||
name String
|
||||
type PhaseType
|
||||
bracketCount Int
|
||||
phaseWinnerCount Int
|
||||
event Event @relation(fields: [eventId], references: [id])
|
||||
eventId String
|
||||
created DateTime @default(now())
|
||||
brackets Bracket[]
|
||||
id String @id @default(uuid(7))
|
||||
name String
|
||||
type PhaseType
|
||||
bracketCount Int
|
||||
phaseWinnerCount Int
|
||||
event Event @relation(fields: [eventId], references: [id])
|
||||
eventId String
|
||||
created DateTime @default(now())
|
||||
brackets Bracket[]
|
||||
}
|
||||
|
||||
model Bracket {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
created DateTime @default(now())
|
||||
Phase Phase? @relation(fields: [phaseId], references: [id])
|
||||
phaseId String?
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
created DateTime @default(now())
|
||||
Phase Phase? @relation(fields: [phaseId], references: [id])
|
||||
phaseId String?
|
||||
}
|
||||
|
||||
model Player {
|
||||
id Int @id @default(autoincrement())
|
||||
name String?
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
created DateTime @default(now())
|
||||
userConfirmed Boolean @default(false)
|
||||
EventPlayer EventPlayer[]
|
||||
id Int @id @default(autoincrement())
|
||||
name String?
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
created DateTime @default(now())
|
||||
userConfirmed Boolean @default(false)
|
||||
EventPlayer EventPlayer[]
|
||||
}
|
||||
|
||||
model EventPlayer {
|
||||
event Event @relation(fields: [eventId], references: [id])
|
||||
eventId String
|
||||
player Player @relation(fields: [playerId], references: [id])
|
||||
playerId Int
|
||||
seed Int
|
||||
manuallySeeded Boolean @default(false)
|
||||
event Event @relation(fields: [eventId], references: [id])
|
||||
eventId String
|
||||
player Player @relation(fields: [playerId], references: [id])
|
||||
playerId Int
|
||||
seed Int
|
||||
manuallySeeded Boolean @default(false)
|
||||
|
||||
@@id([eventId, playerId])
|
||||
@@id([eventId, playerId])
|
||||
}
|
||||
|
||||
model Game {
|
||||
id Int @id @default(autoincrement())
|
||||
title String
|
||||
slug String?
|
||||
created DateTime @default(now())
|
||||
Event Event[]
|
||||
id Int @id @default(autoincrement())
|
||||
title String
|
||||
slug String?
|
||||
created DateTime @default(now())
|
||||
Event Event[]
|
||||
}
|
||||
|
||||
0
prisma/seed.ts
Normal file
0
prisma/seed.ts
Normal file
Reference in New Issue
Block a user