@varaos/db 1.4.5 → 1.4.7
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
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "AdminSession" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"userId" TEXT NOT NULL,
|
|
5
|
+
"token" TEXT NOT NULL,
|
|
6
|
+
"role" "Role" NOT NULL,
|
|
7
|
+
"ip" TEXT,
|
|
8
|
+
"userAgent" TEXT,
|
|
9
|
+
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
10
|
+
"revokedAt" TIMESTAMP(3),
|
|
11
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
12
|
+
|
|
13
|
+
CONSTRAINT "AdminSession_pkey" PRIMARY KEY ("id")
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
-- CreateTable
|
|
17
|
+
CREATE TABLE "AdminOTP" (
|
|
18
|
+
"id" TEXT NOT NULL,
|
|
19
|
+
"userId" TEXT NOT NULL,
|
|
20
|
+
"code" TEXT NOT NULL,
|
|
21
|
+
"used" BOOLEAN NOT NULL DEFAULT false,
|
|
22
|
+
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
23
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
24
|
+
|
|
25
|
+
CONSTRAINT "AdminOTP_pkey" PRIMARY KEY ("id")
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
-- CreateTable
|
|
29
|
+
CREATE TABLE "ImpersonationSession" (
|
|
30
|
+
"id" TEXT NOT NULL,
|
|
31
|
+
"actorId" TEXT NOT NULL,
|
|
32
|
+
"targetId" TEXT NOT NULL,
|
|
33
|
+
"token" TEXT NOT NULL,
|
|
34
|
+
"reason" TEXT NOT NULL,
|
|
35
|
+
"used" BOOLEAN NOT NULL DEFAULT false,
|
|
36
|
+
"usedAt" TIMESTAMP(3),
|
|
37
|
+
"expiresAt" TIMESTAMP(3) NOT NULL,
|
|
38
|
+
"revokedAt" TIMESTAMP(3),
|
|
39
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
40
|
+
|
|
41
|
+
CONSTRAINT "ImpersonationSession_pkey" PRIMARY KEY ("id")
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
-- CreateIndex
|
|
45
|
+
CREATE UNIQUE INDEX "AdminSession_token_key" ON "AdminSession"("token");
|
|
46
|
+
|
|
47
|
+
-- CreateIndex
|
|
48
|
+
CREATE INDEX "AdminSession_userId_idx" ON "AdminSession"("userId");
|
|
49
|
+
|
|
50
|
+
-- CreateIndex
|
|
51
|
+
CREATE INDEX "AdminSession_token_idx" ON "AdminSession"("token");
|
|
52
|
+
|
|
53
|
+
-- CreateIndex
|
|
54
|
+
CREATE INDEX "AdminOTP_userId_used_idx" ON "AdminOTP"("userId", "used");
|
|
55
|
+
|
|
56
|
+
-- CreateIndex
|
|
57
|
+
CREATE UNIQUE INDEX "ImpersonationSession_token_key" ON "ImpersonationSession"("token");
|
|
58
|
+
|
|
59
|
+
-- CreateIndex
|
|
60
|
+
CREATE INDEX "ImpersonationSession_actorId_idx" ON "ImpersonationSession"("actorId");
|
|
61
|
+
|
|
62
|
+
-- CreateIndex
|
|
63
|
+
CREATE INDEX "ImpersonationSession_targetId_idx" ON "ImpersonationSession"("targetId");
|
|
64
|
+
|
|
65
|
+
-- AddForeignKey
|
|
66
|
+
ALTER TABLE "AdminSession" ADD CONSTRAINT "AdminSession_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
67
|
+
|
|
68
|
+
-- AddForeignKey
|
|
69
|
+
ALTER TABLE "AdminOTP" ADD CONSTRAINT "AdminOTP_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
70
|
+
|
|
71
|
+
-- AddForeignKey
|
|
72
|
+
ALTER TABLE "ImpersonationSession" ADD CONSTRAINT "ImpersonationSession_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
73
|
+
|
|
74
|
+
-- AddForeignKey
|
|
75
|
+
ALTER TABLE "ImpersonationSession" ADD CONSTRAINT "ImpersonationSession_targetId_fkey" FOREIGN KEY ("targetId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "cloudflare_metrics" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"timestamp" TIMESTAMP(3) NOT NULL,
|
|
5
|
+
"zoneId" TEXT NOT NULL,
|
|
6
|
+
"requests" BIGINT NOT NULL DEFAULT 0,
|
|
7
|
+
"pageViews" BIGINT NOT NULL DEFAULT 0,
|
|
8
|
+
"bytes" BIGINT NOT NULL DEFAULT 0,
|
|
9
|
+
"errors4xx" INTEGER NOT NULL DEFAULT 0,
|
|
10
|
+
"errors5xx" INTEGER NOT NULL DEFAULT 0,
|
|
11
|
+
"uniqueVisitors" INTEGER NOT NULL DEFAULT 0,
|
|
12
|
+
"granularity" TEXT NOT NULL DEFAULT '1h',
|
|
13
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
14
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
15
|
+
|
|
16
|
+
CONSTRAINT "cloudflare_metrics_pkey" PRIMARY KEY ("id")
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
-- CreateIndex
|
|
20
|
+
CREATE UNIQUE INDEX "cloudflare_metrics_zoneId_timestamp_granularity_key" ON "cloudflare_metrics"("zoneId", "timestamp", "granularity");
|
|
21
|
+
|
|
22
|
+
-- CreateIndex
|
|
23
|
+
CREATE INDEX "cloudflare_metrics_timestamp_idx" ON "cloudflare_metrics"("timestamp");
|
package/prisma/schema.prisma
CHANGED
|
@@ -664,6 +664,26 @@ model UsageAggregate {
|
|
|
664
664
|
@@unique([userId, workspaceId, billingPeriod, source])
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
+
model CloudflareMetric {
|
|
668
|
+
id String @id @default(uuid())
|
|
669
|
+
timestamp DateTime
|
|
670
|
+
zoneId String
|
|
671
|
+
requests BigInt @default(0)
|
|
672
|
+
pageViews BigInt @default(0)
|
|
673
|
+
bytes BigInt @default(0)
|
|
674
|
+
errors4xx Int @default(0)
|
|
675
|
+
errors5xx Int @default(0)
|
|
676
|
+
uniqueVisitors Int @default(0)
|
|
677
|
+
granularity String @default("1h") // 1h, 1d
|
|
678
|
+
|
|
679
|
+
createdAt DateTime @default(now())
|
|
680
|
+
updatedAt DateTime @updatedAt
|
|
681
|
+
|
|
682
|
+
@@unique([zoneId, timestamp, granularity])
|
|
683
|
+
@@index([timestamp])
|
|
684
|
+
@@map("cloudflare_metrics")
|
|
685
|
+
}
|
|
686
|
+
|
|
667
687
|
model TokenTransaction {
|
|
668
688
|
id String @id @default(uuid())
|
|
669
689
|
userId String
|