@varaos/db 1.1.19 → 1.2.0
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,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- The `status` column on the `Workflow` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
|
5
|
+
- The `status` column on the `WorkflowRun` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
|
6
|
+
- The `status` column on the `WorkflowStep` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
|
7
|
+
- The `status` column on the `WorkflowStepRun` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
|
8
|
+
- Changed the type of `status` on the `Subscription` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
|
|
9
|
+
|
|
10
|
+
*/
|
|
11
|
+
-- CreateEnum
|
|
12
|
+
CREATE TYPE "public"."SubscriptionStatus" AS ENUM ('active', 'trialing', 'past_due', 'canceled', 'paused');
|
|
13
|
+
|
|
14
|
+
-- CreateEnum
|
|
15
|
+
CREATE TYPE "public"."WorkflowStatus" AS ENUM ('active', 'paused', 'archived');
|
|
16
|
+
|
|
17
|
+
-- CreateEnum
|
|
18
|
+
CREATE TYPE "public"."WorkflowRunStatus" AS ENUM ('running', 'completed', 'failed', 'canceled');
|
|
19
|
+
|
|
20
|
+
-- CreateEnum
|
|
21
|
+
CREATE TYPE "public"."WorkflowStepStatus" AS ENUM ('active', 'paused', 'deprecated');
|
|
22
|
+
|
|
23
|
+
-- CreateEnum
|
|
24
|
+
CREATE TYPE "public"."WorkflowStepRunStatus" AS ENUM ('pending', 'running', 'completed', 'failed', 'skipped');
|
|
25
|
+
|
|
26
|
+
-- DropIndex
|
|
27
|
+
DROP INDEX "public"."UserSession_userId_idx";
|
|
28
|
+
|
|
29
|
+
-- AlterTable
|
|
30
|
+
ALTER TABLE "public"."BillingEvent" ADD COLUMN "error" TEXT,
|
|
31
|
+
ADD COLUMN "processedAt" TIMESTAMP(3);
|
|
32
|
+
|
|
33
|
+
-- AlterTable
|
|
34
|
+
ALTER TABLE "public"."Subscription" ADD COLUMN "currentPeriodEnd" TIMESTAMP(3),
|
|
35
|
+
ADD COLUMN "currentPeriodStart" TIMESTAMP(3),
|
|
36
|
+
DROP COLUMN "status",
|
|
37
|
+
ADD COLUMN "status" "public"."SubscriptionStatus" NOT NULL;
|
|
38
|
+
|
|
39
|
+
-- AlterTable
|
|
40
|
+
ALTER TABLE "public"."User" ADD COLUMN "chatCount" INTEGER NOT NULL DEFAULT 0,
|
|
41
|
+
ADD COLUMN "integrationCount" INTEGER NOT NULL DEFAULT 0,
|
|
42
|
+
ADD COLUMN "lastActiveAt" TIMESTAMP(3),
|
|
43
|
+
ADD COLUMN "workflowCount" INTEGER NOT NULL DEFAULT 0;
|
|
44
|
+
|
|
45
|
+
-- AlterTable
|
|
46
|
+
ALTER TABLE "public"."Workflow" DROP COLUMN "status",
|
|
47
|
+
ADD COLUMN "status" "public"."WorkflowStatus" NOT NULL DEFAULT 'active';
|
|
48
|
+
|
|
49
|
+
-- AlterTable
|
|
50
|
+
ALTER TABLE "public"."WorkflowRun" DROP COLUMN "status",
|
|
51
|
+
ADD COLUMN "status" "public"."WorkflowRunStatus" NOT NULL DEFAULT 'running';
|
|
52
|
+
|
|
53
|
+
-- AlterTable
|
|
54
|
+
ALTER TABLE "public"."WorkflowStep" DROP COLUMN "status",
|
|
55
|
+
ADD COLUMN "status" "public"."WorkflowStepStatus" NOT NULL DEFAULT 'active';
|
|
56
|
+
|
|
57
|
+
-- AlterTable
|
|
58
|
+
ALTER TABLE "public"."WorkflowStepRun" DROP COLUMN "status",
|
|
59
|
+
ADD COLUMN "status" "public"."WorkflowStepRunStatus" NOT NULL DEFAULT 'pending';
|
|
60
|
+
|
|
61
|
+
-- CreateIndex
|
|
62
|
+
CREATE INDEX "UserSession_userId_revoked_idx" ON "public"."UserSession"("userId", "revoked");
|
package/prisma/schema.prisma
CHANGED
|
@@ -82,6 +82,43 @@ enum TwoFactorMethod {
|
|
|
82
82
|
webauthn
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
enum SubscriptionStatus {
|
|
86
|
+
active
|
|
87
|
+
trialing
|
|
88
|
+
past_due
|
|
89
|
+
canceled
|
|
90
|
+
paused
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
enum WorkflowStatus {
|
|
94
|
+
active
|
|
95
|
+
paused
|
|
96
|
+
archived
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
enum WorkflowRunStatus {
|
|
100
|
+
running
|
|
101
|
+
completed
|
|
102
|
+
failed
|
|
103
|
+
canceled
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
enum WorkflowStepStatus {
|
|
107
|
+
active
|
|
108
|
+
paused
|
|
109
|
+
deprecated
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
enum WorkflowStepRunStatus {
|
|
113
|
+
pending
|
|
114
|
+
running
|
|
115
|
+
completed
|
|
116
|
+
failed
|
|
117
|
+
skipped
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
85
122
|
/// ─────────────────────────────────────────────
|
|
86
123
|
/// USERS & AUTH
|
|
87
124
|
/// ─────────────────────────────────────────────
|
|
@@ -108,10 +145,16 @@ model User {
|
|
|
108
145
|
userTwoFactor UserTwoFactor?
|
|
109
146
|
|
|
110
147
|
metadata Json?
|
|
111
|
-
plan Plan @default(free)
|
|
112
|
-
tokenBalance Int @default(0)
|
|
113
|
-
creditsUsed Int @default(0)
|
|
114
148
|
deletedAt DateTime?
|
|
149
|
+
plan Plan @default(free)
|
|
150
|
+
tokenBalance Int @default(0)
|
|
151
|
+
creditsUsed Int @default(0)
|
|
152
|
+
|
|
153
|
+
chatCount Int @default(0)
|
|
154
|
+
workflowCount Int @default(0)
|
|
155
|
+
integrationCount Int @default(0)
|
|
156
|
+
|
|
157
|
+
lastActiveAt DateTime?
|
|
115
158
|
|
|
116
159
|
authType AuthType @default(oauth)
|
|
117
160
|
|
|
@@ -181,7 +224,7 @@ model UserSession {
|
|
|
181
224
|
|
|
182
225
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
183
226
|
|
|
184
|
-
@@index([userId])
|
|
227
|
+
@@index([userId, revoked])
|
|
185
228
|
}
|
|
186
229
|
|
|
187
230
|
model UploadIntent {
|
|
@@ -420,10 +463,10 @@ model TokenTransaction {
|
|
|
420
463
|
}
|
|
421
464
|
|
|
422
465
|
model Workflow {
|
|
423
|
-
id String
|
|
466
|
+
id String @id @default(uuid())
|
|
424
467
|
name String
|
|
425
468
|
description String?
|
|
426
|
-
status
|
|
469
|
+
status WorkflowStatus @default(active)
|
|
427
470
|
userId String
|
|
428
471
|
workspaceId String?
|
|
429
472
|
|
|
@@ -442,7 +485,7 @@ model WorkflowStep {
|
|
|
442
485
|
type String
|
|
443
486
|
config Json
|
|
444
487
|
order Int
|
|
445
|
-
status
|
|
488
|
+
status WorkflowStepStatus @default(active)
|
|
446
489
|
|
|
447
490
|
workflow Workflow @relation(fields: [workflowId], references: [id])
|
|
448
491
|
|
|
@@ -452,9 +495,9 @@ model WorkflowStep {
|
|
|
452
495
|
}
|
|
453
496
|
|
|
454
497
|
model WorkflowRun {
|
|
455
|
-
id String
|
|
498
|
+
id String @id @default(uuid())
|
|
456
499
|
workflowId String
|
|
457
|
-
status
|
|
500
|
+
status WorkflowRunStatus @default(running)
|
|
458
501
|
input Json?
|
|
459
502
|
output Json?
|
|
460
503
|
error String?
|
|
@@ -472,7 +515,7 @@ model WorkflowStepRun {
|
|
|
472
515
|
id String @id @default(uuid())
|
|
473
516
|
workflowRunId String
|
|
474
517
|
workflowStepId String
|
|
475
|
-
status
|
|
518
|
+
status WorkflowStepRunStatus @default(pending)
|
|
476
519
|
input Json?
|
|
477
520
|
output Json?
|
|
478
521
|
error String?
|
|
@@ -682,12 +725,20 @@ model SecurityEvent {
|
|
|
682
725
|
/// ─────────────────────────────────────────────
|
|
683
726
|
|
|
684
727
|
model Subscription {
|
|
685
|
-
id
|
|
686
|
-
userId
|
|
687
|
-
plan
|
|
688
|
-
status
|
|
689
|
-
|
|
690
|
-
|
|
728
|
+
id String @id @default(uuid())
|
|
729
|
+
userId String
|
|
730
|
+
plan Plan
|
|
731
|
+
status SubscriptionStatus // active | trialing | past_due | canceled
|
|
732
|
+
|
|
733
|
+
// ── Lifecycle (rarely changes)
|
|
734
|
+
startedAt DateTime
|
|
735
|
+
endedAt DateTime?
|
|
736
|
+
|
|
737
|
+
// ── Billing cycle (changes every invoice)
|
|
738
|
+
currentPeriodStart DateTime?
|
|
739
|
+
currentPeriodEnd DateTime?
|
|
740
|
+
|
|
741
|
+
// ── Provider scheduling (informational only)
|
|
691
742
|
nextPayment DateTime?
|
|
692
743
|
|
|
693
744
|
razorpayCustomerId String?
|
|
@@ -727,8 +778,11 @@ model BillingEvent {
|
|
|
727
778
|
eventType String
|
|
728
779
|
eventId String @unique // razorpay event ID
|
|
729
780
|
|
|
730
|
-
payload
|
|
731
|
-
processed
|
|
781
|
+
payload Json
|
|
782
|
+
processed Boolean @default(false)
|
|
783
|
+
processedAt DateTime?
|
|
784
|
+
error String?
|
|
785
|
+
|
|
732
786
|
createdAt DateTime @default(now())
|
|
733
787
|
|
|
734
788
|
@@index([provider, eventType])
|