This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-04 13:23:21 +01:00
parent 30af9cab2f
commit ccd1a1456f
135 changed files with 5588 additions and 1758 deletions

View File

@@ -0,0 +1,17 @@
/*
Warnings:
- The primary key for the `profiles` table will be changed. If it partially fails, the table could be left without primary key constraint.
*/
-- DropForeignKey
ALTER TABLE "events" DROP CONSTRAINT "events_profile_id_fkey";
-- AlterTable
ALTER TABLE "events" ALTER COLUMN "profile_id" SET DATA TYPE TEXT;
-- AlterTable
ALTER TABLE "profiles" DROP CONSTRAINT "profiles_pkey",
ALTER COLUMN "id" DROP DEFAULT,
ALTER COLUMN "id" SET DATA TYPE TEXT,
ADD CONSTRAINT "profiles_pkey" PRIMARY KEY ("id");

View File

@@ -0,0 +1,8 @@
-- CreateTable
CREATE TABLE "salts" (
"salt" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "salts_pkey" PRIMARY KEY ("salt")
);

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "reports" ADD COLUMN "formula" TEXT;

View File

@@ -0,0 +1,6 @@
-- CreateEnum
CREATE TYPE "Metric" AS ENUM ('sum', 'average', 'min', 'max');
-- AlterTable
ALTER TABLE "reports" ADD COLUMN "metric" "Metric" NOT NULL DEFAULT 'sum',
ADD COLUMN "unit" TEXT;

View File

@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "projects" ADD COLUMN "eventsCount" INTEGER NOT NULL DEFAULT 0;

View File

@@ -30,6 +30,7 @@ model Project {
organization_id String
organization Organization @relation(fields: [organization_id], references: [id])
events Event[]
eventsCount Int @default(0)
profiles Profile[]
clients Client[]
@@ -64,8 +65,7 @@ model Event {
project_id String
project Project @relation(fields: [project_id], references: [id])
profile_id String? @db.Uuid
profile Profile? @relation(fields: [profile_id], references: [id])
profile_id String?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@ -73,8 +73,16 @@ model Event {
@@map("events")
}
model Salt {
salt String @id
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@map("salts")
}
model Profile {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
id String @id
external_id String?
first_name String?
last_name String?
@@ -82,11 +90,9 @@ model Profile {
avatar String?
properties Json
project_id String
project Project @relation(fields: [project_id], references: [id])
events Event[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
project Project @relation(fields: [project_id], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
@@map("profiles")
}
@@ -160,6 +166,13 @@ model Dashboard {
@@map("dashboards")
}
enum Metric {
sum
average
min
max
}
model Report {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
@@ -169,6 +182,9 @@ model Report {
line_type String @default("monotone")
breakdowns Json
events Json
formula String?
unit String?
metric Metric @default(sum)
project_id String
project Project @relation(fields: [project_id], references: [id])
previous Boolean @default(false)