9drive 1.0.1 → 1.0.3

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.
@@ -1,354 +1,354 @@
1
- generator client {
2
- provider = "prisma-client-js"
3
- output = "./generated/sqlite-client"
4
- }
5
-
6
- datasource db {
7
- provider = "sqlite"
8
- url = env("DATABASE_URL")
9
- }
10
-
11
- model User {
12
- id String @id @default(uuid())
13
- name String
14
- email String @unique
15
- passwordHash String @map("password_hash")
16
- status String @default("active")
17
- createdAt DateTime @default(now()) @map("created_at")
18
- updatedAt DateTime @updatedAt @map("updated_at")
19
- sessions UserSession[]
20
- authHandoffs AuthHandoff[]
21
- providerConfigs ProviderConfig[]
22
- oauthStates OauthState[]
23
- connectedAccounts ConnectedAccount[]
24
- s3StorageConfigs S3StorageConfig[]
25
- files File[]
26
- fileShares FileShare[]
27
- filePreviewTokens FilePreviewToken[]
28
- folders Folder[]
29
- uploadSessions UploadSession[]
30
- auditLogs AuditLog[]
31
- workspaceInvitesSent WorkspaceInvite[] @relation("WorkspaceInvitesSent")
32
- uploadRoutingPolicy UploadRoutingPolicy?
33
- apiKeys ApiKey[]
34
-
35
- @@map("users")
36
- }
37
-
38
- model ApiKey {
39
- id String @id @default(uuid())
40
- userId String @map("user_id")
41
- name String
42
- keyPrefix String @map("key_prefix")
43
- keyHash String @unique @map("key_hash")
44
- scopes Json
45
- status String @default("active")
46
- lastUsedAt DateTime? @map("last_used_at")
47
- expiresAt DateTime? @map("expires_at")
48
- revokedAt DateTime? @map("revoked_at")
49
- createdAt DateTime @default(now()) @map("created_at")
50
- updatedAt DateTime @updatedAt @map("updated_at")
51
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
52
-
53
- @@index([userId])
54
- @@index([userId, status, createdAt])
55
- @@map("api_keys")
56
- }
57
-
58
- model UploadRoutingPolicy {
59
- id String @id @default(uuid())
60
- userId String @unique @map("user_id")
61
- mode String @default("most_available")
62
- priorityAccountIds Json @map("priority_account_ids")
63
- roundRobinCursor Int @default(0) @map("round_robin_cursor")
64
- createdAt DateTime @default(now()) @map("created_at")
65
- updatedAt DateTime @updatedAt @map("updated_at")
66
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
67
-
68
- @@map("upload_routing_policies")
69
- }
70
-
71
- model UserSession {
72
- id String @id @default(uuid())
73
- userId String @map("user_id")
74
- refreshTokenHash String @map("refresh_token_hash")
75
- userAgent String? @map("user_agent")
76
- ipAddress String? @map("ip_address")
77
- expiresAt DateTime @map("expires_at")
78
- revokedAt DateTime? @map("revoked_at")
79
- createdAt DateTime @default(now()) @map("created_at")
80
- updatedAt DateTime @updatedAt @map("updated_at")
81
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
82
-
83
- @@index([userId])
84
- @@index([refreshTokenHash])
85
- @@map("user_sessions")
86
- }
87
-
88
- model AuthHandoff {
89
- id String @id @default(uuid())
90
- userId String @map("user_id")
91
- tokenHash String @unique @map("token_hash")
92
- expiresAt DateTime @map("expires_at")
93
- usedAt DateTime? @map("used_at")
94
- createdAt DateTime @default(now()) @map("created_at")
95
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
96
-
97
- @@index([userId])
98
- @@map("auth_handoffs")
99
- }
100
-
101
- model ProviderConfig {
102
- id String @id @default(uuid())
103
- userId String? @map("user_id")
104
- provider String
105
- clientIdEncrypted String @map("client_id_encrypted")
106
- clientSecretEncrypted String @map("client_secret_encrypted")
107
- redirectUri String @map("redirect_uri")
108
- scopes Json
109
- status String @default("active")
110
- createdAt DateTime @default(now()) @map("created_at")
111
- updatedAt DateTime @updatedAt @map("updated_at")
112
- user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
113
- oauthStates OauthState[]
114
- connectedAccounts ConnectedAccount[]
115
-
116
- @@index([userId])
117
- @@index([provider])
118
- @@map("provider_configs")
119
- }
120
-
121
- model OauthState {
122
- id String @id @default(uuid())
123
- userId String? @map("user_id")
124
- providerConfigId String @map("provider_config_id")
125
- flow String @default("connect")
126
- stateHash String @unique @map("state_hash")
127
- expiresAt DateTime @map("expires_at")
128
- usedAt DateTime? @map("used_at")
129
- createdAt DateTime @default(now()) @map("created_at")
130
- user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
131
- providerConfig ProviderConfig @relation(fields: [providerConfigId], references: [id], onDelete: Cascade)
132
-
133
- @@index([userId])
134
- @@map("oauth_states")
135
- }
136
-
137
- model ConnectedAccount {
138
- id String @id @default(uuid())
139
- userId String @map("user_id")
140
- providerConfigId String? @map("provider_config_id")
141
- provider String
142
- providerAccountId String @map("provider_account_id")
143
- email String
144
- displayName String? @map("display_name")
145
- avatarUrl String? @map("avatar_url")
146
- accessTokenEncrypted String? @map("access_token_encrypted")
147
- refreshTokenEncrypted String? @map("refresh_token_encrypted")
148
- tokenExpiresAt DateTime? @map("token_expires_at")
149
- scopes Json
150
- status String @default("connected")
151
- lastError String? @map("last_error")
152
- createdAt DateTime @default(now()) @map("created_at")
153
- updatedAt DateTime @updatedAt @map("updated_at")
154
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
155
- providerConfig ProviderConfig? @relation(fields: [providerConfigId], references: [id], onDelete: Cascade)
156
- storageAccount StorageAccount?
157
- files File[]
158
- folders Folder[]
159
- uploadSessions UploadSession[]
160
- s3StorageConfig S3StorageConfig?
161
-
162
- @@unique([userId, provider, providerAccountId])
163
- @@index([userId])
164
- @@index([userId, status, createdAt])
165
- @@map("connected_accounts")
166
- }
167
-
168
- model S3StorageConfig {
169
- id String @id @default(uuid())
170
- userId String @map("user_id")
171
- connectedAccountId String @unique @map("connected_account_id")
172
- name String
173
- bucket String
174
- region String
175
- endpoint String?
176
- accessKeyIdEncrypted String @map("access_key_id_encrypted")
177
- secretAccessKeyEncrypted String @map("secret_access_key_encrypted")
178
- forcePathStyle Boolean @default(false) @map("force_path_style")
179
- prefix String @default("9drive")
180
- quotaBytes BigInt? @map("quota_bytes")
181
- status String @default("active")
182
- createdAt DateTime @default(now()) @map("created_at")
183
- updatedAt DateTime @updatedAt @map("updated_at")
184
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
185
- connectedAccount ConnectedAccount @relation(fields: [connectedAccountId], references: [id], onDelete: Cascade)
186
-
187
- @@index([userId])
188
- @@index([userId, status])
189
- @@map("s3_storage_configs")
190
- }
191
-
192
- model StorageAccount {
193
- id String @id @default(uuid())
194
- connectedAccountId String @unique @map("connected_account_id")
195
- totalBytes BigInt? @map("total_bytes")
196
- usedBytes BigInt @default(0) @map("used_bytes")
197
- availableBytes BigInt? @map("available_bytes")
198
- trashBytes BigInt? @map("trash_bytes")
199
- lastSyncedAt DateTime? @map("last_synced_at")
200
- createdAt DateTime @default(now()) @map("created_at")
201
- updatedAt DateTime @updatedAt @map("updated_at")
202
- connectedAccount ConnectedAccount @relation(fields: [connectedAccountId], references: [id], onDelete: Cascade)
203
-
204
- @@map("storage_accounts")
205
- }
206
-
207
- model File {
208
- id String @id @default(uuid())
209
- userId String @map("user_id")
210
- connectedAccountId String @map("connected_account_id")
211
- folderId String? @map("folder_id")
212
- provider String
213
- providerFileId String @map("provider_file_id")
214
- name String
215
- mimeType String @map("mime_type")
216
- sizeBytes BigInt @map("size_bytes")
217
- checksum String?
218
- status String @default("active")
219
- createdAt DateTime @default(now()) @map("created_at")
220
- updatedAt DateTime @updatedAt @map("updated_at")
221
- deletedAt DateTime? @map("deleted_at")
222
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
223
- connectedAccount ConnectedAccount @relation(fields: [connectedAccountId], references: [id], onDelete: Cascade)
224
- folder Folder? @relation(fields: [folderId], references: [id], onDelete: SetNull)
225
- shares FileShare[]
226
- previewTokens FilePreviewToken[]
227
-
228
- @@index([userId])
229
- @@index([userId, status, createdAt])
230
- @@index([userId, status, folderId, createdAt])
231
- @@index([connectedAccountId])
232
- @@index([folderId])
233
- @@index([providerFileId])
234
- @@map("files")
235
- }
236
-
237
- model FileShare {
238
- id String @id @default(uuid())
239
- fileId String @map("file_id")
240
- userId String @map("user_id")
241
- token String? @unique
242
- tokenHash String @unique @map("token_hash")
243
- enabled Boolean @default(true)
244
- expiresAt DateTime? @map("expires_at")
245
- createdAt DateTime @default(now()) @map("created_at")
246
- updatedAt DateTime @updatedAt @map("updated_at")
247
- file File @relation(fields: [fileId], references: [id], onDelete: Cascade)
248
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
249
-
250
- @@index([fileId])
251
- @@index([userId])
252
- @@index([userId, enabled, createdAt])
253
- @@index([fileId, userId, enabled, createdAt])
254
- @@map("file_shares")
255
- }
256
-
257
- model FilePreviewToken {
258
- id String @id @default(uuid())
259
- fileId String @map("file_id")
260
- userId String @map("user_id")
261
- tokenHash String @unique @map("token_hash")
262
- expiresAt DateTime @map("expires_at")
263
- createdAt DateTime @default(now()) @map("created_at")
264
- file File @relation(fields: [fileId], references: [id], onDelete: Cascade)
265
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
266
-
267
- @@index([fileId])
268
- @@index([userId])
269
- @@map("file_preview_tokens")
270
- }
271
-
272
- model Folder {
273
- id String @id @default(uuid())
274
- userId String @map("user_id")
275
- parentId String? @map("parent_id")
276
- connectedAccountId String? @map("connected_account_id")
277
- provider String @default("google_drive")
278
- providerFolderId String? @map("provider_folder_id")
279
- name String
280
- color String @default("text-blue-500")
281
- iconUrl String? @map("icon_url")
282
- createdAt DateTime @default(now()) @map("created_at")
283
- updatedAt DateTime @updatedAt @map("updated_at")
284
- deletedAt DateTime? @map("deleted_at")
285
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
286
- parent Folder? @relation("FolderChildren", fields: [parentId], references: [id], onDelete: SetNull)
287
- children Folder[] @relation("FolderChildren")
288
- connectedAccount ConnectedAccount? @relation(fields: [connectedAccountId], references: [id], onDelete: SetNull)
289
- files File[]
290
- uploadSessions UploadSession[] @relation("UploadSessionFolder")
291
-
292
- @@index([userId])
293
- @@index([userId, deletedAt, updatedAt])
294
- @@index([userId, deletedAt, parentId, updatedAt])
295
- @@index([parentId])
296
- @@index([connectedAccountId])
297
- @@map("folders")
298
- }
299
-
300
- model UploadSession {
301
- id String @id @default(uuid())
302
- userId String @map("user_id")
303
- targetConnectedAccountId String? @map("target_connected_account_id")
304
- folderId String? @map("folder_id")
305
- fileName String @map("file_name")
306
- mimeType String @map("mime_type")
307
- sizeBytes BigInt @map("size_bytes")
308
- status String
309
- googleSessionUri String? @map("google_session_uri")
310
- errorMessage String? @map("error_message")
311
- createdAt DateTime @default(now()) @map("created_at")
312
- completedAt DateTime? @map("completed_at")
313
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
314
- targetConnectedAccount ConnectedAccount? @relation(fields: [targetConnectedAccountId], references: [id], onDelete: SetNull)
315
- folder Folder? @relation("UploadSessionFolder", fields: [folderId], references: [id], onDelete: SetNull)
316
-
317
- @@index([userId])
318
- @@index([folderId])
319
- @@map("upload_sessions")
320
- }
321
-
322
- model AuditLog {
323
- id String @id @default(uuid())
324
- userId String? @map("user_id")
325
- action String
326
- entityType String @map("entity_type")
327
- entityId String? @map("entity_id")
328
- metadata Json?
329
- createdAt DateTime @default(now()) @map("created_at")
330
- user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
331
-
332
- @@index([userId])
333
- @@map("audit_logs")
334
- }
335
-
336
- model WorkspaceInvite {
337
- id String @id @default(uuid())
338
- inviterId String @map("inviter_id")
339
- inviteeEmail String @map("invitee_email")
340
- targetType String @default("file") @map("target_type")
341
- targetId String @default("") @map("target_id")
342
- role String @default("viewer")
343
- status String @default("pending")
344
- revokedAt DateTime? @map("revoked_at")
345
- acceptedAt DateTime? @map("accepted_at")
346
- createdAt DateTime @default(now()) @map("created_at")
347
- updatedAt DateTime @updatedAt @map("updated_at")
348
- inviter User @relation("WorkspaceInvitesSent", fields: [inviterId], references: [id], onDelete: Cascade)
349
-
350
- @@unique([inviterId, inviteeEmail, targetType, targetId], map: "workspace_invites_target_unique")
351
- @@index([inviteeEmail])
352
- @@index([targetType, targetId])
353
- @@map("workspace_invites")
354
- }
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ output = "./generated/sqlite-client"
4
+ }
5
+
6
+ datasource db {
7
+ provider = "sqlite"
8
+ url = env("DATABASE_URL")
9
+ }
10
+
11
+ model User {
12
+ id String @id @default(uuid())
13
+ name String
14
+ email String @unique
15
+ passwordHash String @map("password_hash")
16
+ status String @default("active")
17
+ createdAt DateTime @default(now()) @map("created_at")
18
+ updatedAt DateTime @updatedAt @map("updated_at")
19
+ sessions UserSession[]
20
+ authHandoffs AuthHandoff[]
21
+ providerConfigs ProviderConfig[]
22
+ oauthStates OauthState[]
23
+ connectedAccounts ConnectedAccount[]
24
+ s3StorageConfigs S3StorageConfig[]
25
+ files File[]
26
+ fileShares FileShare[]
27
+ filePreviewTokens FilePreviewToken[]
28
+ folders Folder[]
29
+ uploadSessions UploadSession[]
30
+ auditLogs AuditLog[]
31
+ workspaceInvitesSent WorkspaceInvite[] @relation("WorkspaceInvitesSent")
32
+ uploadRoutingPolicy UploadRoutingPolicy?
33
+ apiKeys ApiKey[]
34
+
35
+ @@map("users")
36
+ }
37
+
38
+ model ApiKey {
39
+ id String @id @default(uuid())
40
+ userId String @map("user_id")
41
+ name String
42
+ keyPrefix String @map("key_prefix")
43
+ keyHash String @unique @map("key_hash")
44
+ scopes Json
45
+ status String @default("active")
46
+ lastUsedAt DateTime? @map("last_used_at")
47
+ expiresAt DateTime? @map("expires_at")
48
+ revokedAt DateTime? @map("revoked_at")
49
+ createdAt DateTime @default(now()) @map("created_at")
50
+ updatedAt DateTime @updatedAt @map("updated_at")
51
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
52
+
53
+ @@index([userId])
54
+ @@index([userId, status, createdAt])
55
+ @@map("api_keys")
56
+ }
57
+
58
+ model UploadRoutingPolicy {
59
+ id String @id @default(uuid())
60
+ userId String @unique @map("user_id")
61
+ mode String @default("most_available")
62
+ priorityAccountIds Json @map("priority_account_ids")
63
+ roundRobinCursor Int @default(0) @map("round_robin_cursor")
64
+ createdAt DateTime @default(now()) @map("created_at")
65
+ updatedAt DateTime @updatedAt @map("updated_at")
66
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
67
+
68
+ @@map("upload_routing_policies")
69
+ }
70
+
71
+ model UserSession {
72
+ id String @id @default(uuid())
73
+ userId String @map("user_id")
74
+ refreshTokenHash String @map("refresh_token_hash")
75
+ userAgent String? @map("user_agent")
76
+ ipAddress String? @map("ip_address")
77
+ expiresAt DateTime @map("expires_at")
78
+ revokedAt DateTime? @map("revoked_at")
79
+ createdAt DateTime @default(now()) @map("created_at")
80
+ updatedAt DateTime @updatedAt @map("updated_at")
81
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
82
+
83
+ @@index([userId])
84
+ @@index([refreshTokenHash])
85
+ @@map("user_sessions")
86
+ }
87
+
88
+ model AuthHandoff {
89
+ id String @id @default(uuid())
90
+ userId String @map("user_id")
91
+ tokenHash String @unique @map("token_hash")
92
+ expiresAt DateTime @map("expires_at")
93
+ usedAt DateTime? @map("used_at")
94
+ createdAt DateTime @default(now()) @map("created_at")
95
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
96
+
97
+ @@index([userId])
98
+ @@map("auth_handoffs")
99
+ }
100
+
101
+ model ProviderConfig {
102
+ id String @id @default(uuid())
103
+ userId String? @map("user_id")
104
+ provider String
105
+ clientIdEncrypted String @map("client_id_encrypted")
106
+ clientSecretEncrypted String @map("client_secret_encrypted")
107
+ redirectUri String @map("redirect_uri")
108
+ scopes Json
109
+ status String @default("active")
110
+ createdAt DateTime @default(now()) @map("created_at")
111
+ updatedAt DateTime @updatedAt @map("updated_at")
112
+ user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
113
+ oauthStates OauthState[]
114
+ connectedAccounts ConnectedAccount[]
115
+
116
+ @@index([userId])
117
+ @@index([provider])
118
+ @@map("provider_configs")
119
+ }
120
+
121
+ model OauthState {
122
+ id String @id @default(uuid())
123
+ userId String? @map("user_id")
124
+ providerConfigId String @map("provider_config_id")
125
+ flow String @default("connect")
126
+ stateHash String @unique @map("state_hash")
127
+ expiresAt DateTime @map("expires_at")
128
+ usedAt DateTime? @map("used_at")
129
+ createdAt DateTime @default(now()) @map("created_at")
130
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
131
+ providerConfig ProviderConfig @relation(fields: [providerConfigId], references: [id], onDelete: Cascade)
132
+
133
+ @@index([userId])
134
+ @@map("oauth_states")
135
+ }
136
+
137
+ model ConnectedAccount {
138
+ id String @id @default(uuid())
139
+ userId String @map("user_id")
140
+ providerConfigId String? @map("provider_config_id")
141
+ provider String
142
+ providerAccountId String @map("provider_account_id")
143
+ email String
144
+ displayName String? @map("display_name")
145
+ avatarUrl String? @map("avatar_url")
146
+ accessTokenEncrypted String? @map("access_token_encrypted")
147
+ refreshTokenEncrypted String? @map("refresh_token_encrypted")
148
+ tokenExpiresAt DateTime? @map("token_expires_at")
149
+ scopes Json
150
+ status String @default("connected")
151
+ lastError String? @map("last_error")
152
+ createdAt DateTime @default(now()) @map("created_at")
153
+ updatedAt DateTime @updatedAt @map("updated_at")
154
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
155
+ providerConfig ProviderConfig? @relation(fields: [providerConfigId], references: [id], onDelete: Cascade)
156
+ storageAccount StorageAccount?
157
+ files File[]
158
+ folders Folder[]
159
+ uploadSessions UploadSession[]
160
+ s3StorageConfig S3StorageConfig?
161
+
162
+ @@unique([userId, provider, providerAccountId])
163
+ @@index([userId])
164
+ @@index([userId, status, createdAt])
165
+ @@map("connected_accounts")
166
+ }
167
+
168
+ model S3StorageConfig {
169
+ id String @id @default(uuid())
170
+ userId String @map("user_id")
171
+ connectedAccountId String @unique @map("connected_account_id")
172
+ name String
173
+ bucket String
174
+ region String
175
+ endpoint String?
176
+ accessKeyIdEncrypted String @map("access_key_id_encrypted")
177
+ secretAccessKeyEncrypted String @map("secret_access_key_encrypted")
178
+ forcePathStyle Boolean @default(false) @map("force_path_style")
179
+ prefix String @default("9drive")
180
+ quotaBytes BigInt? @map("quota_bytes")
181
+ status String @default("active")
182
+ createdAt DateTime @default(now()) @map("created_at")
183
+ updatedAt DateTime @updatedAt @map("updated_at")
184
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
185
+ connectedAccount ConnectedAccount @relation(fields: [connectedAccountId], references: [id], onDelete: Cascade)
186
+
187
+ @@index([userId])
188
+ @@index([userId, status])
189
+ @@map("s3_storage_configs")
190
+ }
191
+
192
+ model StorageAccount {
193
+ id String @id @default(uuid())
194
+ connectedAccountId String @unique @map("connected_account_id")
195
+ totalBytes BigInt? @map("total_bytes")
196
+ usedBytes BigInt @default(0) @map("used_bytes")
197
+ availableBytes BigInt? @map("available_bytes")
198
+ trashBytes BigInt? @map("trash_bytes")
199
+ lastSyncedAt DateTime? @map("last_synced_at")
200
+ createdAt DateTime @default(now()) @map("created_at")
201
+ updatedAt DateTime @updatedAt @map("updated_at")
202
+ connectedAccount ConnectedAccount @relation(fields: [connectedAccountId], references: [id], onDelete: Cascade)
203
+
204
+ @@map("storage_accounts")
205
+ }
206
+
207
+ model File {
208
+ id String @id @default(uuid())
209
+ userId String @map("user_id")
210
+ connectedAccountId String @map("connected_account_id")
211
+ folderId String? @map("folder_id")
212
+ provider String
213
+ providerFileId String @map("provider_file_id")
214
+ name String
215
+ mimeType String @map("mime_type")
216
+ sizeBytes BigInt @map("size_bytes")
217
+ checksum String?
218
+ status String @default("active")
219
+ createdAt DateTime @default(now()) @map("created_at")
220
+ updatedAt DateTime @updatedAt @map("updated_at")
221
+ deletedAt DateTime? @map("deleted_at")
222
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
223
+ connectedAccount ConnectedAccount @relation(fields: [connectedAccountId], references: [id], onDelete: Cascade)
224
+ folder Folder? @relation(fields: [folderId], references: [id], onDelete: SetNull)
225
+ shares FileShare[]
226
+ previewTokens FilePreviewToken[]
227
+
228
+ @@index([userId])
229
+ @@index([userId, status, createdAt])
230
+ @@index([userId, status, folderId, createdAt])
231
+ @@index([connectedAccountId])
232
+ @@index([folderId])
233
+ @@index([providerFileId])
234
+ @@map("files")
235
+ }
236
+
237
+ model FileShare {
238
+ id String @id @default(uuid())
239
+ fileId String @map("file_id")
240
+ userId String @map("user_id")
241
+ token String? @unique
242
+ tokenHash String @unique @map("token_hash")
243
+ enabled Boolean @default(true)
244
+ expiresAt DateTime? @map("expires_at")
245
+ createdAt DateTime @default(now()) @map("created_at")
246
+ updatedAt DateTime @updatedAt @map("updated_at")
247
+ file File @relation(fields: [fileId], references: [id], onDelete: Cascade)
248
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
249
+
250
+ @@index([fileId])
251
+ @@index([userId])
252
+ @@index([userId, enabled, createdAt])
253
+ @@index([fileId, userId, enabled, createdAt])
254
+ @@map("file_shares")
255
+ }
256
+
257
+ model FilePreviewToken {
258
+ id String @id @default(uuid())
259
+ fileId String @map("file_id")
260
+ userId String @map("user_id")
261
+ tokenHash String @unique @map("token_hash")
262
+ expiresAt DateTime @map("expires_at")
263
+ createdAt DateTime @default(now()) @map("created_at")
264
+ file File @relation(fields: [fileId], references: [id], onDelete: Cascade)
265
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
266
+
267
+ @@index([fileId])
268
+ @@index([userId])
269
+ @@map("file_preview_tokens")
270
+ }
271
+
272
+ model Folder {
273
+ id String @id @default(uuid())
274
+ userId String @map("user_id")
275
+ parentId String? @map("parent_id")
276
+ connectedAccountId String? @map("connected_account_id")
277
+ provider String @default("google_drive")
278
+ providerFolderId String? @map("provider_folder_id")
279
+ name String
280
+ color String @default("text-blue-500")
281
+ iconUrl String? @map("icon_url")
282
+ createdAt DateTime @default(now()) @map("created_at")
283
+ updatedAt DateTime @updatedAt @map("updated_at")
284
+ deletedAt DateTime? @map("deleted_at")
285
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
286
+ parent Folder? @relation("FolderChildren", fields: [parentId], references: [id], onDelete: SetNull)
287
+ children Folder[] @relation("FolderChildren")
288
+ connectedAccount ConnectedAccount? @relation(fields: [connectedAccountId], references: [id], onDelete: SetNull)
289
+ files File[]
290
+ uploadSessions UploadSession[] @relation("UploadSessionFolder")
291
+
292
+ @@index([userId])
293
+ @@index([userId, deletedAt, updatedAt])
294
+ @@index([userId, deletedAt, parentId, updatedAt])
295
+ @@index([parentId])
296
+ @@index([connectedAccountId])
297
+ @@map("folders")
298
+ }
299
+
300
+ model UploadSession {
301
+ id String @id @default(uuid())
302
+ userId String @map("user_id")
303
+ targetConnectedAccountId String? @map("target_connected_account_id")
304
+ folderId String? @map("folder_id")
305
+ fileName String @map("file_name")
306
+ mimeType String @map("mime_type")
307
+ sizeBytes BigInt @map("size_bytes")
308
+ status String
309
+ googleSessionUri String? @map("google_session_uri")
310
+ errorMessage String? @map("error_message")
311
+ createdAt DateTime @default(now()) @map("created_at")
312
+ completedAt DateTime? @map("completed_at")
313
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
314
+ targetConnectedAccount ConnectedAccount? @relation(fields: [targetConnectedAccountId], references: [id], onDelete: SetNull)
315
+ folder Folder? @relation("UploadSessionFolder", fields: [folderId], references: [id], onDelete: SetNull)
316
+
317
+ @@index([userId])
318
+ @@index([folderId])
319
+ @@map("upload_sessions")
320
+ }
321
+
322
+ model AuditLog {
323
+ id String @id @default(uuid())
324
+ userId String? @map("user_id")
325
+ action String
326
+ entityType String @map("entity_type")
327
+ entityId String? @map("entity_id")
328
+ metadata Json?
329
+ createdAt DateTime @default(now()) @map("created_at")
330
+ user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
331
+
332
+ @@index([userId])
333
+ @@map("audit_logs")
334
+ }
335
+
336
+ model WorkspaceInvite {
337
+ id String @id @default(uuid())
338
+ inviterId String @map("inviter_id")
339
+ inviteeEmail String @map("invitee_email")
340
+ targetType String @default("file") @map("target_type")
341
+ targetId String @default("") @map("target_id")
342
+ role String @default("viewer")
343
+ status String @default("pending")
344
+ revokedAt DateTime? @map("revoked_at")
345
+ acceptedAt DateTime? @map("accepted_at")
346
+ createdAt DateTime @default(now()) @map("created_at")
347
+ updatedAt DateTime @updatedAt @map("updated_at")
348
+ inviter User @relation("WorkspaceInvitesSent", fields: [inviterId], references: [id], onDelete: Cascade)
349
+
350
+ @@unique([inviterId, inviteeEmail, targetType, targetId], map: "workspace_invites_target_unique")
351
+ @@index([inviteeEmail])
352
+ @@index([targetType, targetId])
353
+ @@map("workspace_invites")
354
+ }