@varaos/db 1.1.17 → 1.1.18

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varaos/db",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "files": [
@@ -0,0 +1,36 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - Changed the type of `category` on the `UserFile` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
5
+
6
+ */
7
+ -- CreateEnum
8
+ CREATE TYPE "public"."FileCategory" AS ENUM ('avatar', 'media', 'attachment', 'memory', 'export');
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "public"."UserFile" DROP COLUMN "category",
12
+ ADD COLUMN "category" "public"."FileCategory" NOT NULL;
13
+
14
+ -- CreateTable
15
+ CREATE TABLE "public"."UploadIntent" (
16
+ "id" TEXT NOT NULL,
17
+ "userId" TEXT NOT NULL,
18
+ "category" "public"."FileCategory" NOT NULL,
19
+ "size" BIGINT NOT NULL,
20
+ "objectKey" TEXT NOT NULL,
21
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
22
+
23
+ CONSTRAINT "UploadIntent_pkey" PRIMARY KEY ("id")
24
+ );
25
+
26
+ -- CreateIndex
27
+ CREATE INDEX "UploadIntent_userId_idx" ON "public"."UploadIntent"("userId");
28
+
29
+ -- CreateIndex
30
+ CREATE INDEX "UploadIntent_userId_category_idx" ON "public"."UploadIntent"("userId", "category");
31
+
32
+ -- CreateIndex
33
+ CREATE INDEX "UserFile_category_idx" ON "public"."UserFile"("category");
34
+
35
+ -- CreateIndex
36
+ CREATE INDEX "UserFile_userId_category_idx" ON "public"."UserFile"("userId", "category");
@@ -68,6 +68,14 @@ enum ReactionType {
68
68
  WOW
69
69
  }
70
70
 
71
+ enum FileCategory {
72
+ avatar
73
+ media
74
+ attachment
75
+ memory
76
+ export
77
+ }
78
+
71
79
  /// ─────────────────────────────────────────────
72
80
  /// USERS & AUTH
73
81
  /// ─────────────────────────────────────────────
@@ -133,10 +141,10 @@ model UserFile {
133
141
  id String @id @default(uuid())
134
142
  userId String
135
143
 
136
- path String // local path or CDN URL
144
+ path String // Spaces object key (users/{userId}/{category}/{fileId}.ext)
137
145
  size BigInt // bytes
138
146
  mimeType String
139
- category String // avatar | memory | export | attachment
147
+ category FileCategory
140
148
 
141
149
  checksum String? // sha256 or md5 for integrity verification
142
150
  metadata Json?
@@ -147,6 +155,7 @@ model UserFile {
147
155
 
148
156
  @@index([userId])
149
157
  @@index([category])
158
+ @@index([userId, category])
150
159
  }
151
160
 
152
161
  model UserSession {
@@ -167,6 +176,18 @@ model UserSession {
167
176
  @@index([userId])
168
177
  }
169
178
 
179
+ model UploadIntent {
180
+ id String @id
181
+ userId String
182
+ category FileCategory
183
+ size BigInt
184
+ objectKey String
185
+ createdAt DateTime @default(now())
186
+
187
+ @@index([userId])
188
+ @@index([userId, category])
189
+ }
190
+
170
191
  model UserEmail {
171
192
  id String @id @default(uuid())
172
193
  userId String