@varaos/db 1.1.15 → 1.1.17
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/20260103095101_add_user_storage_quota_fields/migration.sql +3 -0
- package/prisma/migrations/20260103095321_add_user_file_storage_tracking/migration.sql +21 -0
- package/prisma/migrations/20260103115541_add_userfile_checksum_metadata/migration.sql +3 -0
- package/prisma/schema.prisma +29 -5
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "public"."UserFile" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"userId" TEXT NOT NULL,
|
|
5
|
+
"path" TEXT NOT NULL,
|
|
6
|
+
"size" BIGINT NOT NULL,
|
|
7
|
+
"mimeType" TEXT NOT NULL,
|
|
8
|
+
"category" TEXT NOT NULL,
|
|
9
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
+
|
|
11
|
+
CONSTRAINT "UserFile_pkey" PRIMARY KEY ("id")
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
-- CreateIndex
|
|
15
|
+
CREATE INDEX "UserFile_userId_idx" ON "public"."UserFile"("userId");
|
|
16
|
+
|
|
17
|
+
-- CreateIndex
|
|
18
|
+
CREATE INDEX "UserFile_category_idx" ON "public"."UserFile"("category");
|
|
19
|
+
|
|
20
|
+
-- AddForeignKey
|
|
21
|
+
ALTER TABLE "public"."UserFile" ADD CONSTRAINT "UserFile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
package/prisma/schema.prisma
CHANGED
|
@@ -101,6 +101,9 @@ model User {
|
|
|
101
101
|
|
|
102
102
|
passwordStrength String? // weak | medium | strong
|
|
103
103
|
|
|
104
|
+
storageUsed BigInt @default(0) // bytes
|
|
105
|
+
storageLimit BigInt @default(524288000) // 500 MB (beta)
|
|
106
|
+
|
|
104
107
|
accounts Account[]
|
|
105
108
|
integrations Integration[]
|
|
106
109
|
tokenTransactions TokenTransaction[]
|
|
@@ -121,10 +124,31 @@ model User {
|
|
|
121
124
|
paymentMethods PaymentMethod[]
|
|
122
125
|
userEmails UserEmail[]
|
|
123
126
|
invoices Invoice[]
|
|
127
|
+
userFiles UserFile[]
|
|
124
128
|
|
|
125
129
|
@@index([status])
|
|
126
130
|
}
|
|
127
131
|
|
|
132
|
+
model UserFile {
|
|
133
|
+
id String @id @default(uuid())
|
|
134
|
+
userId String
|
|
135
|
+
|
|
136
|
+
path String // local path or CDN URL
|
|
137
|
+
size BigInt // bytes
|
|
138
|
+
mimeType String
|
|
139
|
+
category String // avatar | memory | export | attachment
|
|
140
|
+
|
|
141
|
+
checksum String? // sha256 or md5 for integrity verification
|
|
142
|
+
metadata Json?
|
|
143
|
+
|
|
144
|
+
createdAt DateTime @default(now())
|
|
145
|
+
|
|
146
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
147
|
+
|
|
148
|
+
@@index([userId])
|
|
149
|
+
@@index([category])
|
|
150
|
+
}
|
|
151
|
+
|
|
128
152
|
model UserSession {
|
|
129
153
|
id String @id @default(uuid())
|
|
130
154
|
userId String
|
|
@@ -132,7 +156,7 @@ model UserSession {
|
|
|
132
156
|
userAgent String?
|
|
133
157
|
lastUsed DateTime
|
|
134
158
|
|
|
135
|
-
revoked Boolean
|
|
159
|
+
revoked Boolean @default(false)
|
|
136
160
|
revokedAt DateTime?
|
|
137
161
|
|
|
138
162
|
expiresAt DateTime
|
|
@@ -645,11 +669,11 @@ model Invoice {
|
|
|
645
669
|
}
|
|
646
670
|
|
|
647
671
|
model BillingEvent {
|
|
648
|
-
id
|
|
649
|
-
provider
|
|
672
|
+
id String @id @default(uuid())
|
|
673
|
+
provider String // razorpay
|
|
650
674
|
|
|
651
675
|
eventType String
|
|
652
|
-
eventId String
|
|
676
|
+
eventId String @unique // razorpay event ID
|
|
653
677
|
|
|
654
678
|
payload Json
|
|
655
679
|
processed Boolean @default(false)
|
|
@@ -661,7 +685,7 @@ model BillingEvent {
|
|
|
661
685
|
model PaymentMethod {
|
|
662
686
|
id String @id @default(uuid())
|
|
663
687
|
userId String
|
|
664
|
-
provider
|
|
688
|
+
provider String // razorpay | stripe | paypal
|
|
665
689
|
type String // card
|
|
666
690
|
brand String?
|
|
667
691
|
last4 String?
|