feat: projects, api, viewer, settings

This commit is contained in:
2024-12-15 20:19:49 +01:00
parent 12036ff5e1
commit d11218b1cd
33 changed files with 1520 additions and 491 deletions

View File

@@ -0,0 +1,13 @@
-- CreateTable
CREATE TABLE "Project" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT NOT NULL,
"githubUrl" TEXT NOT NULL,
"userId" TEXT NOT NULL,
CONSTRAINT "Project_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Project" ADD CONSTRAINT "Project_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the column `githubUrl` on the `Project` table. All the data in the column will be lost.
- Added the required column `github` to the `Project` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Project" DROP COLUMN "githubUrl",
ADD COLUMN "github" TEXT NOT NULL;

View File

@@ -0,0 +1,12 @@
/*
Warnings:
- The primary key for the `Project` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The `id` column on the `Project` table would be dropped and recreated. This will lead to data loss if there is data in the column.
*/
-- AlterTable
ALTER TABLE "Project" DROP CONSTRAINT "Project_pkey",
DROP COLUMN "id",
ADD COLUMN "id" SERIAL NOT NULL,
ADD CONSTRAINT "Project_pkey" PRIMARY KEY ("id");

View File

@@ -0,0 +1,26 @@
/*
Warnings:
- The primary key for the `Project` table will be changed. If it partially fails, the table could be left without primary key constraint.
*/
-- AlterTable
ALTER TABLE "Project" DROP CONSTRAINT "Project_pkey",
ADD COLUMN "customData" TEXT[],
ALTER COLUMN "id" DROP DEFAULT,
ALTER COLUMN "id" SET DATA TYPE TEXT,
ADD CONSTRAINT "Project_pkey" PRIMARY KEY ("id");
DROP SEQUENCE "Project_id_seq";
-- CreateTable
CREATE TABLE "Feedback" (
"id" SERIAL NOT NULL,
"message" TEXT NOT NULL,
"customData" TEXT NOT NULL,
"projectId" TEXT NOT NULL,
CONSTRAINT "Feedback_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Feedback" ADD CONSTRAINT "Feedback_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Project" ADD COLUMN "rateLimitReq" INTEGER NOT NULL DEFAULT 5,
ADD COLUMN "rateLimitTime" INTEGER NOT NULL DEFAULT 60;

View File

@@ -17,6 +17,7 @@ model User {
id String @id @default(cuid())
githubId String @unique
username String
projects Project[]
sessions Session[]
}
@@ -25,4 +26,27 @@ model Session {
userId String
expiresAt DateTime
user User @relation(references: [id], fields: [userId], onDelete: Cascade)
}
}
model Project {
id String @id @default(cuid())
name String
description String
github String
customData String[]
rateLimitReq Int @default(5)
rateLimitTime Int @default(60)
userId String
user User @relation(fields: [userId], references: [id])
feedback Feedback[]
}
model Feedback {
id Int @id @default(autoincrement())
message String
customData String
projectId String
project Project @relation(fields: [projectId], references: [id])
}