HUB - Admin und Einstellungen Seiten hinzugefügt, Prisma Client Integration und Migrationen aktualisiert

This commit is contained in:
PxlLoewe
2025-02-16 01:09:33 +01:00
parent a4bdc94aa1
commit 62ae71d6b6
28 changed files with 862 additions and 234 deletions

View File

@@ -2,7 +2,8 @@
"name": "@repo/db",
"version": "0.0.0",
"description": "VAR Databse package",
"main": "index.js",
"main": "generated/client/index.js",
"types": "generated/client/index.d.ts",
"scripts": {
"db:generate": "npx prisma generate",
"db:migrate": "npx prisma migrate dev",

View File

@@ -0,0 +1,19 @@
-- CreateTable
CREATE TABLE "discord_accounts" (
"id" SERIAL NOT NULL,
"user_id" TEXT NOT NULL,
"discord_id" TEXT NOT NULL,
"access_token" TEXT NOT NULL,
"refresh_token" TEXT NOT NULL,
"token_type" TEXT NOT NULL,
"scope" TEXT NOT NULL,
"guild_id" TEXT NOT NULL,
"guild_name" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "discord_accounts_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "discord_accounts" ADD CONSTRAINT "discord_accounts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -0,0 +1,13 @@
/*
Warnings:
- You are about to drop the column `guild_id` on the `discord_accounts` table. All the data in the column will be lost.
- You are about to drop the column `guild_name` on the `discord_accounts` table. All the data in the column will be lost.
- You are about to drop the column `scope` on the `discord_accounts` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "discord_accounts" DROP COLUMN "guild_id",
DROP COLUMN "guild_name",
DROP COLUMN "scope",
ADD COLUMN "email" TEXT;

View File

@@ -0,0 +1,14 @@
/*
Warnings:
- Added the required column `global_name` to the `discord_accounts` table without a default value. This is not possible if the table is not empty.
- Added the required column `username` to the `discord_accounts` table without a default value. This is not possible if the table is not empty.
- Made the column `email` on table `discord_accounts` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "discord_accounts" ADD COLUMN "avatar" TEXT,
ADD COLUMN "global_name" TEXT NOT NULL,
ADD COLUMN "username" TEXT NOT NULL,
ADD COLUMN "verified" BOOLEAN NOT NULL DEFAULT false,
ALTER COLUMN "email" SET NOT NULL;

View File

@@ -0,0 +1,8 @@
/*
Warnings:
- A unique constraint covering the columns `[discord_id]` on the table `discord_accounts` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "discord_accounts_discord_id_key" ON "discord_accounts"("discord_id");

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "vatsim_cid" INTEGER;

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "vatsim_cid" SET DATA TYPE TEXT;

View File

@@ -0,0 +1,9 @@
/*
Warnings:
- The `vatsim_cid` column on the `users` table would be dropped and recreated. This will lead to data loss if there is data in the column.
*/
-- AlterTable
ALTER TABLE "users" DROP COLUMN "vatsim_cid",
ADD COLUMN "vatsim_cid" INTEGER;

View File

@@ -1,3 +1,23 @@
model Account {
id Int @id @default(autoincrement())
compoundId String @unique @map(name: "compound_id")
userId Int @map(name: "user_id")
providerType String @map(name: "provider_type")
providerId String @map(name: "provider_id")
providerAccountId String @map(name: "provider_account_id")
refreshToken String? @map(name: "refresh_token")
accessToken String? @map(name: "access_token")
accessTokenExpires DateTime? @map(name: "access_token_expires")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
@@index([providerAccountId], name: "providerAccountId")
@@index([providerId], name: "providerId")
@@index([userId], name: "userId")
@@map(name: "accounts")
}
model Session {
id Int @id @default(autoincrement())
userId Int @map(name: "user_id")
@@ -10,23 +30,6 @@ model Session {
@@map(name: "sessions")
}
model User {
id String @id @default(uuid())
firstname String
lastname String
email String @unique
password String
emailVerified DateTime? @map(name: "email_verified")
image String?
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
// relations:
oauthTokens OAuthToken[]
@@map(name: "users")
}
model VerificationRequest {
id Int @id @default(autoincrement())
identifier String

View File

@@ -1,18 +1,39 @@
model Account {
id Int @id @default(autoincrement())
compoundId String @unique @map(name: "compound_id")
userId Int @map(name: "user_id")
providerType String @map(name: "provider_type")
providerId String @map(name: "provider_id")
providerAccountId String @map(name: "provider_account_id")
refreshToken String? @map(name: "refresh_token")
accessToken String? @map(name: "access_token")
accessTokenExpires DateTime? @map(name: "access_token_expires")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
model User {
id String @id @default(uuid())
firstname String
lastname String
email String @unique
password String
vatsimCid Int? @map(name: "vatsim_cid")
emailVerified DateTime? @map(name: "email_verified")
image String?
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
@@index([providerAccountId], name: "providerAccountId")
@@index([providerId], name: "providerId")
@@index([userId], name: "userId")
@@map(name: "accounts")
// relations:
oauthTokens OAuthToken[]
discordAccounts DiscordAccount[]
@@map(name: "users")
}
model DiscordAccount {
id Int @id @default(autoincrement())
discordId String @unique @map(name: "discord_id")
userId String @map(name: "user_id")
email String @map(name: "email")
username String @map(name: "username")
avatar String? @map(name: "avatar")
globalName String @map(name: "global_name")
verified Boolean @default(false)
accessToken String @map(name: "access_token")
refreshToken String @map(name: "refresh_token")
tokenType String @map(name: "token_type")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
// relations:
user User @relation(fields: [userId], references: [id]) // Beziehung zu User
@@map(name: "discord_accounts")
}