@varaos/db 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/prisma/migrations/20251015110514_extend_status_enum_and_improve_schema_indexes/migration.sql +21 -0
- package/prisma/migrations/20251015110611_update_default_status_to_draft/migration.sql +2 -0
- package/prisma/migrations/20251018141649_add_visitor_model/migration.sql +22 -0
- package/prisma/schema.prisma +34 -5
package/package.json
CHANGED
package/prisma/migrations/20251015110514_extend_status_enum_and_improve_schema_indexes/migration.sql
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
-- AlterEnum
|
|
2
|
+
-- This migration adds more than one value to an enum.
|
|
3
|
+
-- With PostgreSQL versions 11 and earlier, this is not possible
|
|
4
|
+
-- in a single migration. This can be worked around by creating
|
|
5
|
+
-- multiple migrations, each migration adding only one value to
|
|
6
|
+
-- the enum.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
ALTER TYPE "public"."Status" ADD VALUE 'draft';
|
|
10
|
+
ALTER TYPE "public"."Status" ADD VALUE 'pending_review';
|
|
11
|
+
ALTER TYPE "public"."Status" ADD VALUE 'deprecated';
|
|
12
|
+
ALTER TYPE "public"."Status" ADD VALUE 'archived';
|
|
13
|
+
|
|
14
|
+
-- DropIndex
|
|
15
|
+
DROP INDEX "public"."Workspace_ownerId_key";
|
|
16
|
+
|
|
17
|
+
-- CreateIndex
|
|
18
|
+
CREATE INDEX "AuditLog_userId_createdAt_idx" ON "public"."AuditLog"("userId", "createdAt");
|
|
19
|
+
|
|
20
|
+
-- CreateIndex
|
|
21
|
+
CREATE INDEX "Workspace_ownerId_idx" ON "public"."Workspace"("ownerId");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "public"."Visitor" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"visitorId" TEXT NOT NULL,
|
|
5
|
+
"ipAddress" TEXT,
|
|
6
|
+
"userAgent" TEXT,
|
|
7
|
+
"country" TEXT,
|
|
8
|
+
"referrer" TEXT,
|
|
9
|
+
"firstVisit" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
+
"lastVisit" TIMESTAMP(3) NOT NULL,
|
|
11
|
+
"visitCount" INTEGER NOT NULL DEFAULT 1,
|
|
12
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
13
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
14
|
+
|
|
15
|
+
CONSTRAINT "Visitor_pkey" PRIMARY KEY ("id")
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
-- CreateIndex
|
|
19
|
+
CREATE UNIQUE INDEX "Visitor_visitorId_key" ON "public"."Visitor"("visitorId");
|
|
20
|
+
|
|
21
|
+
-- CreateIndex
|
|
22
|
+
CREATE INDEX "Visitor_createdAt_idx" ON "public"."Visitor"("createdAt");
|
package/prisma/schema.prisma
CHANGED
|
@@ -22,9 +22,13 @@ enum Role {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
enum Status {
|
|
25
|
-
active
|
|
26
|
-
suspended
|
|
27
|
-
deleted
|
|
25
|
+
active // Visible and usable in production
|
|
26
|
+
suspended // Temporarily disabled but can be restored
|
|
27
|
+
deleted // Soft-deleted or removed from UI
|
|
28
|
+
draft // Being worked on but not yet published
|
|
29
|
+
pending_review // Awaiting manual or automated approval
|
|
30
|
+
deprecated // Old but still accessible for legacy users
|
|
31
|
+
archived // Hidden from new users, preserved for history
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
enum Plan {
|
|
@@ -134,7 +138,7 @@ model Workspace {
|
|
|
134
138
|
id String @id @default(uuid())
|
|
135
139
|
name String
|
|
136
140
|
description String?
|
|
137
|
-
ownerId String
|
|
141
|
+
ownerId String
|
|
138
142
|
status Status @default(active)
|
|
139
143
|
deletedAt DateTime?
|
|
140
144
|
|
|
@@ -150,6 +154,7 @@ model Workspace {
|
|
|
150
154
|
ChatSession ChatSession[]
|
|
151
155
|
|
|
152
156
|
@@index([status])
|
|
157
|
+
@@index([ownerId])
|
|
153
158
|
}
|
|
154
159
|
|
|
155
160
|
model Integration {
|
|
@@ -195,7 +200,7 @@ model IntegrationCatalog {
|
|
|
195
200
|
docsUrl String?
|
|
196
201
|
oauthType String?
|
|
197
202
|
setupInstructions Json?
|
|
198
|
-
status Status @default(
|
|
203
|
+
status Status @default(draft)
|
|
199
204
|
|
|
200
205
|
createdAt DateTime @default(now())
|
|
201
206
|
updatedAt DateTime @updatedAt
|
|
@@ -490,6 +495,8 @@ model AuditLog {
|
|
|
490
495
|
createdAt DateTime @default(now())
|
|
491
496
|
|
|
492
497
|
user User? @relation(fields: [userId], references: [id])
|
|
498
|
+
|
|
499
|
+
@@index([userId, createdAt])
|
|
493
500
|
}
|
|
494
501
|
|
|
495
502
|
/// ─────────────────────────────────────────────
|
|
@@ -554,3 +561,25 @@ model Onboarding {
|
|
|
554
561
|
|
|
555
562
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
556
563
|
}
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
/////////////////////
|
|
568
|
+
// Unique Visitors
|
|
569
|
+
//////////////////////
|
|
570
|
+
model Visitor {
|
|
571
|
+
id String @id @default(uuid())
|
|
572
|
+
visitorId String @unique // cookie or fingerprint ID
|
|
573
|
+
ipAddress String?
|
|
574
|
+
userAgent String?
|
|
575
|
+
country String? // optional if you plan to use GeoIP later
|
|
576
|
+
referrer String?
|
|
577
|
+
firstVisit DateTime @default(now())
|
|
578
|
+
lastVisit DateTime @updatedAt
|
|
579
|
+
visitCount Int @default(1)
|
|
580
|
+
|
|
581
|
+
createdAt DateTime @default(now())
|
|
582
|
+
updatedAt DateTime @updatedAt
|
|
583
|
+
|
|
584
|
+
@@index([createdAt])
|
|
585
|
+
}
|