web: added the base for the web project

This commit is contained in:
Carl-Gerhard Lindesvärd
2023-10-26 20:53:11 +02:00
parent 15e29edaa7
commit 8a87fff689
107 changed files with 3607 additions and 512 deletions

View File

@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "clients" ADD COLUMN "organization_id" UUID;
-- AddForeignKey
ALTER TABLE "clients" ADD CONSTRAINT "clients_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "organizations"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@@ -0,0 +1,14 @@
/*
Warnings:
- Made the column `organization_id` on table `clients` required. This step will fail if there are existing NULL values in that column.
*/
-- DropForeignKey
ALTER TABLE "clients" DROP CONSTRAINT "clients_organization_id_fkey";
-- AlterTable
ALTER TABLE "clients" ALTER COLUMN "organization_id" SET NOT NULL;
-- AddForeignKey
ALTER TABLE "clients" ADD CONSTRAINT "clients_organization_id_fkey" FOREIGN KEY ("organization_id") REFERENCES "organizations"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@@ -0,0 +1,25 @@
/*
Warnings:
- A unique constraint covering the columns `[slug]` on the table `dashboards` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[slug]` on the table `organizations` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[slug]` on the table `projects` will be added. If there are existing duplicate values, this will fail.
*/
-- AlterTable
ALTER TABLE "dashboards" ADD COLUMN "slug" TEXT NOT NULL DEFAULT gen_random_uuid();
-- AlterTable
ALTER TABLE "organizations" ADD COLUMN "slug" TEXT NOT NULL DEFAULT gen_random_uuid();
-- AlterTable
ALTER TABLE "projects" ADD COLUMN "slug" TEXT NOT NULL DEFAULT gen_random_uuid();
-- CreateIndex
CREATE UNIQUE INDEX "dashboards_slug_key" ON "dashboards"("slug");
-- CreateIndex
CREATE UNIQUE INDEX "organizations_slug_key" ON "organizations"("slug");
-- CreateIndex
CREATE UNIQUE INDEX "projects_slug_key" ON "projects"("slug");

View File

@@ -13,11 +13,13 @@ datasource db {
model Organization {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
slug String @unique @default(dbgenerated("gen_random_uuid()"))
projects Project[]
users User[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
clients Client[]
@@map("organizations")
}
@@ -25,6 +27,7 @@ model Organization {
model Project {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
slug String @unique @default(dbgenerated("gen_random_uuid()"))
organization_id String @db.Uuid
organization Organization @relation(fields: [organization_id], references: [id])
events Event[]
@@ -88,11 +91,13 @@ model Profile {
}
model Client {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
secret String
project_id String @db.Uuid
project Project @relation(fields: [project_id], references: [id])
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
secret String
project_id String @db.Uuid
project Project @relation(fields: [project_id], references: [id])
organization_id String @db.Uuid
organization Organization @relation(fields: [organization_id], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@ -117,6 +122,7 @@ enum ChartType {
model Dashboard {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
slug String @unique @default(dbgenerated("gen_random_uuid()"))
project_id String @db.Uuid
project Project @relation(fields: [project_id], references: [id])
reports Report[]