wip: clerk auth

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-07 11:59:40 +01:00
parent bd62127451
commit a9cbff2306
46 changed files with 611 additions and 816 deletions

View File

@@ -0,0 +1,17 @@
/*
Warnings:
- You are about to drop the `users` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "recent_dashboards" DROP CONSTRAINT "recent_dashboards_user_id_fkey";
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_organization_id_fkey";
-- AlterTable
ALTER TABLE "recent_dashboards" ALTER COLUMN "user_id" SET DATA TYPE TEXT;
-- DropTable
DROP TABLE "users";

View File

@@ -0,0 +1,39 @@
/*
Warnings:
- You are about to drop the column `organization_id` on the `clients` table. All the data in the column will be lost.
- You are about to drop the column `organization_id` on the `projects` table. All the data in the column will be lost.
- You are about to drop the column `organization_id` on the `recent_dashboards` table. All the data in the column will be lost.
- You are about to drop the `invites` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `organizations` table. If the table is not empty, all the data it contains will be lost.
- Added the required column `organization_slug` to the `clients` table without a default value. This is not possible if the table is not empty.
- Added the required column `organization_slug` to the `projects` table without a default value. This is not possible if the table is not empty.
- Added the required column `organization_slug` to the `recent_dashboards` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "clients" DROP CONSTRAINT "clients_organization_id_fkey";
-- DropForeignKey
ALTER TABLE "invites" DROP CONSTRAINT "invites_organization_id_fkey";
-- DropForeignKey
ALTER TABLE "projects" DROP CONSTRAINT "projects_organization_id_fkey";
-- AlterTable
ALTER TABLE "clients" DROP COLUMN "organization_id",
ADD COLUMN "organization_slug" TEXT NOT NULL;
-- AlterTable
ALTER TABLE "projects" DROP COLUMN "organization_id",
ADD COLUMN "organization_slug" TEXT NOT NULL;
-- AlterTable
ALTER TABLE "recent_dashboards" DROP COLUMN "organization_id",
ADD COLUMN "organization_slug" TEXT NOT NULL;
-- DropTable
DROP TABLE "invites";
-- DropTable
DROP TABLE "organizations";

View File

@@ -10,29 +10,14 @@ datasource db {
url = env("DATABASE_URL")
}
model Organization {
id String @id @default(dbgenerated("gen_random_uuid()"))
name String
projects Project[]
users User[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
clients Client[]
Invite Invite[]
@@map("organizations")
}
model Project {
id String @id @default(dbgenerated("gen_random_uuid()"))
name String
organization_id String
organization Organization @relation(fields: [organization_id], references: [id])
events Event[]
eventsCount Int @default(0)
profiles Profile[]
clients Client[]
id String @id @default(dbgenerated("gen_random_uuid()"))
name String
organization_slug String
events Event[]
eventsCount Int @default(0)
profiles Profile[]
clients Client[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@ -43,21 +28,6 @@ model Project {
@@map("projects")
}
model User {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
email String
password String
organization_id String
organization Organization @relation(fields: [organization_id], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
RecentDashboards RecentDashboards[]
@@map("users")
}
model Event {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
@@ -107,14 +77,13 @@ model EventFailed {
}
model Client {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
secret String?
project_id String
project Project @relation(fields: [project_id], references: [id])
organization_id String
organization Organization @relation(fields: [organization_id], references: [id])
cors String @default("*")
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
secret String?
project_id String
project Project @relation(fields: [project_id], references: [id])
organization_slug String
cors String @default("*")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@ -123,15 +92,14 @@ model Client {
}
model RecentDashboards {
id String @id @default(dbgenerated("gen_random_uuid()"))
project_id String
project Project @relation(fields: [project_id], references: [id])
organization_id String
dashboard_id String
dashboard Dashboard @relation(fields: [dashboard_id], references: [id])
user_id String @db.Uuid
user User @relation(fields: [user_id], references: [id])
createdAt DateTime @default(now())
id String @id @default(dbgenerated("gen_random_uuid()"))
project_id String
project Project @relation(fields: [project_id], references: [id])
organization_slug String
dashboard_id String
dashboard Dashboard @relation(fields: [dashboard_id], references: [id])
user_id String
createdAt DateTime @default(now())
@@map("recent_dashboards")
}
@@ -198,20 +166,6 @@ model Report {
@@map("reports")
}
model Invite {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String
organization_id String
organization Organization @relation(fields: [organization_id], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
accepted Boolean @default(false)
@@map("invites")
}
model Waitlist {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String @unique