@intelligo-dev/core 1.0.0-beta.13 → 1.0.0-beta.15

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.
Files changed (42) hide show
  1. package/dist/db/schema/billing.d.ts +207 -2
  2. package/dist/db/schema/billing.d.ts.map +1 -1
  3. package/dist/db/schema/billing.js +32 -3
  4. package/dist/db/schema/billing.js.map +1 -1
  5. package/dist/db/schema/usage.d.ts +20 -2
  6. package/dist/db/schema/usage.d.ts.map +1 -1
  7. package/dist/db/schema/usage.js +17 -9
  8. package/dist/db/schema/usage.js.map +1 -1
  9. package/dist/env.d.ts.map +1 -1
  10. package/dist/env.js +7 -1
  11. package/dist/env.js.map +1 -1
  12. package/dist/identity/index.d.ts +4 -3
  13. package/dist/identity/index.d.ts.map +1 -1
  14. package/dist/identity/index.js +3 -2
  15. package/dist/identity/index.js.map +1 -1
  16. package/dist/identity/service.d.ts +20 -4
  17. package/dist/identity/service.d.ts.map +1 -1
  18. package/dist/identity/service.js +78 -3
  19. package/dist/identity/service.js.map +1 -1
  20. package/dist/identity/types.d.ts +28 -1
  21. package/dist/identity/types.d.ts.map +1 -1
  22. package/dist/notifications/index.d.ts +1 -1
  23. package/dist/notifications/index.d.ts.map +1 -1
  24. package/dist/notifications/index.js.map +1 -1
  25. package/dist/notifications/types.d.ts +8 -1
  26. package/dist/notifications/types.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/db/migrations/0003_local_payments.sql +18 -0
  29. package/src/db/migrations/0004_usage_subjects.sql +5 -0
  30. package/src/db/migrations/README.md +31 -2
  31. package/src/db/migrations/legacy-chain.json +13 -4
  32. package/src/db/migrations/meta/0003_snapshot.json +4501 -0
  33. package/src/db/migrations/meta/0004_snapshot.json +4504 -0
  34. package/src/db/migrations/meta/_journal.json +14 -0
  35. package/src/db/schema/billing.ts +39 -3
  36. package/src/db/schema/usage.ts +17 -9
  37. package/src/env.ts +10 -3
  38. package/src/identity/index.ts +4 -1
  39. package/src/identity/service.ts +106 -5
  40. package/src/identity/types.ts +30 -0
  41. package/src/notifications/index.ts +5 -1
  42. package/src/notifications/types.ts +9 -1
@@ -0,0 +1,4504 @@
1
+ {
2
+ "id": "1cad05f9-9c1b-4ee8-9a3b-f8f0e8a11a46",
3
+ "prevId": "25fa76d2-5b6b-4004-9785-846ea1227c55",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.agents": {
8
+ "name": "agents",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "name": {
18
+ "name": "name",
19
+ "type": "jsonb",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "description": {
24
+ "name": "description",
25
+ "type": "jsonb",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "system_prompt_key": {
30
+ "name": "system_prompt_key",
31
+ "type": "text",
32
+ "primaryKey": false,
33
+ "notNull": true
34
+ },
35
+ "system_prompt": {
36
+ "name": "system_prompt",
37
+ "type": "jsonb",
38
+ "primaryKey": false,
39
+ "notNull": false
40
+ },
41
+ "model_config": {
42
+ "name": "model_config",
43
+ "type": "jsonb",
44
+ "primaryKey": false,
45
+ "notNull": false
46
+ },
47
+ "icon": {
48
+ "name": "icon",
49
+ "type": "text",
50
+ "primaryKey": false,
51
+ "notNull": true
52
+ },
53
+ "default_model": {
54
+ "name": "default_model",
55
+ "type": "text",
56
+ "primaryKey": false,
57
+ "notNull": true
58
+ },
59
+ "max_steps": {
60
+ "name": "max_steps",
61
+ "type": "integer",
62
+ "primaryKey": false,
63
+ "notNull": true
64
+ },
65
+ "context_window_size": {
66
+ "name": "context_window_size",
67
+ "type": "integer",
68
+ "primaryKey": false,
69
+ "notNull": true
70
+ },
71
+ "tools": {
72
+ "name": "tools",
73
+ "type": "jsonb",
74
+ "primaryKey": false,
75
+ "notNull": true,
76
+ "default": "'[]'::jsonb"
77
+ },
78
+ "base_path": {
79
+ "name": "base_path",
80
+ "type": "text",
81
+ "primaryKey": false,
82
+ "notNull": true
83
+ },
84
+ "is_active": {
85
+ "name": "is_active",
86
+ "type": "boolean",
87
+ "primaryKey": false,
88
+ "notNull": true,
89
+ "default": true
90
+ },
91
+ "suggestions": {
92
+ "name": "suggestions",
93
+ "type": "jsonb",
94
+ "primaryKey": false,
95
+ "notNull": true,
96
+ "default": "'[]'::jsonb"
97
+ },
98
+ "is_system": {
99
+ "name": "is_system",
100
+ "type": "boolean",
101
+ "primaryKey": false,
102
+ "notNull": true,
103
+ "default": true
104
+ },
105
+ "feature_key": {
106
+ "name": "feature_key",
107
+ "type": "text",
108
+ "primaryKey": false,
109
+ "notNull": false
110
+ },
111
+ "color": {
112
+ "name": "color",
113
+ "type": "text",
114
+ "primaryKey": false,
115
+ "notNull": true,
116
+ "default": "'bg-gray-500'"
117
+ },
118
+ "created_at": {
119
+ "name": "created_at",
120
+ "type": "timestamp",
121
+ "primaryKey": false,
122
+ "notNull": true,
123
+ "default": "now()"
124
+ },
125
+ "updated_at": {
126
+ "name": "updated_at",
127
+ "type": "timestamp",
128
+ "primaryKey": false,
129
+ "notNull": true,
130
+ "default": "now()"
131
+ }
132
+ },
133
+ "indexes": {},
134
+ "foreignKeys": {},
135
+ "compositePrimaryKeys": {},
136
+ "uniqueConstraints": {},
137
+ "policies": {},
138
+ "checkConstraints": {},
139
+ "isRLSEnabled": false
140
+ },
141
+ "public.attachments": {
142
+ "name": "attachments",
143
+ "schema": "",
144
+ "columns": {
145
+ "id": {
146
+ "name": "id",
147
+ "type": "text",
148
+ "primaryKey": true,
149
+ "notNull": true
150
+ },
151
+ "workspace_id": {
152
+ "name": "workspace_id",
153
+ "type": "text",
154
+ "primaryKey": false,
155
+ "notNull": true
156
+ },
157
+ "user_id": {
158
+ "name": "user_id",
159
+ "type": "text",
160
+ "primaryKey": false,
161
+ "notNull": true
162
+ },
163
+ "conversation_id": {
164
+ "name": "conversation_id",
165
+ "type": "text",
166
+ "primaryKey": false,
167
+ "notNull": false
168
+ },
169
+ "storage_key": {
170
+ "name": "storage_key",
171
+ "type": "text",
172
+ "primaryKey": false,
173
+ "notNull": true
174
+ },
175
+ "filename": {
176
+ "name": "filename",
177
+ "type": "text",
178
+ "primaryKey": false,
179
+ "notNull": true
180
+ },
181
+ "media_type": {
182
+ "name": "media_type",
183
+ "type": "text",
184
+ "primaryKey": false,
185
+ "notNull": true
186
+ },
187
+ "size_bytes": {
188
+ "name": "size_bytes",
189
+ "type": "integer",
190
+ "primaryKey": false,
191
+ "notNull": true
192
+ },
193
+ "extracted_text": {
194
+ "name": "extracted_text",
195
+ "type": "text",
196
+ "primaryKey": false,
197
+ "notNull": false
198
+ },
199
+ "created_at": {
200
+ "name": "created_at",
201
+ "type": "timestamp",
202
+ "primaryKey": false,
203
+ "notNull": true,
204
+ "default": "now()"
205
+ }
206
+ },
207
+ "indexes": {
208
+ "attachments_workspace_id_idx": {
209
+ "name": "attachments_workspace_id_idx",
210
+ "columns": [
211
+ {
212
+ "expression": "workspace_id",
213
+ "isExpression": false,
214
+ "asc": true,
215
+ "nulls": "last"
216
+ }
217
+ ],
218
+ "isUnique": false,
219
+ "concurrently": false,
220
+ "method": "btree",
221
+ "with": {}
222
+ },
223
+ "attachments_conversation_id_idx": {
224
+ "name": "attachments_conversation_id_idx",
225
+ "columns": [
226
+ {
227
+ "expression": "conversation_id",
228
+ "isExpression": false,
229
+ "asc": true,
230
+ "nulls": "last"
231
+ }
232
+ ],
233
+ "isUnique": false,
234
+ "concurrently": false,
235
+ "method": "btree",
236
+ "with": {}
237
+ },
238
+ "attachments_storage_key_idx": {
239
+ "name": "attachments_storage_key_idx",
240
+ "columns": [
241
+ {
242
+ "expression": "storage_key",
243
+ "isExpression": false,
244
+ "asc": true,
245
+ "nulls": "last"
246
+ }
247
+ ],
248
+ "isUnique": true,
249
+ "concurrently": false,
250
+ "method": "btree",
251
+ "with": {}
252
+ }
253
+ },
254
+ "foreignKeys": {
255
+ "attachments_workspace_id_organization_id_fk": {
256
+ "name": "attachments_workspace_id_organization_id_fk",
257
+ "tableFrom": "attachments",
258
+ "tableTo": "organization",
259
+ "columnsFrom": ["workspace_id"],
260
+ "columnsTo": ["id"],
261
+ "onDelete": "cascade",
262
+ "onUpdate": "no action"
263
+ },
264
+ "attachments_user_id_users_id_fk": {
265
+ "name": "attachments_user_id_users_id_fk",
266
+ "tableFrom": "attachments",
267
+ "tableTo": "users",
268
+ "columnsFrom": ["user_id"],
269
+ "columnsTo": ["id"],
270
+ "onDelete": "cascade",
271
+ "onUpdate": "no action"
272
+ },
273
+ "attachments_conversation_id_conversations_id_fk": {
274
+ "name": "attachments_conversation_id_conversations_id_fk",
275
+ "tableFrom": "attachments",
276
+ "tableTo": "conversations",
277
+ "columnsFrom": ["conversation_id"],
278
+ "columnsTo": ["id"],
279
+ "onDelete": "set null",
280
+ "onUpdate": "no action"
281
+ }
282
+ },
283
+ "compositePrimaryKeys": {},
284
+ "uniqueConstraints": {},
285
+ "policies": {},
286
+ "checkConstraints": {},
287
+ "isRLSEnabled": false
288
+ },
289
+ "public.conversations": {
290
+ "name": "conversations",
291
+ "schema": "",
292
+ "columns": {
293
+ "id": {
294
+ "name": "id",
295
+ "type": "text",
296
+ "primaryKey": true,
297
+ "notNull": true
298
+ },
299
+ "workspace_id": {
300
+ "name": "workspace_id",
301
+ "type": "text",
302
+ "primaryKey": false,
303
+ "notNull": true
304
+ },
305
+ "user_id": {
306
+ "name": "user_id",
307
+ "type": "text",
308
+ "primaryKey": false,
309
+ "notNull": true
310
+ },
311
+ "agent_id": {
312
+ "name": "agent_id",
313
+ "type": "text",
314
+ "primaryKey": false,
315
+ "notNull": true
316
+ },
317
+ "title": {
318
+ "name": "title",
319
+ "type": "text",
320
+ "primaryKey": false,
321
+ "notNull": false
322
+ },
323
+ "model_id": {
324
+ "name": "model_id",
325
+ "type": "text",
326
+ "primaryKey": false,
327
+ "notNull": false
328
+ },
329
+ "visibility": {
330
+ "name": "visibility",
331
+ "type": "text",
332
+ "primaryKey": false,
333
+ "notNull": true,
334
+ "default": "'private'"
335
+ },
336
+ "metadata": {
337
+ "name": "metadata",
338
+ "type": "jsonb",
339
+ "primaryKey": false,
340
+ "notNull": false
341
+ },
342
+ "created_at": {
343
+ "name": "created_at",
344
+ "type": "timestamp",
345
+ "primaryKey": false,
346
+ "notNull": true,
347
+ "default": "now()"
348
+ },
349
+ "updated_at": {
350
+ "name": "updated_at",
351
+ "type": "timestamp",
352
+ "primaryKey": false,
353
+ "notNull": true,
354
+ "default": "now()"
355
+ }
356
+ },
357
+ "indexes": {
358
+ "conversations_workspace_id_idx": {
359
+ "name": "conversations_workspace_id_idx",
360
+ "columns": [
361
+ {
362
+ "expression": "workspace_id",
363
+ "isExpression": false,
364
+ "asc": true,
365
+ "nulls": "last"
366
+ }
367
+ ],
368
+ "isUnique": false,
369
+ "concurrently": false,
370
+ "method": "btree",
371
+ "with": {}
372
+ },
373
+ "conversations_user_id_idx": {
374
+ "name": "conversations_user_id_idx",
375
+ "columns": [
376
+ {
377
+ "expression": "user_id",
378
+ "isExpression": false,
379
+ "asc": true,
380
+ "nulls": "last"
381
+ }
382
+ ],
383
+ "isUnique": false,
384
+ "concurrently": false,
385
+ "method": "btree",
386
+ "with": {}
387
+ },
388
+ "conversations_workspace_updated_idx": {
389
+ "name": "conversations_workspace_updated_idx",
390
+ "columns": [
391
+ {
392
+ "expression": "workspace_id",
393
+ "isExpression": false,
394
+ "asc": true,
395
+ "nulls": "last"
396
+ },
397
+ {
398
+ "expression": "updated_at",
399
+ "isExpression": false,
400
+ "asc": true,
401
+ "nulls": "last"
402
+ }
403
+ ],
404
+ "isUnique": false,
405
+ "concurrently": false,
406
+ "method": "btree",
407
+ "with": {}
408
+ },
409
+ "conversations_workspace_user_idx": {
410
+ "name": "conversations_workspace_user_idx",
411
+ "columns": [
412
+ {
413
+ "expression": "workspace_id",
414
+ "isExpression": false,
415
+ "asc": true,
416
+ "nulls": "last"
417
+ },
418
+ {
419
+ "expression": "user_id",
420
+ "isExpression": false,
421
+ "asc": true,
422
+ "nulls": "last"
423
+ }
424
+ ],
425
+ "isUnique": false,
426
+ "concurrently": false,
427
+ "method": "btree",
428
+ "with": {}
429
+ }
430
+ },
431
+ "foreignKeys": {
432
+ "conversations_workspace_id_organization_id_fk": {
433
+ "name": "conversations_workspace_id_organization_id_fk",
434
+ "tableFrom": "conversations",
435
+ "tableTo": "organization",
436
+ "columnsFrom": ["workspace_id"],
437
+ "columnsTo": ["id"],
438
+ "onDelete": "cascade",
439
+ "onUpdate": "no action"
440
+ },
441
+ "conversations_user_id_users_id_fk": {
442
+ "name": "conversations_user_id_users_id_fk",
443
+ "tableFrom": "conversations",
444
+ "tableTo": "users",
445
+ "columnsFrom": ["user_id"],
446
+ "columnsTo": ["id"],
447
+ "onDelete": "cascade",
448
+ "onUpdate": "no action"
449
+ }
450
+ },
451
+ "compositePrimaryKeys": {},
452
+ "uniqueConstraints": {},
453
+ "policies": {},
454
+ "checkConstraints": {},
455
+ "isRLSEnabled": false
456
+ },
457
+ "public.documents": {
458
+ "name": "documents",
459
+ "schema": "",
460
+ "columns": {
461
+ "id": {
462
+ "name": "id",
463
+ "type": "text",
464
+ "primaryKey": false,
465
+ "notNull": true
466
+ },
467
+ "created_at": {
468
+ "name": "created_at",
469
+ "type": "timestamp",
470
+ "primaryKey": false,
471
+ "notNull": true,
472
+ "default": "now()"
473
+ },
474
+ "title": {
475
+ "name": "title",
476
+ "type": "text",
477
+ "primaryKey": false,
478
+ "notNull": true
479
+ },
480
+ "content": {
481
+ "name": "content",
482
+ "type": "text",
483
+ "primaryKey": false,
484
+ "notNull": false
485
+ },
486
+ "kind": {
487
+ "name": "kind",
488
+ "type": "text",
489
+ "primaryKey": false,
490
+ "notNull": true,
491
+ "default": "'text'"
492
+ },
493
+ "metadata": {
494
+ "name": "metadata",
495
+ "type": "jsonb",
496
+ "primaryKey": false,
497
+ "notNull": false
498
+ },
499
+ "user_id": {
500
+ "name": "user_id",
501
+ "type": "text",
502
+ "primaryKey": false,
503
+ "notNull": true
504
+ },
505
+ "workspace_id": {
506
+ "name": "workspace_id",
507
+ "type": "text",
508
+ "primaryKey": false,
509
+ "notNull": true
510
+ }
511
+ },
512
+ "indexes": {
513
+ "documents_workspace_id_idx": {
514
+ "name": "documents_workspace_id_idx",
515
+ "columns": [
516
+ {
517
+ "expression": "workspace_id",
518
+ "isExpression": false,
519
+ "asc": true,
520
+ "nulls": "last"
521
+ }
522
+ ],
523
+ "isUnique": false,
524
+ "concurrently": false,
525
+ "method": "btree",
526
+ "with": {}
527
+ },
528
+ "documents_user_id_idx": {
529
+ "name": "documents_user_id_idx",
530
+ "columns": [
531
+ {
532
+ "expression": "user_id",
533
+ "isExpression": false,
534
+ "asc": true,
535
+ "nulls": "last"
536
+ }
537
+ ],
538
+ "isUnique": false,
539
+ "concurrently": false,
540
+ "method": "btree",
541
+ "with": {}
542
+ }
543
+ },
544
+ "foreignKeys": {
545
+ "documents_user_id_users_id_fk": {
546
+ "name": "documents_user_id_users_id_fk",
547
+ "tableFrom": "documents",
548
+ "tableTo": "users",
549
+ "columnsFrom": ["user_id"],
550
+ "columnsTo": ["id"],
551
+ "onDelete": "cascade",
552
+ "onUpdate": "no action"
553
+ },
554
+ "documents_workspace_id_organization_id_fk": {
555
+ "name": "documents_workspace_id_organization_id_fk",
556
+ "tableFrom": "documents",
557
+ "tableTo": "organization",
558
+ "columnsFrom": ["workspace_id"],
559
+ "columnsTo": ["id"],
560
+ "onDelete": "cascade",
561
+ "onUpdate": "no action"
562
+ }
563
+ },
564
+ "compositePrimaryKeys": {
565
+ "documents_id_created_at_pk": {
566
+ "name": "documents_id_created_at_pk",
567
+ "columns": ["id", "created_at"]
568
+ }
569
+ },
570
+ "uniqueConstraints": {},
571
+ "policies": {},
572
+ "checkConstraints": {},
573
+ "isRLSEnabled": false
574
+ },
575
+ "public.messages": {
576
+ "name": "messages",
577
+ "schema": "",
578
+ "columns": {
579
+ "id": {
580
+ "name": "id",
581
+ "type": "text",
582
+ "primaryKey": true,
583
+ "notNull": true
584
+ },
585
+ "conversation_id": {
586
+ "name": "conversation_id",
587
+ "type": "text",
588
+ "primaryKey": false,
589
+ "notNull": true
590
+ },
591
+ "role": {
592
+ "name": "role",
593
+ "type": "text",
594
+ "primaryKey": false,
595
+ "notNull": true
596
+ },
597
+ "content": {
598
+ "name": "content",
599
+ "type": "text",
600
+ "primaryKey": false,
601
+ "notNull": false
602
+ },
603
+ "parts": {
604
+ "name": "parts",
605
+ "type": "text",
606
+ "primaryKey": false,
607
+ "notNull": true
608
+ },
609
+ "attachments": {
610
+ "name": "attachments",
611
+ "type": "text",
612
+ "primaryKey": false,
613
+ "notNull": false
614
+ },
615
+ "tool_invocations": {
616
+ "name": "tool_invocations",
617
+ "type": "text",
618
+ "primaryKey": false,
619
+ "notNull": false
620
+ },
621
+ "token_count": {
622
+ "name": "token_count",
623
+ "type": "integer",
624
+ "primaryKey": false,
625
+ "notNull": false
626
+ },
627
+ "created_at": {
628
+ "name": "created_at",
629
+ "type": "timestamp",
630
+ "primaryKey": false,
631
+ "notNull": true,
632
+ "default": "now()"
633
+ }
634
+ },
635
+ "indexes": {
636
+ "messages_conversation_id_idx": {
637
+ "name": "messages_conversation_id_idx",
638
+ "columns": [
639
+ {
640
+ "expression": "conversation_id",
641
+ "isExpression": false,
642
+ "asc": true,
643
+ "nulls": "last"
644
+ }
645
+ ],
646
+ "isUnique": false,
647
+ "concurrently": false,
648
+ "method": "btree",
649
+ "with": {}
650
+ },
651
+ "messages_conversation_created_idx": {
652
+ "name": "messages_conversation_created_idx",
653
+ "columns": [
654
+ {
655
+ "expression": "conversation_id",
656
+ "isExpression": false,
657
+ "asc": true,
658
+ "nulls": "last"
659
+ },
660
+ {
661
+ "expression": "created_at",
662
+ "isExpression": false,
663
+ "asc": true,
664
+ "nulls": "last"
665
+ }
666
+ ],
667
+ "isUnique": false,
668
+ "concurrently": false,
669
+ "method": "btree",
670
+ "with": {}
671
+ }
672
+ },
673
+ "foreignKeys": {
674
+ "messages_conversation_id_conversations_id_fk": {
675
+ "name": "messages_conversation_id_conversations_id_fk",
676
+ "tableFrom": "messages",
677
+ "tableTo": "conversations",
678
+ "columnsFrom": ["conversation_id"],
679
+ "columnsTo": ["id"],
680
+ "onDelete": "cascade",
681
+ "onUpdate": "no action"
682
+ }
683
+ },
684
+ "compositePrimaryKeys": {},
685
+ "uniqueConstraints": {},
686
+ "policies": {},
687
+ "checkConstraints": {},
688
+ "isRLSEnabled": false
689
+ },
690
+ "public.votes": {
691
+ "name": "votes",
692
+ "schema": "",
693
+ "columns": {
694
+ "chat_id": {
695
+ "name": "chat_id",
696
+ "type": "text",
697
+ "primaryKey": false,
698
+ "notNull": true
699
+ },
700
+ "message_id": {
701
+ "name": "message_id",
702
+ "type": "text",
703
+ "primaryKey": false,
704
+ "notNull": true
705
+ },
706
+ "is_upvoted": {
707
+ "name": "is_upvoted",
708
+ "type": "boolean",
709
+ "primaryKey": false,
710
+ "notNull": true
711
+ }
712
+ },
713
+ "indexes": {
714
+ "votes_message_id_idx": {
715
+ "name": "votes_message_id_idx",
716
+ "columns": [
717
+ {
718
+ "expression": "message_id",
719
+ "isExpression": false,
720
+ "asc": true,
721
+ "nulls": "last"
722
+ }
723
+ ],
724
+ "isUnique": false,
725
+ "concurrently": false,
726
+ "method": "btree",
727
+ "with": {}
728
+ }
729
+ },
730
+ "foreignKeys": {
731
+ "votes_chat_id_conversations_id_fk": {
732
+ "name": "votes_chat_id_conversations_id_fk",
733
+ "tableFrom": "votes",
734
+ "tableTo": "conversations",
735
+ "columnsFrom": ["chat_id"],
736
+ "columnsTo": ["id"],
737
+ "onDelete": "cascade",
738
+ "onUpdate": "no action"
739
+ },
740
+ "votes_message_id_messages_id_fk": {
741
+ "name": "votes_message_id_messages_id_fk",
742
+ "tableFrom": "votes",
743
+ "tableTo": "messages",
744
+ "columnsFrom": ["message_id"],
745
+ "columnsTo": ["id"],
746
+ "onDelete": "cascade",
747
+ "onUpdate": "no action"
748
+ }
749
+ },
750
+ "compositePrimaryKeys": {
751
+ "votes_chat_id_message_id_pk": {
752
+ "name": "votes_chat_id_message_id_pk",
753
+ "columns": ["chat_id", "message_id"]
754
+ }
755
+ },
756
+ "uniqueConstraints": {},
757
+ "policies": {},
758
+ "checkConstraints": {},
759
+ "isRLSEnabled": false
760
+ },
761
+ "public.accounts": {
762
+ "name": "accounts",
763
+ "schema": "",
764
+ "columns": {
765
+ "id": {
766
+ "name": "id",
767
+ "type": "text",
768
+ "primaryKey": true,
769
+ "notNull": true
770
+ },
771
+ "user_id": {
772
+ "name": "user_id",
773
+ "type": "text",
774
+ "primaryKey": false,
775
+ "notNull": true
776
+ },
777
+ "account_id": {
778
+ "name": "account_id",
779
+ "type": "text",
780
+ "primaryKey": false,
781
+ "notNull": true
782
+ },
783
+ "provider_id": {
784
+ "name": "provider_id",
785
+ "type": "text",
786
+ "primaryKey": false,
787
+ "notNull": true
788
+ },
789
+ "access_token": {
790
+ "name": "access_token",
791
+ "type": "text",
792
+ "primaryKey": false,
793
+ "notNull": false
794
+ },
795
+ "refresh_token": {
796
+ "name": "refresh_token",
797
+ "type": "text",
798
+ "primaryKey": false,
799
+ "notNull": false
800
+ },
801
+ "access_token_expires_at": {
802
+ "name": "access_token_expires_at",
803
+ "type": "timestamp",
804
+ "primaryKey": false,
805
+ "notNull": false
806
+ },
807
+ "refresh_token_expires_at": {
808
+ "name": "refresh_token_expires_at",
809
+ "type": "timestamp",
810
+ "primaryKey": false,
811
+ "notNull": false
812
+ },
813
+ "scope": {
814
+ "name": "scope",
815
+ "type": "text",
816
+ "primaryKey": false,
817
+ "notNull": false
818
+ },
819
+ "id_token": {
820
+ "name": "id_token",
821
+ "type": "text",
822
+ "primaryKey": false,
823
+ "notNull": false
824
+ },
825
+ "password": {
826
+ "name": "password",
827
+ "type": "text",
828
+ "primaryKey": false,
829
+ "notNull": false
830
+ },
831
+ "created_at": {
832
+ "name": "created_at",
833
+ "type": "timestamp",
834
+ "primaryKey": false,
835
+ "notNull": true,
836
+ "default": "now()"
837
+ },
838
+ "updated_at": {
839
+ "name": "updated_at",
840
+ "type": "timestamp",
841
+ "primaryKey": false,
842
+ "notNull": true,
843
+ "default": "now()"
844
+ }
845
+ },
846
+ "indexes": {
847
+ "accounts_user_id_idx": {
848
+ "name": "accounts_user_id_idx",
849
+ "columns": [
850
+ {
851
+ "expression": "user_id",
852
+ "isExpression": false,
853
+ "asc": true,
854
+ "nulls": "last"
855
+ }
856
+ ],
857
+ "isUnique": false,
858
+ "concurrently": false,
859
+ "method": "btree",
860
+ "with": {}
861
+ }
862
+ },
863
+ "foreignKeys": {
864
+ "accounts_user_id_users_id_fk": {
865
+ "name": "accounts_user_id_users_id_fk",
866
+ "tableFrom": "accounts",
867
+ "tableTo": "users",
868
+ "columnsFrom": ["user_id"],
869
+ "columnsTo": ["id"],
870
+ "onDelete": "cascade",
871
+ "onUpdate": "no action"
872
+ }
873
+ },
874
+ "compositePrimaryKeys": {},
875
+ "uniqueConstraints": {},
876
+ "policies": {},
877
+ "checkConstraints": {},
878
+ "isRLSEnabled": false
879
+ },
880
+ "public.invitation": {
881
+ "name": "invitation",
882
+ "schema": "",
883
+ "columns": {
884
+ "id": {
885
+ "name": "id",
886
+ "type": "text",
887
+ "primaryKey": true,
888
+ "notNull": true
889
+ },
890
+ "organization_id": {
891
+ "name": "organization_id",
892
+ "type": "text",
893
+ "primaryKey": false,
894
+ "notNull": true
895
+ },
896
+ "email": {
897
+ "name": "email",
898
+ "type": "text",
899
+ "primaryKey": false,
900
+ "notNull": true
901
+ },
902
+ "role": {
903
+ "name": "role",
904
+ "type": "text",
905
+ "primaryKey": false,
906
+ "notNull": true
907
+ },
908
+ "status": {
909
+ "name": "status",
910
+ "type": "text",
911
+ "primaryKey": false,
912
+ "notNull": true
913
+ },
914
+ "expires_at": {
915
+ "name": "expires_at",
916
+ "type": "timestamp",
917
+ "primaryKey": false,
918
+ "notNull": true
919
+ },
920
+ "inviter_id": {
921
+ "name": "inviter_id",
922
+ "type": "text",
923
+ "primaryKey": false,
924
+ "notNull": false
925
+ },
926
+ "created_at": {
927
+ "name": "created_at",
928
+ "type": "timestamp",
929
+ "primaryKey": false,
930
+ "notNull": true,
931
+ "default": "now()"
932
+ },
933
+ "updated_at": {
934
+ "name": "updated_at",
935
+ "type": "timestamp",
936
+ "primaryKey": false,
937
+ "notNull": true,
938
+ "default": "now()"
939
+ }
940
+ },
941
+ "indexes": {
942
+ "invitation_organization_id_idx": {
943
+ "name": "invitation_organization_id_idx",
944
+ "columns": [
945
+ {
946
+ "expression": "organization_id",
947
+ "isExpression": false,
948
+ "asc": true,
949
+ "nulls": "last"
950
+ }
951
+ ],
952
+ "isUnique": false,
953
+ "concurrently": false,
954
+ "method": "btree",
955
+ "with": {}
956
+ },
957
+ "invitation_email_idx": {
958
+ "name": "invitation_email_idx",
959
+ "columns": [
960
+ {
961
+ "expression": "email",
962
+ "isExpression": false,
963
+ "asc": true,
964
+ "nulls": "last"
965
+ }
966
+ ],
967
+ "isUnique": false,
968
+ "concurrently": false,
969
+ "method": "btree",
970
+ "with": {}
971
+ }
972
+ },
973
+ "foreignKeys": {
974
+ "invitation_organization_id_organization_id_fk": {
975
+ "name": "invitation_organization_id_organization_id_fk",
976
+ "tableFrom": "invitation",
977
+ "tableTo": "organization",
978
+ "columnsFrom": ["organization_id"],
979
+ "columnsTo": ["id"],
980
+ "onDelete": "cascade",
981
+ "onUpdate": "no action"
982
+ },
983
+ "invitation_inviter_id_users_id_fk": {
984
+ "name": "invitation_inviter_id_users_id_fk",
985
+ "tableFrom": "invitation",
986
+ "tableTo": "users",
987
+ "columnsFrom": ["inviter_id"],
988
+ "columnsTo": ["id"],
989
+ "onDelete": "set null",
990
+ "onUpdate": "no action"
991
+ }
992
+ },
993
+ "compositePrimaryKeys": {},
994
+ "uniqueConstraints": {},
995
+ "policies": {},
996
+ "checkConstraints": {},
997
+ "isRLSEnabled": false
998
+ },
999
+ "public.member": {
1000
+ "name": "member",
1001
+ "schema": "",
1002
+ "columns": {
1003
+ "id": {
1004
+ "name": "id",
1005
+ "type": "text",
1006
+ "primaryKey": true,
1007
+ "notNull": true
1008
+ },
1009
+ "organization_id": {
1010
+ "name": "organization_id",
1011
+ "type": "text",
1012
+ "primaryKey": false,
1013
+ "notNull": true
1014
+ },
1015
+ "user_id": {
1016
+ "name": "user_id",
1017
+ "type": "text",
1018
+ "primaryKey": false,
1019
+ "notNull": true
1020
+ },
1021
+ "role": {
1022
+ "name": "role",
1023
+ "type": "text",
1024
+ "primaryKey": false,
1025
+ "notNull": true
1026
+ },
1027
+ "created_at": {
1028
+ "name": "created_at",
1029
+ "type": "timestamp",
1030
+ "primaryKey": false,
1031
+ "notNull": true,
1032
+ "default": "now()"
1033
+ },
1034
+ "updated_at": {
1035
+ "name": "updated_at",
1036
+ "type": "timestamp",
1037
+ "primaryKey": false,
1038
+ "notNull": true,
1039
+ "default": "now()"
1040
+ }
1041
+ },
1042
+ "indexes": {
1043
+ "member_organization_id_idx": {
1044
+ "name": "member_organization_id_idx",
1045
+ "columns": [
1046
+ {
1047
+ "expression": "organization_id",
1048
+ "isExpression": false,
1049
+ "asc": true,
1050
+ "nulls": "last"
1051
+ }
1052
+ ],
1053
+ "isUnique": false,
1054
+ "concurrently": false,
1055
+ "method": "btree",
1056
+ "with": {}
1057
+ },
1058
+ "member_user_id_idx": {
1059
+ "name": "member_user_id_idx",
1060
+ "columns": [
1061
+ {
1062
+ "expression": "user_id",
1063
+ "isExpression": false,
1064
+ "asc": true,
1065
+ "nulls": "last"
1066
+ }
1067
+ ],
1068
+ "isUnique": false,
1069
+ "concurrently": false,
1070
+ "method": "btree",
1071
+ "with": {}
1072
+ },
1073
+ "member_organization_user_uniq": {
1074
+ "name": "member_organization_user_uniq",
1075
+ "columns": [
1076
+ {
1077
+ "expression": "organization_id",
1078
+ "isExpression": false,
1079
+ "asc": true,
1080
+ "nulls": "last"
1081
+ },
1082
+ {
1083
+ "expression": "user_id",
1084
+ "isExpression": false,
1085
+ "asc": true,
1086
+ "nulls": "last"
1087
+ }
1088
+ ],
1089
+ "isUnique": true,
1090
+ "concurrently": false,
1091
+ "method": "btree",
1092
+ "with": {}
1093
+ }
1094
+ },
1095
+ "foreignKeys": {
1096
+ "member_organization_id_organization_id_fk": {
1097
+ "name": "member_organization_id_organization_id_fk",
1098
+ "tableFrom": "member",
1099
+ "tableTo": "organization",
1100
+ "columnsFrom": ["organization_id"],
1101
+ "columnsTo": ["id"],
1102
+ "onDelete": "cascade",
1103
+ "onUpdate": "no action"
1104
+ },
1105
+ "member_user_id_users_id_fk": {
1106
+ "name": "member_user_id_users_id_fk",
1107
+ "tableFrom": "member",
1108
+ "tableTo": "users",
1109
+ "columnsFrom": ["user_id"],
1110
+ "columnsTo": ["id"],
1111
+ "onDelete": "cascade",
1112
+ "onUpdate": "no action"
1113
+ }
1114
+ },
1115
+ "compositePrimaryKeys": {},
1116
+ "uniqueConstraints": {},
1117
+ "policies": {},
1118
+ "checkConstraints": {},
1119
+ "isRLSEnabled": false
1120
+ },
1121
+ "public.organization": {
1122
+ "name": "organization",
1123
+ "schema": "",
1124
+ "columns": {
1125
+ "id": {
1126
+ "name": "id",
1127
+ "type": "text",
1128
+ "primaryKey": true,
1129
+ "notNull": true
1130
+ },
1131
+ "name": {
1132
+ "name": "name",
1133
+ "type": "text",
1134
+ "primaryKey": false,
1135
+ "notNull": true
1136
+ },
1137
+ "slug": {
1138
+ "name": "slug",
1139
+ "type": "text",
1140
+ "primaryKey": false,
1141
+ "notNull": false
1142
+ },
1143
+ "logo": {
1144
+ "name": "logo",
1145
+ "type": "text",
1146
+ "primaryKey": false,
1147
+ "notNull": false
1148
+ },
1149
+ "metadata": {
1150
+ "name": "metadata",
1151
+ "type": "text",
1152
+ "primaryKey": false,
1153
+ "notNull": false
1154
+ },
1155
+ "created_at": {
1156
+ "name": "created_at",
1157
+ "type": "timestamp",
1158
+ "primaryKey": false,
1159
+ "notNull": true,
1160
+ "default": "now()"
1161
+ },
1162
+ "updated_at": {
1163
+ "name": "updated_at",
1164
+ "type": "timestamp",
1165
+ "primaryKey": false,
1166
+ "notNull": true,
1167
+ "default": "now()"
1168
+ }
1169
+ },
1170
+ "indexes": {},
1171
+ "foreignKeys": {},
1172
+ "compositePrimaryKeys": {},
1173
+ "uniqueConstraints": {
1174
+ "organization_slug_unique": {
1175
+ "name": "organization_slug_unique",
1176
+ "nullsNotDistinct": false,
1177
+ "columns": ["slug"]
1178
+ }
1179
+ },
1180
+ "policies": {},
1181
+ "checkConstraints": {},
1182
+ "isRLSEnabled": false
1183
+ },
1184
+ "public.sessions": {
1185
+ "name": "sessions",
1186
+ "schema": "",
1187
+ "columns": {
1188
+ "id": {
1189
+ "name": "id",
1190
+ "type": "text",
1191
+ "primaryKey": true,
1192
+ "notNull": true
1193
+ },
1194
+ "user_id": {
1195
+ "name": "user_id",
1196
+ "type": "text",
1197
+ "primaryKey": false,
1198
+ "notNull": true
1199
+ },
1200
+ "token": {
1201
+ "name": "token",
1202
+ "type": "text",
1203
+ "primaryKey": false,
1204
+ "notNull": true
1205
+ },
1206
+ "expires_at": {
1207
+ "name": "expires_at",
1208
+ "type": "timestamp",
1209
+ "primaryKey": false,
1210
+ "notNull": true
1211
+ },
1212
+ "ip_address": {
1213
+ "name": "ip_address",
1214
+ "type": "text",
1215
+ "primaryKey": false,
1216
+ "notNull": false
1217
+ },
1218
+ "user_agent": {
1219
+ "name": "user_agent",
1220
+ "type": "text",
1221
+ "primaryKey": false,
1222
+ "notNull": false
1223
+ },
1224
+ "impersonated_by": {
1225
+ "name": "impersonated_by",
1226
+ "type": "text",
1227
+ "primaryKey": false,
1228
+ "notNull": false
1229
+ },
1230
+ "active_organization_id": {
1231
+ "name": "active_organization_id",
1232
+ "type": "text",
1233
+ "primaryKey": false,
1234
+ "notNull": false
1235
+ },
1236
+ "created_at": {
1237
+ "name": "created_at",
1238
+ "type": "timestamp",
1239
+ "primaryKey": false,
1240
+ "notNull": true,
1241
+ "default": "now()"
1242
+ },
1243
+ "updated_at": {
1244
+ "name": "updated_at",
1245
+ "type": "timestamp",
1246
+ "primaryKey": false,
1247
+ "notNull": true,
1248
+ "default": "now()"
1249
+ }
1250
+ },
1251
+ "indexes": {
1252
+ "sessions_user_id_idx": {
1253
+ "name": "sessions_user_id_idx",
1254
+ "columns": [
1255
+ {
1256
+ "expression": "user_id",
1257
+ "isExpression": false,
1258
+ "asc": true,
1259
+ "nulls": "last"
1260
+ }
1261
+ ],
1262
+ "isUnique": false,
1263
+ "concurrently": false,
1264
+ "method": "btree",
1265
+ "with": {}
1266
+ }
1267
+ },
1268
+ "foreignKeys": {
1269
+ "sessions_user_id_users_id_fk": {
1270
+ "name": "sessions_user_id_users_id_fk",
1271
+ "tableFrom": "sessions",
1272
+ "tableTo": "users",
1273
+ "columnsFrom": ["user_id"],
1274
+ "columnsTo": ["id"],
1275
+ "onDelete": "cascade",
1276
+ "onUpdate": "no action"
1277
+ }
1278
+ },
1279
+ "compositePrimaryKeys": {},
1280
+ "uniqueConstraints": {
1281
+ "sessions_token_unique": {
1282
+ "name": "sessions_token_unique",
1283
+ "nullsNotDistinct": false,
1284
+ "columns": ["token"]
1285
+ }
1286
+ },
1287
+ "policies": {},
1288
+ "checkConstraints": {},
1289
+ "isRLSEnabled": false
1290
+ },
1291
+ "public.users": {
1292
+ "name": "users",
1293
+ "schema": "",
1294
+ "columns": {
1295
+ "id": {
1296
+ "name": "id",
1297
+ "type": "text",
1298
+ "primaryKey": true,
1299
+ "notNull": true
1300
+ },
1301
+ "name": {
1302
+ "name": "name",
1303
+ "type": "text",
1304
+ "primaryKey": false,
1305
+ "notNull": true
1306
+ },
1307
+ "email": {
1308
+ "name": "email",
1309
+ "type": "text",
1310
+ "primaryKey": false,
1311
+ "notNull": true
1312
+ },
1313
+ "email_verified": {
1314
+ "name": "email_verified",
1315
+ "type": "boolean",
1316
+ "primaryKey": false,
1317
+ "notNull": true,
1318
+ "default": false
1319
+ },
1320
+ "image": {
1321
+ "name": "image",
1322
+ "type": "text",
1323
+ "primaryKey": false,
1324
+ "notNull": false
1325
+ },
1326
+ "deleted_at": {
1327
+ "name": "deleted_at",
1328
+ "type": "timestamp",
1329
+ "primaryKey": false,
1330
+ "notNull": false
1331
+ },
1332
+ "created_at": {
1333
+ "name": "created_at",
1334
+ "type": "timestamp",
1335
+ "primaryKey": false,
1336
+ "notNull": true,
1337
+ "default": "now()"
1338
+ },
1339
+ "updated_at": {
1340
+ "name": "updated_at",
1341
+ "type": "timestamp",
1342
+ "primaryKey": false,
1343
+ "notNull": true,
1344
+ "default": "now()"
1345
+ },
1346
+ "onboarding_completed": {
1347
+ "name": "onboarding_completed",
1348
+ "type": "boolean",
1349
+ "primaryKey": false,
1350
+ "notNull": true,
1351
+ "default": false
1352
+ },
1353
+ "onboarding_step": {
1354
+ "name": "onboarding_step",
1355
+ "type": "text",
1356
+ "primaryKey": false,
1357
+ "notNull": false
1358
+ },
1359
+ "preferred_language": {
1360
+ "name": "preferred_language",
1361
+ "type": "text",
1362
+ "primaryKey": false,
1363
+ "notNull": true,
1364
+ "default": "'en'"
1365
+ },
1366
+ "role": {
1367
+ "name": "role",
1368
+ "type": "text",
1369
+ "primaryKey": false,
1370
+ "notNull": false
1371
+ },
1372
+ "banned": {
1373
+ "name": "banned",
1374
+ "type": "boolean",
1375
+ "primaryKey": false,
1376
+ "notNull": true,
1377
+ "default": false
1378
+ },
1379
+ "ban_reason": {
1380
+ "name": "ban_reason",
1381
+ "type": "text",
1382
+ "primaryKey": false,
1383
+ "notNull": false
1384
+ },
1385
+ "ban_expires": {
1386
+ "name": "ban_expires",
1387
+ "type": "timestamp",
1388
+ "primaryKey": false,
1389
+ "notNull": false
1390
+ }
1391
+ },
1392
+ "indexes": {
1393
+ "users_role_idx": {
1394
+ "name": "users_role_idx",
1395
+ "columns": [
1396
+ {
1397
+ "expression": "role",
1398
+ "isExpression": false,
1399
+ "asc": true,
1400
+ "nulls": "last"
1401
+ }
1402
+ ],
1403
+ "isUnique": false,
1404
+ "where": "\"users\".\"role\" IS NOT NULL",
1405
+ "concurrently": false,
1406
+ "method": "btree",
1407
+ "with": {}
1408
+ }
1409
+ },
1410
+ "foreignKeys": {},
1411
+ "compositePrimaryKeys": {},
1412
+ "uniqueConstraints": {
1413
+ "users_email_unique": {
1414
+ "name": "users_email_unique",
1415
+ "nullsNotDistinct": false,
1416
+ "columns": ["email"]
1417
+ }
1418
+ },
1419
+ "policies": {},
1420
+ "checkConstraints": {},
1421
+ "isRLSEnabled": false
1422
+ },
1423
+ "public.verifications": {
1424
+ "name": "verifications",
1425
+ "schema": "",
1426
+ "columns": {
1427
+ "id": {
1428
+ "name": "id",
1429
+ "type": "text",
1430
+ "primaryKey": true,
1431
+ "notNull": true
1432
+ },
1433
+ "identifier": {
1434
+ "name": "identifier",
1435
+ "type": "text",
1436
+ "primaryKey": false,
1437
+ "notNull": true
1438
+ },
1439
+ "value": {
1440
+ "name": "value",
1441
+ "type": "text",
1442
+ "primaryKey": false,
1443
+ "notNull": true
1444
+ },
1445
+ "expires_at": {
1446
+ "name": "expires_at",
1447
+ "type": "timestamp",
1448
+ "primaryKey": false,
1449
+ "notNull": true
1450
+ },
1451
+ "created_at": {
1452
+ "name": "created_at",
1453
+ "type": "timestamp",
1454
+ "primaryKey": false,
1455
+ "notNull": true,
1456
+ "default": "now()"
1457
+ },
1458
+ "updated_at": {
1459
+ "name": "updated_at",
1460
+ "type": "timestamp",
1461
+ "primaryKey": false,
1462
+ "notNull": true,
1463
+ "default": "now()"
1464
+ }
1465
+ },
1466
+ "indexes": {},
1467
+ "foreignKeys": {},
1468
+ "compositePrimaryKeys": {},
1469
+ "uniqueConstraints": {},
1470
+ "policies": {},
1471
+ "checkConstraints": {},
1472
+ "isRLSEnabled": false
1473
+ },
1474
+ "public.billing_settings": {
1475
+ "name": "billing_settings",
1476
+ "schema": "",
1477
+ "columns": {
1478
+ "id": {
1479
+ "name": "id",
1480
+ "type": "text",
1481
+ "primaryKey": true,
1482
+ "notNull": true
1483
+ },
1484
+ "currency": {
1485
+ "name": "currency",
1486
+ "type": "text",
1487
+ "primaryKey": false,
1488
+ "notNull": true,
1489
+ "default": "'USD'"
1490
+ },
1491
+ "usd_rate_micros": {
1492
+ "name": "usd_rate_micros",
1493
+ "type": "bigint",
1494
+ "primaryKey": false,
1495
+ "notNull": true,
1496
+ "default": 1000000
1497
+ },
1498
+ "margin_bp": {
1499
+ "name": "margin_bp",
1500
+ "type": "integer",
1501
+ "primaryKey": false,
1502
+ "notNull": true,
1503
+ "default": 40000
1504
+ },
1505
+ "updated_at": {
1506
+ "name": "updated_at",
1507
+ "type": "timestamp",
1508
+ "primaryKey": false,
1509
+ "notNull": true,
1510
+ "default": "now()"
1511
+ }
1512
+ },
1513
+ "indexes": {},
1514
+ "foreignKeys": {},
1515
+ "compositePrimaryKeys": {},
1516
+ "uniqueConstraints": {},
1517
+ "policies": {},
1518
+ "checkConstraints": {},
1519
+ "isRLSEnabled": false
1520
+ },
1521
+ "public.credit_balances": {
1522
+ "name": "credit_balances",
1523
+ "schema": "",
1524
+ "columns": {
1525
+ "id": {
1526
+ "name": "id",
1527
+ "type": "text",
1528
+ "primaryKey": true,
1529
+ "notNull": true
1530
+ },
1531
+ "workspace_id": {
1532
+ "name": "workspace_id",
1533
+ "type": "text",
1534
+ "primaryKey": false,
1535
+ "notNull": true
1536
+ },
1537
+ "balance_micros": {
1538
+ "name": "balance_micros",
1539
+ "type": "bigint",
1540
+ "primaryKey": false,
1541
+ "notNull": true,
1542
+ "default": 0
1543
+ },
1544
+ "total_purchased_micros": {
1545
+ "name": "total_purchased_micros",
1546
+ "type": "bigint",
1547
+ "primaryKey": false,
1548
+ "notNull": true,
1549
+ "default": 0
1550
+ },
1551
+ "total_used_micros": {
1552
+ "name": "total_used_micros",
1553
+ "type": "bigint",
1554
+ "primaryKey": false,
1555
+ "notNull": true,
1556
+ "default": 0
1557
+ },
1558
+ "currency": {
1559
+ "name": "currency",
1560
+ "type": "text",
1561
+ "primaryKey": false,
1562
+ "notNull": true,
1563
+ "default": "'USD'"
1564
+ },
1565
+ "updated_at": {
1566
+ "name": "updated_at",
1567
+ "type": "timestamp",
1568
+ "primaryKey": false,
1569
+ "notNull": true,
1570
+ "default": "now()"
1571
+ }
1572
+ },
1573
+ "indexes": {},
1574
+ "foreignKeys": {
1575
+ "credit_balances_workspace_id_organization_id_fk": {
1576
+ "name": "credit_balances_workspace_id_organization_id_fk",
1577
+ "tableFrom": "credit_balances",
1578
+ "tableTo": "organization",
1579
+ "columnsFrom": ["workspace_id"],
1580
+ "columnsTo": ["id"],
1581
+ "onDelete": "cascade",
1582
+ "onUpdate": "no action"
1583
+ }
1584
+ },
1585
+ "compositePrimaryKeys": {},
1586
+ "uniqueConstraints": {
1587
+ "credit_balances_workspace_id_unique": {
1588
+ "name": "credit_balances_workspace_id_unique",
1589
+ "nullsNotDistinct": false,
1590
+ "columns": ["workspace_id"]
1591
+ }
1592
+ },
1593
+ "policies": {},
1594
+ "checkConstraints": {},
1595
+ "isRLSEnabled": false
1596
+ },
1597
+ "public.credit_purchases": {
1598
+ "name": "credit_purchases",
1599
+ "schema": "",
1600
+ "columns": {
1601
+ "id": {
1602
+ "name": "id",
1603
+ "type": "text",
1604
+ "primaryKey": true,
1605
+ "notNull": true
1606
+ },
1607
+ "workspace_id": {
1608
+ "name": "workspace_id",
1609
+ "type": "text",
1610
+ "primaryKey": false,
1611
+ "notNull": true
1612
+ },
1613
+ "price_minor": {
1614
+ "name": "price_minor",
1615
+ "type": "integer",
1616
+ "primaryKey": false,
1617
+ "notNull": false
1618
+ },
1619
+ "price_currency": {
1620
+ "name": "price_currency",
1621
+ "type": "text",
1622
+ "primaryKey": false,
1623
+ "notNull": false
1624
+ },
1625
+ "granted_micros": {
1626
+ "name": "granted_micros",
1627
+ "type": "bigint",
1628
+ "primaryKey": false,
1629
+ "notNull": false
1630
+ },
1631
+ "granted_currency": {
1632
+ "name": "granted_currency",
1633
+ "type": "text",
1634
+ "primaryKey": false,
1635
+ "notNull": false
1636
+ },
1637
+ "stripe_payment_intent_id": {
1638
+ "name": "stripe_payment_intent_id",
1639
+ "type": "text",
1640
+ "primaryKey": false,
1641
+ "notNull": false
1642
+ },
1643
+ "stripe_checkout_session_id": {
1644
+ "name": "stripe_checkout_session_id",
1645
+ "type": "text",
1646
+ "primaryKey": false,
1647
+ "notNull": false
1648
+ },
1649
+ "status": {
1650
+ "name": "status",
1651
+ "type": "text",
1652
+ "primaryKey": false,
1653
+ "notNull": true,
1654
+ "default": "'pending'"
1655
+ },
1656
+ "created_at": {
1657
+ "name": "created_at",
1658
+ "type": "timestamp",
1659
+ "primaryKey": false,
1660
+ "notNull": true,
1661
+ "default": "now()"
1662
+ }
1663
+ },
1664
+ "indexes": {
1665
+ "credit_purchases_workspace_id_idx": {
1666
+ "name": "credit_purchases_workspace_id_idx",
1667
+ "columns": [
1668
+ {
1669
+ "expression": "workspace_id",
1670
+ "isExpression": false,
1671
+ "asc": true,
1672
+ "nulls": "last"
1673
+ }
1674
+ ],
1675
+ "isUnique": false,
1676
+ "concurrently": false,
1677
+ "method": "btree",
1678
+ "with": {}
1679
+ }
1680
+ },
1681
+ "foreignKeys": {
1682
+ "credit_purchases_workspace_id_organization_id_fk": {
1683
+ "name": "credit_purchases_workspace_id_organization_id_fk",
1684
+ "tableFrom": "credit_purchases",
1685
+ "tableTo": "organization",
1686
+ "columnsFrom": ["workspace_id"],
1687
+ "columnsTo": ["id"],
1688
+ "onDelete": "cascade",
1689
+ "onUpdate": "no action"
1690
+ }
1691
+ },
1692
+ "compositePrimaryKeys": {},
1693
+ "uniqueConstraints": {},
1694
+ "policies": {},
1695
+ "checkConstraints": {},
1696
+ "isRLSEnabled": false
1697
+ },
1698
+ "public.credit_reservations": {
1699
+ "name": "credit_reservations",
1700
+ "schema": "",
1701
+ "columns": {
1702
+ "id": {
1703
+ "name": "id",
1704
+ "type": "text",
1705
+ "primaryKey": true,
1706
+ "notNull": true
1707
+ },
1708
+ "workspace_id": {
1709
+ "name": "workspace_id",
1710
+ "type": "text",
1711
+ "primaryKey": false,
1712
+ "notNull": true
1713
+ },
1714
+ "request_id": {
1715
+ "name": "request_id",
1716
+ "type": "text",
1717
+ "primaryKey": false,
1718
+ "notNull": true
1719
+ },
1720
+ "estimated_micros": {
1721
+ "name": "estimated_micros",
1722
+ "type": "bigint",
1723
+ "primaryKey": false,
1724
+ "notNull": true,
1725
+ "default": 0
1726
+ },
1727
+ "currency": {
1728
+ "name": "currency",
1729
+ "type": "text",
1730
+ "primaryKey": false,
1731
+ "notNull": true,
1732
+ "default": "'USD'"
1733
+ },
1734
+ "status": {
1735
+ "name": "status",
1736
+ "type": "text",
1737
+ "primaryKey": false,
1738
+ "notNull": true,
1739
+ "default": "'active'"
1740
+ },
1741
+ "created_at": {
1742
+ "name": "created_at",
1743
+ "type": "timestamp",
1744
+ "primaryKey": false,
1745
+ "notNull": true,
1746
+ "default": "now()"
1747
+ },
1748
+ "expires_at": {
1749
+ "name": "expires_at",
1750
+ "type": "timestamp",
1751
+ "primaryKey": false,
1752
+ "notNull": true
1753
+ },
1754
+ "settled_at": {
1755
+ "name": "settled_at",
1756
+ "type": "timestamp",
1757
+ "primaryKey": false,
1758
+ "notNull": false
1759
+ }
1760
+ },
1761
+ "indexes": {
1762
+ "credit_reservations_active_idx": {
1763
+ "name": "credit_reservations_active_idx",
1764
+ "columns": [
1765
+ {
1766
+ "expression": "workspace_id",
1767
+ "isExpression": false,
1768
+ "asc": true,
1769
+ "nulls": "last"
1770
+ },
1771
+ {
1772
+ "expression": "status",
1773
+ "isExpression": false,
1774
+ "asc": true,
1775
+ "nulls": "last"
1776
+ },
1777
+ {
1778
+ "expression": "expires_at",
1779
+ "isExpression": false,
1780
+ "asc": true,
1781
+ "nulls": "last"
1782
+ }
1783
+ ],
1784
+ "isUnique": false,
1785
+ "concurrently": false,
1786
+ "method": "btree",
1787
+ "with": {}
1788
+ }
1789
+ },
1790
+ "foreignKeys": {
1791
+ "credit_reservations_workspace_id_organization_id_fk": {
1792
+ "name": "credit_reservations_workspace_id_organization_id_fk",
1793
+ "tableFrom": "credit_reservations",
1794
+ "tableTo": "organization",
1795
+ "columnsFrom": ["workspace_id"],
1796
+ "columnsTo": ["id"],
1797
+ "onDelete": "cascade",
1798
+ "onUpdate": "no action"
1799
+ }
1800
+ },
1801
+ "compositePrimaryKeys": {},
1802
+ "uniqueConstraints": {
1803
+ "credit_reservations_request_id_unique": {
1804
+ "name": "credit_reservations_request_id_unique",
1805
+ "nullsNotDistinct": false,
1806
+ "columns": ["request_id"]
1807
+ }
1808
+ },
1809
+ "policies": {},
1810
+ "checkConstraints": {},
1811
+ "isRLSEnabled": false
1812
+ },
1813
+ "public.finance_events": {
1814
+ "name": "finance_events",
1815
+ "schema": "",
1816
+ "columns": {
1817
+ "id": {
1818
+ "name": "id",
1819
+ "type": "text",
1820
+ "primaryKey": true,
1821
+ "notNull": true
1822
+ },
1823
+ "workspace_id": {
1824
+ "name": "workspace_id",
1825
+ "type": "text",
1826
+ "primaryKey": false,
1827
+ "notNull": false
1828
+ },
1829
+ "stripe_event_id": {
1830
+ "name": "stripe_event_id",
1831
+ "type": "text",
1832
+ "primaryKey": false,
1833
+ "notNull": true
1834
+ },
1835
+ "type": {
1836
+ "name": "type",
1837
+ "type": "text",
1838
+ "primaryKey": false,
1839
+ "notNull": true
1840
+ },
1841
+ "amount_minor": {
1842
+ "name": "amount_minor",
1843
+ "type": "integer",
1844
+ "primaryKey": false,
1845
+ "notNull": false
1846
+ },
1847
+ "currency": {
1848
+ "name": "currency",
1849
+ "type": "text",
1850
+ "primaryKey": false,
1851
+ "notNull": false,
1852
+ "default": "'USD'"
1853
+ },
1854
+ "metadata": {
1855
+ "name": "metadata",
1856
+ "type": "text",
1857
+ "primaryKey": false,
1858
+ "notNull": false
1859
+ },
1860
+ "claimed_at": {
1861
+ "name": "claimed_at",
1862
+ "type": "timestamp",
1863
+ "primaryKey": false,
1864
+ "notNull": false
1865
+ },
1866
+ "processed_at": {
1867
+ "name": "processed_at",
1868
+ "type": "timestamp",
1869
+ "primaryKey": false,
1870
+ "notNull": false
1871
+ },
1872
+ "created_at": {
1873
+ "name": "created_at",
1874
+ "type": "timestamp",
1875
+ "primaryKey": false,
1876
+ "notNull": true,
1877
+ "default": "now()"
1878
+ }
1879
+ },
1880
+ "indexes": {},
1881
+ "foreignKeys": {
1882
+ "finance_events_workspace_id_organization_id_fk": {
1883
+ "name": "finance_events_workspace_id_organization_id_fk",
1884
+ "tableFrom": "finance_events",
1885
+ "tableTo": "organization",
1886
+ "columnsFrom": ["workspace_id"],
1887
+ "columnsTo": ["id"],
1888
+ "onDelete": "set null",
1889
+ "onUpdate": "no action"
1890
+ }
1891
+ },
1892
+ "compositePrimaryKeys": {},
1893
+ "uniqueConstraints": {
1894
+ "finance_events_stripe_event_id_unique": {
1895
+ "name": "finance_events_stripe_event_id_unique",
1896
+ "nullsNotDistinct": false,
1897
+ "columns": ["stripe_event_id"]
1898
+ }
1899
+ },
1900
+ "policies": {},
1901
+ "checkConstraints": {},
1902
+ "isRLSEnabled": false
1903
+ },
1904
+ "public.payments": {
1905
+ "name": "payments",
1906
+ "schema": "",
1907
+ "columns": {
1908
+ "id": {
1909
+ "name": "id",
1910
+ "type": "text",
1911
+ "primaryKey": true,
1912
+ "notNull": true
1913
+ },
1914
+ "provider": {
1915
+ "name": "provider",
1916
+ "type": "text",
1917
+ "primaryKey": false,
1918
+ "notNull": true
1919
+ },
1920
+ "invoice_id": {
1921
+ "name": "invoice_id",
1922
+ "type": "text",
1923
+ "primaryKey": false,
1924
+ "notNull": true
1925
+ },
1926
+ "workspace_id": {
1927
+ "name": "workspace_id",
1928
+ "type": "text",
1929
+ "primaryKey": false,
1930
+ "notNull": true
1931
+ },
1932
+ "user_id": {
1933
+ "name": "user_id",
1934
+ "type": "text",
1935
+ "primaryKey": false,
1936
+ "notNull": false
1937
+ },
1938
+ "reference": {
1939
+ "name": "reference",
1940
+ "type": "text",
1941
+ "primaryKey": false,
1942
+ "notNull": true
1943
+ },
1944
+ "amount_minor": {
1945
+ "name": "amount_minor",
1946
+ "type": "integer",
1947
+ "primaryKey": false,
1948
+ "notNull": true
1949
+ },
1950
+ "currency": {
1951
+ "name": "currency",
1952
+ "type": "text",
1953
+ "primaryKey": false,
1954
+ "notNull": true
1955
+ },
1956
+ "status": {
1957
+ "name": "status",
1958
+ "type": "text",
1959
+ "primaryKey": false,
1960
+ "notNull": true,
1961
+ "default": "'pending'"
1962
+ },
1963
+ "fulfilled_at": {
1964
+ "name": "fulfilled_at",
1965
+ "type": "timestamp",
1966
+ "primaryKey": false,
1967
+ "notNull": false
1968
+ },
1969
+ "created_at": {
1970
+ "name": "created_at",
1971
+ "type": "timestamp",
1972
+ "primaryKey": false,
1973
+ "notNull": true,
1974
+ "default": "now()"
1975
+ }
1976
+ },
1977
+ "indexes": {
1978
+ "payments_workspace_id_idx": {
1979
+ "name": "payments_workspace_id_idx",
1980
+ "columns": [
1981
+ {
1982
+ "expression": "workspace_id",
1983
+ "isExpression": false,
1984
+ "asc": true,
1985
+ "nulls": "last"
1986
+ }
1987
+ ],
1988
+ "isUnique": false,
1989
+ "concurrently": false,
1990
+ "method": "btree",
1991
+ "with": {}
1992
+ }
1993
+ },
1994
+ "foreignKeys": {
1995
+ "payments_workspace_id_organization_id_fk": {
1996
+ "name": "payments_workspace_id_organization_id_fk",
1997
+ "tableFrom": "payments",
1998
+ "tableTo": "organization",
1999
+ "columnsFrom": ["workspace_id"],
2000
+ "columnsTo": ["id"],
2001
+ "onDelete": "cascade",
2002
+ "onUpdate": "no action"
2003
+ },
2004
+ "payments_user_id_users_id_fk": {
2005
+ "name": "payments_user_id_users_id_fk",
2006
+ "tableFrom": "payments",
2007
+ "tableTo": "users",
2008
+ "columnsFrom": ["user_id"],
2009
+ "columnsTo": ["id"],
2010
+ "onDelete": "set null",
2011
+ "onUpdate": "no action"
2012
+ }
2013
+ },
2014
+ "compositePrimaryKeys": {},
2015
+ "uniqueConstraints": {
2016
+ "payments_invoice_id_unique": {
2017
+ "name": "payments_invoice_id_unique",
2018
+ "nullsNotDistinct": false,
2019
+ "columns": ["invoice_id"]
2020
+ }
2021
+ },
2022
+ "policies": {},
2023
+ "checkConstraints": {},
2024
+ "isRLSEnabled": false
2025
+ },
2026
+ "public.plans": {
2027
+ "name": "plans",
2028
+ "schema": "",
2029
+ "columns": {
2030
+ "id": {
2031
+ "name": "id",
2032
+ "type": "text",
2033
+ "primaryKey": true,
2034
+ "notNull": true
2035
+ },
2036
+ "name": {
2037
+ "name": "name",
2038
+ "type": "text",
2039
+ "primaryKey": false,
2040
+ "notNull": true
2041
+ },
2042
+ "slug": {
2043
+ "name": "slug",
2044
+ "type": "text",
2045
+ "primaryKey": false,
2046
+ "notNull": true
2047
+ },
2048
+ "description": {
2049
+ "name": "description",
2050
+ "type": "text",
2051
+ "primaryKey": false,
2052
+ "notNull": false
2053
+ },
2054
+ "price_monthly": {
2055
+ "name": "price_monthly",
2056
+ "type": "integer",
2057
+ "primaryKey": false,
2058
+ "notNull": true
2059
+ },
2060
+ "price_yearly": {
2061
+ "name": "price_yearly",
2062
+ "type": "integer",
2063
+ "primaryKey": false,
2064
+ "notNull": true
2065
+ },
2066
+ "stripe_price_id_monthly": {
2067
+ "name": "stripe_price_id_monthly",
2068
+ "type": "text",
2069
+ "primaryKey": false,
2070
+ "notNull": false
2071
+ },
2072
+ "stripe_price_id_yearly": {
2073
+ "name": "stripe_price_id_yearly",
2074
+ "type": "text",
2075
+ "primaryKey": false,
2076
+ "notNull": false
2077
+ },
2078
+ "features": {
2079
+ "name": "features",
2080
+ "type": "text",
2081
+ "primaryKey": false,
2082
+ "notNull": true
2083
+ },
2084
+ "limits": {
2085
+ "name": "limits",
2086
+ "type": "text",
2087
+ "primaryKey": false,
2088
+ "notNull": true
2089
+ },
2090
+ "is_active": {
2091
+ "name": "is_active",
2092
+ "type": "boolean",
2093
+ "primaryKey": false,
2094
+ "notNull": true,
2095
+ "default": true
2096
+ },
2097
+ "sort_order": {
2098
+ "name": "sort_order",
2099
+ "type": "integer",
2100
+ "primaryKey": false,
2101
+ "notNull": true,
2102
+ "default": 0
2103
+ },
2104
+ "created_at": {
2105
+ "name": "created_at",
2106
+ "type": "timestamp",
2107
+ "primaryKey": false,
2108
+ "notNull": true,
2109
+ "default": "now()"
2110
+ },
2111
+ "updated_at": {
2112
+ "name": "updated_at",
2113
+ "type": "timestamp",
2114
+ "primaryKey": false,
2115
+ "notNull": true,
2116
+ "default": "now()"
2117
+ }
2118
+ },
2119
+ "indexes": {},
2120
+ "foreignKeys": {},
2121
+ "compositePrimaryKeys": {},
2122
+ "uniqueConstraints": {
2123
+ "plans_slug_unique": {
2124
+ "name": "plans_slug_unique",
2125
+ "nullsNotDistinct": false,
2126
+ "columns": ["slug"]
2127
+ }
2128
+ },
2129
+ "policies": {},
2130
+ "checkConstraints": {},
2131
+ "isRLSEnabled": false
2132
+ },
2133
+ "public.subscriptions": {
2134
+ "name": "subscriptions",
2135
+ "schema": "",
2136
+ "columns": {
2137
+ "id": {
2138
+ "name": "id",
2139
+ "type": "text",
2140
+ "primaryKey": true,
2141
+ "notNull": true
2142
+ },
2143
+ "workspace_id": {
2144
+ "name": "workspace_id",
2145
+ "type": "text",
2146
+ "primaryKey": false,
2147
+ "notNull": true
2148
+ },
2149
+ "plan_id": {
2150
+ "name": "plan_id",
2151
+ "type": "text",
2152
+ "primaryKey": false,
2153
+ "notNull": true
2154
+ },
2155
+ "stripe_customer_id": {
2156
+ "name": "stripe_customer_id",
2157
+ "type": "text",
2158
+ "primaryKey": false,
2159
+ "notNull": false
2160
+ },
2161
+ "stripe_subscription_id": {
2162
+ "name": "stripe_subscription_id",
2163
+ "type": "text",
2164
+ "primaryKey": false,
2165
+ "notNull": false
2166
+ },
2167
+ "status": {
2168
+ "name": "status",
2169
+ "type": "text",
2170
+ "primaryKey": false,
2171
+ "notNull": true,
2172
+ "default": "'active'"
2173
+ },
2174
+ "billing_mode": {
2175
+ "name": "billing_mode",
2176
+ "type": "text",
2177
+ "primaryKey": false,
2178
+ "notNull": true,
2179
+ "default": "'subscription'"
2180
+ },
2181
+ "current_period_start": {
2182
+ "name": "current_period_start",
2183
+ "type": "timestamp",
2184
+ "primaryKey": false,
2185
+ "notNull": false
2186
+ },
2187
+ "current_period_end": {
2188
+ "name": "current_period_end",
2189
+ "type": "timestamp",
2190
+ "primaryKey": false,
2191
+ "notNull": false
2192
+ },
2193
+ "cancel_at_period_end": {
2194
+ "name": "cancel_at_period_end",
2195
+ "type": "boolean",
2196
+ "primaryKey": false,
2197
+ "notNull": true,
2198
+ "default": false
2199
+ },
2200
+ "created_at": {
2201
+ "name": "created_at",
2202
+ "type": "timestamp",
2203
+ "primaryKey": false,
2204
+ "notNull": true,
2205
+ "default": "now()"
2206
+ },
2207
+ "updated_at": {
2208
+ "name": "updated_at",
2209
+ "type": "timestamp",
2210
+ "primaryKey": false,
2211
+ "notNull": true,
2212
+ "default": "now()"
2213
+ }
2214
+ },
2215
+ "indexes": {
2216
+ "subscriptions_workspace_id_idx": {
2217
+ "name": "subscriptions_workspace_id_idx",
2218
+ "columns": [
2219
+ {
2220
+ "expression": "workspace_id",
2221
+ "isExpression": false,
2222
+ "asc": true,
2223
+ "nulls": "last"
2224
+ }
2225
+ ],
2226
+ "isUnique": false,
2227
+ "concurrently": false,
2228
+ "method": "btree",
2229
+ "with": {}
2230
+ }
2231
+ },
2232
+ "foreignKeys": {
2233
+ "subscriptions_workspace_id_organization_id_fk": {
2234
+ "name": "subscriptions_workspace_id_organization_id_fk",
2235
+ "tableFrom": "subscriptions",
2236
+ "tableTo": "organization",
2237
+ "columnsFrom": ["workspace_id"],
2238
+ "columnsTo": ["id"],
2239
+ "onDelete": "cascade",
2240
+ "onUpdate": "no action"
2241
+ },
2242
+ "subscriptions_plan_id_plans_id_fk": {
2243
+ "name": "subscriptions_plan_id_plans_id_fk",
2244
+ "tableFrom": "subscriptions",
2245
+ "tableTo": "plans",
2246
+ "columnsFrom": ["plan_id"],
2247
+ "columnsTo": ["id"],
2248
+ "onDelete": "restrict",
2249
+ "onUpdate": "no action"
2250
+ }
2251
+ },
2252
+ "compositePrimaryKeys": {},
2253
+ "uniqueConstraints": {
2254
+ "subscriptions_stripe_subscription_id_unique": {
2255
+ "name": "subscriptions_stripe_subscription_id_unique",
2256
+ "nullsNotDistinct": false,
2257
+ "columns": ["stripe_subscription_id"]
2258
+ },
2259
+ "subscriptions_workspace_id_unique": {
2260
+ "name": "subscriptions_workspace_id_unique",
2261
+ "nullsNotDistinct": false,
2262
+ "columns": ["workspace_id"]
2263
+ }
2264
+ },
2265
+ "policies": {},
2266
+ "checkConstraints": {},
2267
+ "isRLSEnabled": false
2268
+ },
2269
+ "public.feature_flags": {
2270
+ "name": "feature_flags",
2271
+ "schema": "",
2272
+ "columns": {
2273
+ "id": {
2274
+ "name": "id",
2275
+ "type": "text",
2276
+ "primaryKey": true,
2277
+ "notNull": true
2278
+ },
2279
+ "name": {
2280
+ "name": "name",
2281
+ "type": "text",
2282
+ "primaryKey": false,
2283
+ "notNull": true
2284
+ },
2285
+ "description": {
2286
+ "name": "description",
2287
+ "type": "text",
2288
+ "primaryKey": false,
2289
+ "notNull": false
2290
+ },
2291
+ "enabled_plans": {
2292
+ "name": "enabled_plans",
2293
+ "type": "text",
2294
+ "primaryKey": false,
2295
+ "notNull": true
2296
+ },
2297
+ "is_active": {
2298
+ "name": "is_active",
2299
+ "type": "boolean",
2300
+ "primaryKey": false,
2301
+ "notNull": true,
2302
+ "default": true
2303
+ },
2304
+ "created_at": {
2305
+ "name": "created_at",
2306
+ "type": "timestamp",
2307
+ "primaryKey": false,
2308
+ "notNull": true,
2309
+ "default": "now()"
2310
+ },
2311
+ "updated_at": {
2312
+ "name": "updated_at",
2313
+ "type": "timestamp",
2314
+ "primaryKey": false,
2315
+ "notNull": true,
2316
+ "default": "now()"
2317
+ }
2318
+ },
2319
+ "indexes": {},
2320
+ "foreignKeys": {},
2321
+ "compositePrimaryKeys": {},
2322
+ "uniqueConstraints": {
2323
+ "feature_flags_name_unique": {
2324
+ "name": "feature_flags_name_unique",
2325
+ "nullsNotDistinct": false,
2326
+ "columns": ["name"]
2327
+ }
2328
+ },
2329
+ "policies": {},
2330
+ "checkConstraints": {},
2331
+ "isRLSEnabled": false
2332
+ },
2333
+ "public.user_facts": {
2334
+ "name": "user_facts",
2335
+ "schema": "",
2336
+ "columns": {
2337
+ "id": {
2338
+ "name": "id",
2339
+ "type": "text",
2340
+ "primaryKey": true,
2341
+ "notNull": true
2342
+ },
2343
+ "user_id": {
2344
+ "name": "user_id",
2345
+ "type": "text",
2346
+ "primaryKey": false,
2347
+ "notNull": true
2348
+ },
2349
+ "workspace_id": {
2350
+ "name": "workspace_id",
2351
+ "type": "text",
2352
+ "primaryKey": false,
2353
+ "notNull": true
2354
+ },
2355
+ "category": {
2356
+ "name": "category",
2357
+ "type": "text",
2358
+ "primaryKey": false,
2359
+ "notNull": true
2360
+ },
2361
+ "key": {
2362
+ "name": "key",
2363
+ "type": "text",
2364
+ "primaryKey": false,
2365
+ "notNull": true
2366
+ },
2367
+ "value": {
2368
+ "name": "value",
2369
+ "type": "jsonb",
2370
+ "primaryKey": false,
2371
+ "notNull": true
2372
+ },
2373
+ "confidence": {
2374
+ "name": "confidence",
2375
+ "type": "double precision",
2376
+ "primaryKey": false,
2377
+ "notNull": true
2378
+ },
2379
+ "importance": {
2380
+ "name": "importance",
2381
+ "type": "integer",
2382
+ "primaryKey": false,
2383
+ "notNull": true,
2384
+ "default": 5
2385
+ },
2386
+ "source_product": {
2387
+ "name": "source_product",
2388
+ "type": "text",
2389
+ "primaryKey": false,
2390
+ "notNull": false
2391
+ },
2392
+ "source_session_id": {
2393
+ "name": "source_session_id",
2394
+ "type": "text",
2395
+ "primaryKey": false,
2396
+ "notNull": false
2397
+ },
2398
+ "source_message_id": {
2399
+ "name": "source_message_id",
2400
+ "type": "text",
2401
+ "primaryKey": false,
2402
+ "notNull": false
2403
+ },
2404
+ "extraction_method": {
2405
+ "name": "extraction_method",
2406
+ "type": "text",
2407
+ "primaryKey": false,
2408
+ "notNull": false
2409
+ },
2410
+ "created_at": {
2411
+ "name": "created_at",
2412
+ "type": "timestamp",
2413
+ "primaryKey": false,
2414
+ "notNull": true,
2415
+ "default": "now()"
2416
+ },
2417
+ "last_confirmed_at": {
2418
+ "name": "last_confirmed_at",
2419
+ "type": "timestamp",
2420
+ "primaryKey": false,
2421
+ "notNull": false
2422
+ },
2423
+ "expires_at": {
2424
+ "name": "expires_at",
2425
+ "type": "timestamp",
2426
+ "primaryKey": false,
2427
+ "notNull": false
2428
+ }
2429
+ },
2430
+ "indexes": {
2431
+ "user_facts_user_idx": {
2432
+ "name": "user_facts_user_idx",
2433
+ "columns": [
2434
+ {
2435
+ "expression": "user_id",
2436
+ "isExpression": false,
2437
+ "asc": true,
2438
+ "nulls": "last"
2439
+ }
2440
+ ],
2441
+ "isUnique": false,
2442
+ "concurrently": false,
2443
+ "method": "btree",
2444
+ "with": {}
2445
+ },
2446
+ "user_facts_workspace_idx": {
2447
+ "name": "user_facts_workspace_idx",
2448
+ "columns": [
2449
+ {
2450
+ "expression": "workspace_id",
2451
+ "isExpression": false,
2452
+ "asc": true,
2453
+ "nulls": "last"
2454
+ }
2455
+ ],
2456
+ "isUnique": false,
2457
+ "concurrently": false,
2458
+ "method": "btree",
2459
+ "with": {}
2460
+ },
2461
+ "user_facts_category_idx": {
2462
+ "name": "user_facts_category_idx",
2463
+ "columns": [
2464
+ {
2465
+ "expression": "workspace_id",
2466
+ "isExpression": false,
2467
+ "asc": true,
2468
+ "nulls": "last"
2469
+ },
2470
+ {
2471
+ "expression": "category",
2472
+ "isExpression": false,
2473
+ "asc": true,
2474
+ "nulls": "last"
2475
+ }
2476
+ ],
2477
+ "isUnique": false,
2478
+ "concurrently": false,
2479
+ "method": "btree",
2480
+ "with": {}
2481
+ },
2482
+ "user_facts_user_workspace_category_key_uniq": {
2483
+ "name": "user_facts_user_workspace_category_key_uniq",
2484
+ "columns": [
2485
+ {
2486
+ "expression": "user_id",
2487
+ "isExpression": false,
2488
+ "asc": true,
2489
+ "nulls": "last"
2490
+ },
2491
+ {
2492
+ "expression": "workspace_id",
2493
+ "isExpression": false,
2494
+ "asc": true,
2495
+ "nulls": "last"
2496
+ },
2497
+ {
2498
+ "expression": "category",
2499
+ "isExpression": false,
2500
+ "asc": true,
2501
+ "nulls": "last"
2502
+ },
2503
+ {
2504
+ "expression": "key",
2505
+ "isExpression": false,
2506
+ "asc": true,
2507
+ "nulls": "last"
2508
+ }
2509
+ ],
2510
+ "isUnique": true,
2511
+ "concurrently": false,
2512
+ "method": "btree",
2513
+ "with": {}
2514
+ }
2515
+ },
2516
+ "foreignKeys": {
2517
+ "user_facts_user_id_users_id_fk": {
2518
+ "name": "user_facts_user_id_users_id_fk",
2519
+ "tableFrom": "user_facts",
2520
+ "tableTo": "users",
2521
+ "columnsFrom": ["user_id"],
2522
+ "columnsTo": ["id"],
2523
+ "onDelete": "cascade",
2524
+ "onUpdate": "no action"
2525
+ },
2526
+ "user_facts_workspace_id_organization_id_fk": {
2527
+ "name": "user_facts_workspace_id_organization_id_fk",
2528
+ "tableFrom": "user_facts",
2529
+ "tableTo": "organization",
2530
+ "columnsFrom": ["workspace_id"],
2531
+ "columnsTo": ["id"],
2532
+ "onDelete": "cascade",
2533
+ "onUpdate": "no action"
2534
+ }
2535
+ },
2536
+ "compositePrimaryKeys": {},
2537
+ "uniqueConstraints": {},
2538
+ "policies": {},
2539
+ "checkConstraints": {},
2540
+ "isRLSEnabled": false
2541
+ },
2542
+ "public.user_memories": {
2543
+ "name": "user_memories",
2544
+ "schema": "",
2545
+ "columns": {
2546
+ "id": {
2547
+ "name": "id",
2548
+ "type": "text",
2549
+ "primaryKey": true,
2550
+ "notNull": true
2551
+ },
2552
+ "user_id": {
2553
+ "name": "user_id",
2554
+ "type": "text",
2555
+ "primaryKey": false,
2556
+ "notNull": true
2557
+ },
2558
+ "workspace_id": {
2559
+ "name": "workspace_id",
2560
+ "type": "text",
2561
+ "primaryKey": false,
2562
+ "notNull": true
2563
+ },
2564
+ "kind": {
2565
+ "name": "kind",
2566
+ "type": "text",
2567
+ "primaryKey": false,
2568
+ "notNull": true
2569
+ },
2570
+ "content": {
2571
+ "name": "content",
2572
+ "type": "text",
2573
+ "primaryKey": false,
2574
+ "notNull": true
2575
+ },
2576
+ "embedding": {
2577
+ "name": "embedding",
2578
+ "type": "vector(1536)",
2579
+ "primaryKey": false,
2580
+ "notNull": false
2581
+ },
2582
+ "source_product": {
2583
+ "name": "source_product",
2584
+ "type": "text",
2585
+ "primaryKey": false,
2586
+ "notNull": false
2587
+ },
2588
+ "source_session_id": {
2589
+ "name": "source_session_id",
2590
+ "type": "text",
2591
+ "primaryKey": false,
2592
+ "notNull": false
2593
+ },
2594
+ "source_message_ids": {
2595
+ "name": "source_message_ids",
2596
+ "type": "text[]",
2597
+ "primaryKey": false,
2598
+ "notNull": false
2599
+ },
2600
+ "importance": {
2601
+ "name": "importance",
2602
+ "type": "integer",
2603
+ "primaryKey": false,
2604
+ "notNull": true,
2605
+ "default": 5
2606
+ },
2607
+ "decay_factor": {
2608
+ "name": "decay_factor",
2609
+ "type": "double precision",
2610
+ "primaryKey": false,
2611
+ "notNull": true,
2612
+ "default": 1
2613
+ },
2614
+ "metadata": {
2615
+ "name": "metadata",
2616
+ "type": "jsonb",
2617
+ "primaryKey": false,
2618
+ "notNull": false
2619
+ },
2620
+ "created_at": {
2621
+ "name": "created_at",
2622
+ "type": "timestamp",
2623
+ "primaryKey": false,
2624
+ "notNull": true,
2625
+ "default": "now()"
2626
+ }
2627
+ },
2628
+ "indexes": {
2629
+ "user_memories_user_idx": {
2630
+ "name": "user_memories_user_idx",
2631
+ "columns": [
2632
+ {
2633
+ "expression": "user_id",
2634
+ "isExpression": false,
2635
+ "asc": true,
2636
+ "nulls": "last"
2637
+ }
2638
+ ],
2639
+ "isUnique": false,
2640
+ "concurrently": false,
2641
+ "method": "btree",
2642
+ "with": {}
2643
+ },
2644
+ "user_memories_workspace_idx": {
2645
+ "name": "user_memories_workspace_idx",
2646
+ "columns": [
2647
+ {
2648
+ "expression": "workspace_id",
2649
+ "isExpression": false,
2650
+ "asc": true,
2651
+ "nulls": "last"
2652
+ }
2653
+ ],
2654
+ "isUnique": false,
2655
+ "concurrently": false,
2656
+ "method": "btree",
2657
+ "with": {}
2658
+ },
2659
+ "user_memories_kind_idx": {
2660
+ "name": "user_memories_kind_idx",
2661
+ "columns": [
2662
+ {
2663
+ "expression": "workspace_id",
2664
+ "isExpression": false,
2665
+ "asc": true,
2666
+ "nulls": "last"
2667
+ },
2668
+ {
2669
+ "expression": "kind",
2670
+ "isExpression": false,
2671
+ "asc": true,
2672
+ "nulls": "last"
2673
+ }
2674
+ ],
2675
+ "isUnique": false,
2676
+ "concurrently": false,
2677
+ "method": "btree",
2678
+ "with": {}
2679
+ }
2680
+ },
2681
+ "foreignKeys": {
2682
+ "user_memories_user_id_users_id_fk": {
2683
+ "name": "user_memories_user_id_users_id_fk",
2684
+ "tableFrom": "user_memories",
2685
+ "tableTo": "users",
2686
+ "columnsFrom": ["user_id"],
2687
+ "columnsTo": ["id"],
2688
+ "onDelete": "cascade",
2689
+ "onUpdate": "no action"
2690
+ },
2691
+ "user_memories_workspace_id_organization_id_fk": {
2692
+ "name": "user_memories_workspace_id_organization_id_fk",
2693
+ "tableFrom": "user_memories",
2694
+ "tableTo": "organization",
2695
+ "columnsFrom": ["workspace_id"],
2696
+ "columnsTo": ["id"],
2697
+ "onDelete": "cascade",
2698
+ "onUpdate": "no action"
2699
+ }
2700
+ },
2701
+ "compositePrimaryKeys": {},
2702
+ "uniqueConstraints": {},
2703
+ "policies": {},
2704
+ "checkConstraints": {},
2705
+ "isRLSEnabled": false
2706
+ },
2707
+ "public.user_memory_audit": {
2708
+ "name": "user_memory_audit",
2709
+ "schema": "",
2710
+ "columns": {
2711
+ "id": {
2712
+ "name": "id",
2713
+ "type": "text",
2714
+ "primaryKey": true,
2715
+ "notNull": true
2716
+ },
2717
+ "user_id": {
2718
+ "name": "user_id",
2719
+ "type": "text",
2720
+ "primaryKey": false,
2721
+ "notNull": true
2722
+ },
2723
+ "workspace_id": {
2724
+ "name": "workspace_id",
2725
+ "type": "text",
2726
+ "primaryKey": false,
2727
+ "notNull": true
2728
+ },
2729
+ "target_kind": {
2730
+ "name": "target_kind",
2731
+ "type": "text",
2732
+ "primaryKey": false,
2733
+ "notNull": true
2734
+ },
2735
+ "target_id": {
2736
+ "name": "target_id",
2737
+ "type": "text",
2738
+ "primaryKey": false,
2739
+ "notNull": true
2740
+ },
2741
+ "action": {
2742
+ "name": "action",
2743
+ "type": "text",
2744
+ "primaryKey": false,
2745
+ "notNull": true
2746
+ },
2747
+ "actor_kind": {
2748
+ "name": "actor_kind",
2749
+ "type": "text",
2750
+ "primaryKey": false,
2751
+ "notNull": true
2752
+ },
2753
+ "actor_id": {
2754
+ "name": "actor_id",
2755
+ "type": "text",
2756
+ "primaryKey": false,
2757
+ "notNull": false
2758
+ },
2759
+ "before_value": {
2760
+ "name": "before_value",
2761
+ "type": "jsonb",
2762
+ "primaryKey": false,
2763
+ "notNull": false
2764
+ },
2765
+ "after_value": {
2766
+ "name": "after_value",
2767
+ "type": "jsonb",
2768
+ "primaryKey": false,
2769
+ "notNull": false
2770
+ },
2771
+ "reason": {
2772
+ "name": "reason",
2773
+ "type": "text",
2774
+ "primaryKey": false,
2775
+ "notNull": false
2776
+ },
2777
+ "created_at": {
2778
+ "name": "created_at",
2779
+ "type": "timestamp",
2780
+ "primaryKey": false,
2781
+ "notNull": true,
2782
+ "default": "now()"
2783
+ }
2784
+ },
2785
+ "indexes": {
2786
+ "user_memory_audit_user_idx": {
2787
+ "name": "user_memory_audit_user_idx",
2788
+ "columns": [
2789
+ {
2790
+ "expression": "user_id",
2791
+ "isExpression": false,
2792
+ "asc": true,
2793
+ "nulls": "last"
2794
+ }
2795
+ ],
2796
+ "isUnique": false,
2797
+ "concurrently": false,
2798
+ "method": "btree",
2799
+ "with": {}
2800
+ },
2801
+ "user_memory_audit_workspace_idx": {
2802
+ "name": "user_memory_audit_workspace_idx",
2803
+ "columns": [
2804
+ {
2805
+ "expression": "workspace_id",
2806
+ "isExpression": false,
2807
+ "asc": true,
2808
+ "nulls": "last"
2809
+ }
2810
+ ],
2811
+ "isUnique": false,
2812
+ "concurrently": false,
2813
+ "method": "btree",
2814
+ "with": {}
2815
+ },
2816
+ "user_memory_audit_target_idx": {
2817
+ "name": "user_memory_audit_target_idx",
2818
+ "columns": [
2819
+ {
2820
+ "expression": "target_kind",
2821
+ "isExpression": false,
2822
+ "asc": true,
2823
+ "nulls": "last"
2824
+ },
2825
+ {
2826
+ "expression": "target_id",
2827
+ "isExpression": false,
2828
+ "asc": true,
2829
+ "nulls": "last"
2830
+ }
2831
+ ],
2832
+ "isUnique": false,
2833
+ "concurrently": false,
2834
+ "method": "btree",
2835
+ "with": {}
2836
+ }
2837
+ },
2838
+ "foreignKeys": {
2839
+ "user_memory_audit_user_id_users_id_fk": {
2840
+ "name": "user_memory_audit_user_id_users_id_fk",
2841
+ "tableFrom": "user_memory_audit",
2842
+ "tableTo": "users",
2843
+ "columnsFrom": ["user_id"],
2844
+ "columnsTo": ["id"],
2845
+ "onDelete": "cascade",
2846
+ "onUpdate": "no action"
2847
+ },
2848
+ "user_memory_audit_workspace_id_organization_id_fk": {
2849
+ "name": "user_memory_audit_workspace_id_organization_id_fk",
2850
+ "tableFrom": "user_memory_audit",
2851
+ "tableTo": "organization",
2852
+ "columnsFrom": ["workspace_id"],
2853
+ "columnsTo": ["id"],
2854
+ "onDelete": "cascade",
2855
+ "onUpdate": "no action"
2856
+ }
2857
+ },
2858
+ "compositePrimaryKeys": {},
2859
+ "uniqueConstraints": {},
2860
+ "policies": {},
2861
+ "checkConstraints": {},
2862
+ "isRLSEnabled": false
2863
+ },
2864
+ "public.user_profile_snapshots": {
2865
+ "name": "user_profile_snapshots",
2866
+ "schema": "",
2867
+ "columns": {
2868
+ "user_id": {
2869
+ "name": "user_id",
2870
+ "type": "text",
2871
+ "primaryKey": false,
2872
+ "notNull": true
2873
+ },
2874
+ "workspace_id": {
2875
+ "name": "workspace_id",
2876
+ "type": "text",
2877
+ "primaryKey": false,
2878
+ "notNull": true
2879
+ },
2880
+ "version": {
2881
+ "name": "version",
2882
+ "type": "integer",
2883
+ "primaryKey": false,
2884
+ "notNull": true
2885
+ },
2886
+ "summary": {
2887
+ "name": "summary",
2888
+ "type": "text",
2889
+ "primaryKey": false,
2890
+ "notNull": true
2891
+ },
2892
+ "summary_en": {
2893
+ "name": "summary_en",
2894
+ "type": "text",
2895
+ "primaryKey": false,
2896
+ "notNull": false
2897
+ },
2898
+ "summary_mn": {
2899
+ "name": "summary_mn",
2900
+ "type": "text",
2901
+ "primaryKey": false,
2902
+ "notNull": false
2903
+ },
2904
+ "facts_digest": {
2905
+ "name": "facts_digest",
2906
+ "type": "jsonb",
2907
+ "primaryKey": false,
2908
+ "notNull": true
2909
+ },
2910
+ "active_goals": {
2911
+ "name": "active_goals",
2912
+ "type": "jsonb",
2913
+ "primaryKey": false,
2914
+ "notNull": false
2915
+ },
2916
+ "personality_signals": {
2917
+ "name": "personality_signals",
2918
+ "type": "jsonb",
2919
+ "primaryKey": false,
2920
+ "notNull": false
2921
+ },
2922
+ "relationship_notes": {
2923
+ "name": "relationship_notes",
2924
+ "type": "jsonb",
2925
+ "primaryKey": false,
2926
+ "notNull": false
2927
+ },
2928
+ "synthesized_by_model": {
2929
+ "name": "synthesized_by_model",
2930
+ "type": "text",
2931
+ "primaryKey": false,
2932
+ "notNull": false
2933
+ },
2934
+ "synthesized_at": {
2935
+ "name": "synthesized_at",
2936
+ "type": "timestamp",
2937
+ "primaryKey": false,
2938
+ "notNull": true,
2939
+ "default": "now()"
2940
+ },
2941
+ "next_synthesis_at": {
2942
+ "name": "next_synthesis_at",
2943
+ "type": "timestamp",
2944
+ "primaryKey": false,
2945
+ "notNull": false
2946
+ },
2947
+ "trigger_reason": {
2948
+ "name": "trigger_reason",
2949
+ "type": "text",
2950
+ "primaryKey": false,
2951
+ "notNull": false
2952
+ }
2953
+ },
2954
+ "indexes": {
2955
+ "user_profile_snapshots_workspace_idx": {
2956
+ "name": "user_profile_snapshots_workspace_idx",
2957
+ "columns": [
2958
+ {
2959
+ "expression": "workspace_id",
2960
+ "isExpression": false,
2961
+ "asc": true,
2962
+ "nulls": "last"
2963
+ }
2964
+ ],
2965
+ "isUnique": false,
2966
+ "concurrently": false,
2967
+ "method": "btree",
2968
+ "with": {}
2969
+ }
2970
+ },
2971
+ "foreignKeys": {
2972
+ "user_profile_snapshots_user_id_users_id_fk": {
2973
+ "name": "user_profile_snapshots_user_id_users_id_fk",
2974
+ "tableFrom": "user_profile_snapshots",
2975
+ "tableTo": "users",
2976
+ "columnsFrom": ["user_id"],
2977
+ "columnsTo": ["id"],
2978
+ "onDelete": "cascade",
2979
+ "onUpdate": "no action"
2980
+ },
2981
+ "user_profile_snapshots_workspace_id_organization_id_fk": {
2982
+ "name": "user_profile_snapshots_workspace_id_organization_id_fk",
2983
+ "tableFrom": "user_profile_snapshots",
2984
+ "tableTo": "organization",
2985
+ "columnsFrom": ["workspace_id"],
2986
+ "columnsTo": ["id"],
2987
+ "onDelete": "cascade",
2988
+ "onUpdate": "no action"
2989
+ }
2990
+ },
2991
+ "compositePrimaryKeys": {
2992
+ "user_profile_snapshots_user_id_workspace_id_pk": {
2993
+ "name": "user_profile_snapshots_user_id_workspace_id_pk",
2994
+ "columns": ["user_id", "workspace_id"]
2995
+ }
2996
+ },
2997
+ "uniqueConstraints": {},
2998
+ "policies": {},
2999
+ "checkConstraints": {},
3000
+ "isRLSEnabled": false
3001
+ },
3002
+ "public.monthly_usage": {
3003
+ "name": "monthly_usage",
3004
+ "schema": "",
3005
+ "columns": {
3006
+ "id": {
3007
+ "name": "id",
3008
+ "type": "text",
3009
+ "primaryKey": true,
3010
+ "notNull": true
3011
+ },
3012
+ "workspace_id": {
3013
+ "name": "workspace_id",
3014
+ "type": "text",
3015
+ "primaryKey": false,
3016
+ "notNull": true
3017
+ },
3018
+ "period_start": {
3019
+ "name": "period_start",
3020
+ "type": "timestamp",
3021
+ "primaryKey": false,
3022
+ "notNull": true
3023
+ },
3024
+ "period_end": {
3025
+ "name": "period_end",
3026
+ "type": "timestamp",
3027
+ "primaryKey": false,
3028
+ "notNull": true
3029
+ },
3030
+ "tokens_used": {
3031
+ "name": "tokens_used",
3032
+ "type": "integer",
3033
+ "primaryKey": false,
3034
+ "notNull": true,
3035
+ "default": 0
3036
+ },
3037
+ "allowance_used_micros": {
3038
+ "name": "allowance_used_micros",
3039
+ "type": "bigint",
3040
+ "primaryKey": false,
3041
+ "notNull": true,
3042
+ "default": 0
3043
+ },
3044
+ "currency": {
3045
+ "name": "currency",
3046
+ "type": "text",
3047
+ "primaryKey": false,
3048
+ "notNull": true,
3049
+ "default": "'USD'"
3050
+ },
3051
+ "request_count": {
3052
+ "name": "request_count",
3053
+ "type": "integer",
3054
+ "primaryKey": false,
3055
+ "notNull": true,
3056
+ "default": 0
3057
+ },
3058
+ "updated_at": {
3059
+ "name": "updated_at",
3060
+ "type": "timestamp",
3061
+ "primaryKey": false,
3062
+ "notNull": true,
3063
+ "default": "now()"
3064
+ }
3065
+ },
3066
+ "indexes": {
3067
+ "monthly_usage_workspace_id_idx": {
3068
+ "name": "monthly_usage_workspace_id_idx",
3069
+ "columns": [
3070
+ {
3071
+ "expression": "workspace_id",
3072
+ "isExpression": false,
3073
+ "asc": true,
3074
+ "nulls": "last"
3075
+ }
3076
+ ],
3077
+ "isUnique": false,
3078
+ "concurrently": false,
3079
+ "method": "btree",
3080
+ "with": {}
3081
+ }
3082
+ },
3083
+ "foreignKeys": {
3084
+ "monthly_usage_workspace_id_organization_id_fk": {
3085
+ "name": "monthly_usage_workspace_id_organization_id_fk",
3086
+ "tableFrom": "monthly_usage",
3087
+ "tableTo": "organization",
3088
+ "columnsFrom": ["workspace_id"],
3089
+ "columnsTo": ["id"],
3090
+ "onDelete": "cascade",
3091
+ "onUpdate": "no action"
3092
+ }
3093
+ },
3094
+ "compositePrimaryKeys": {},
3095
+ "uniqueConstraints": {
3096
+ "monthly_usage_workspace_period_unique": {
3097
+ "name": "monthly_usage_workspace_period_unique",
3098
+ "nullsNotDistinct": false,
3099
+ "columns": ["workspace_id", "period_start"]
3100
+ }
3101
+ },
3102
+ "policies": {},
3103
+ "checkConstraints": {},
3104
+ "isRLSEnabled": false
3105
+ },
3106
+ "public.notification_history": {
3107
+ "name": "notification_history",
3108
+ "schema": "",
3109
+ "columns": {
3110
+ "id": {
3111
+ "name": "id",
3112
+ "type": "text",
3113
+ "primaryKey": true,
3114
+ "notNull": true
3115
+ },
3116
+ "workspace_id": {
3117
+ "name": "workspace_id",
3118
+ "type": "text",
3119
+ "primaryKey": false,
3120
+ "notNull": true
3121
+ },
3122
+ "type": {
3123
+ "name": "type",
3124
+ "type": "text",
3125
+ "primaryKey": false,
3126
+ "notNull": true
3127
+ },
3128
+ "period_key": {
3129
+ "name": "period_key",
3130
+ "type": "text",
3131
+ "primaryKey": false,
3132
+ "notNull": true
3133
+ },
3134
+ "sent_at": {
3135
+ "name": "sent_at",
3136
+ "type": "timestamp",
3137
+ "primaryKey": false,
3138
+ "notNull": true,
3139
+ "default": "now()"
3140
+ },
3141
+ "channel": {
3142
+ "name": "channel",
3143
+ "type": "text",
3144
+ "primaryKey": false,
3145
+ "notNull": true,
3146
+ "default": "'console'"
3147
+ },
3148
+ "metadata": {
3149
+ "name": "metadata",
3150
+ "type": "text",
3151
+ "primaryKey": false,
3152
+ "notNull": false
3153
+ }
3154
+ },
3155
+ "indexes": {
3156
+ "notification_history_workspace_id_idx": {
3157
+ "name": "notification_history_workspace_id_idx",
3158
+ "columns": [
3159
+ {
3160
+ "expression": "workspace_id",
3161
+ "isExpression": false,
3162
+ "asc": true,
3163
+ "nulls": "last"
3164
+ }
3165
+ ],
3166
+ "isUnique": false,
3167
+ "concurrently": false,
3168
+ "method": "btree",
3169
+ "with": {}
3170
+ }
3171
+ },
3172
+ "foreignKeys": {
3173
+ "notification_history_workspace_id_organization_id_fk": {
3174
+ "name": "notification_history_workspace_id_organization_id_fk",
3175
+ "tableFrom": "notification_history",
3176
+ "tableTo": "organization",
3177
+ "columnsFrom": ["workspace_id"],
3178
+ "columnsTo": ["id"],
3179
+ "onDelete": "cascade",
3180
+ "onUpdate": "no action"
3181
+ }
3182
+ },
3183
+ "compositePrimaryKeys": {},
3184
+ "uniqueConstraints": {
3185
+ "notification_history_dedup_unique": {
3186
+ "name": "notification_history_dedup_unique",
3187
+ "nullsNotDistinct": false,
3188
+ "columns": ["workspace_id", "type", "period_key"]
3189
+ }
3190
+ },
3191
+ "policies": {},
3192
+ "checkConstraints": {},
3193
+ "isRLSEnabled": false
3194
+ },
3195
+ "public.rate_limit_entries": {
3196
+ "name": "rate_limit_entries",
3197
+ "schema": "",
3198
+ "columns": {
3199
+ "id": {
3200
+ "name": "id",
3201
+ "type": "text",
3202
+ "primaryKey": true,
3203
+ "notNull": true
3204
+ },
3205
+ "workspace_id": {
3206
+ "name": "workspace_id",
3207
+ "type": "text",
3208
+ "primaryKey": false,
3209
+ "notNull": true
3210
+ },
3211
+ "endpoint": {
3212
+ "name": "endpoint",
3213
+ "type": "text",
3214
+ "primaryKey": false,
3215
+ "notNull": true,
3216
+ "default": "'chat'"
3217
+ },
3218
+ "requested_at": {
3219
+ "name": "requested_at",
3220
+ "type": "timestamp",
3221
+ "primaryKey": false,
3222
+ "notNull": true,
3223
+ "default": "now()"
3224
+ },
3225
+ "minute_bucket": {
3226
+ "name": "minute_bucket",
3227
+ "type": "timestamp",
3228
+ "primaryKey": false,
3229
+ "notNull": true
3230
+ },
3231
+ "window_seconds": {
3232
+ "name": "window_seconds",
3233
+ "type": "integer",
3234
+ "primaryKey": false,
3235
+ "notNull": true,
3236
+ "default": 60
3237
+ },
3238
+ "count": {
3239
+ "name": "count",
3240
+ "type": "integer",
3241
+ "primaryKey": false,
3242
+ "notNull": true,
3243
+ "default": 1
3244
+ }
3245
+ },
3246
+ "indexes": {
3247
+ "rate_limit_entries_window_idx": {
3248
+ "name": "rate_limit_entries_window_idx",
3249
+ "columns": [
3250
+ {
3251
+ "expression": "workspace_id",
3252
+ "isExpression": false,
3253
+ "asc": true,
3254
+ "nulls": "last"
3255
+ },
3256
+ {
3257
+ "expression": "endpoint",
3258
+ "isExpression": false,
3259
+ "asc": true,
3260
+ "nulls": "last"
3261
+ },
3262
+ {
3263
+ "expression": "requested_at",
3264
+ "isExpression": false,
3265
+ "asc": true,
3266
+ "nulls": "last"
3267
+ }
3268
+ ],
3269
+ "isUnique": false,
3270
+ "concurrently": false,
3271
+ "method": "btree",
3272
+ "with": {}
3273
+ }
3274
+ },
3275
+ "foreignKeys": {},
3276
+ "compositePrimaryKeys": {},
3277
+ "uniqueConstraints": {
3278
+ "rate_limit_entries_unique_bucket_idx": {
3279
+ "name": "rate_limit_entries_unique_bucket_idx",
3280
+ "nullsNotDistinct": false,
3281
+ "columns": ["workspace_id", "endpoint", "minute_bucket"]
3282
+ }
3283
+ },
3284
+ "policies": {},
3285
+ "checkConstraints": {},
3286
+ "isRLSEnabled": false
3287
+ },
3288
+ "public.trial_credits": {
3289
+ "name": "trial_credits",
3290
+ "schema": "",
3291
+ "columns": {
3292
+ "id": {
3293
+ "name": "id",
3294
+ "type": "text",
3295
+ "primaryKey": true,
3296
+ "notNull": true
3297
+ },
3298
+ "workspace_id": {
3299
+ "name": "workspace_id",
3300
+ "type": "text",
3301
+ "primaryKey": false,
3302
+ "notNull": true
3303
+ },
3304
+ "initial_credits": {
3305
+ "name": "initial_credits",
3306
+ "type": "integer",
3307
+ "primaryKey": false,
3308
+ "notNull": true,
3309
+ "default": 100000
3310
+ },
3311
+ "credits_used": {
3312
+ "name": "credits_used",
3313
+ "type": "integer",
3314
+ "primaryKey": false,
3315
+ "notNull": true,
3316
+ "default": 0
3317
+ },
3318
+ "credits_remaining": {
3319
+ "name": "credits_remaining",
3320
+ "type": "integer",
3321
+ "primaryKey": false,
3322
+ "notNull": true,
3323
+ "default": 100000
3324
+ },
3325
+ "initial_micros": {
3326
+ "name": "initial_micros",
3327
+ "type": "bigint",
3328
+ "primaryKey": false,
3329
+ "notNull": true,
3330
+ "default": 0
3331
+ },
3332
+ "used_micros": {
3333
+ "name": "used_micros",
3334
+ "type": "bigint",
3335
+ "primaryKey": false,
3336
+ "notNull": true,
3337
+ "default": 0
3338
+ },
3339
+ "remaining_micros": {
3340
+ "name": "remaining_micros",
3341
+ "type": "bigint",
3342
+ "primaryKey": false,
3343
+ "notNull": true,
3344
+ "default": 0
3345
+ },
3346
+ "currency": {
3347
+ "name": "currency",
3348
+ "type": "text",
3349
+ "primaryKey": false,
3350
+ "notNull": true,
3351
+ "default": "'USD'"
3352
+ },
3353
+ "status": {
3354
+ "name": "status",
3355
+ "type": "text",
3356
+ "primaryKey": false,
3357
+ "notNull": true,
3358
+ "default": "'active'"
3359
+ },
3360
+ "provisioned_at": {
3361
+ "name": "provisioned_at",
3362
+ "type": "timestamp",
3363
+ "primaryKey": false,
3364
+ "notNull": true,
3365
+ "default": "now()"
3366
+ },
3367
+ "trial_end_date": {
3368
+ "name": "trial_end_date",
3369
+ "type": "timestamp",
3370
+ "primaryKey": false,
3371
+ "notNull": false
3372
+ },
3373
+ "depleted_at": {
3374
+ "name": "depleted_at",
3375
+ "type": "timestamp",
3376
+ "primaryKey": false,
3377
+ "notNull": false
3378
+ },
3379
+ "converted_at": {
3380
+ "name": "converted_at",
3381
+ "type": "timestamp",
3382
+ "primaryKey": false,
3383
+ "notNull": false
3384
+ },
3385
+ "created_by_ip": {
3386
+ "name": "created_by_ip",
3387
+ "type": "text",
3388
+ "primaryKey": false,
3389
+ "notNull": false
3390
+ },
3391
+ "created_by_email": {
3392
+ "name": "created_by_email",
3393
+ "type": "text",
3394
+ "primaryKey": false,
3395
+ "notNull": false
3396
+ },
3397
+ "normalized_email": {
3398
+ "name": "normalized_email",
3399
+ "type": "text",
3400
+ "primaryKey": false,
3401
+ "notNull": false
3402
+ }
3403
+ },
3404
+ "indexes": {
3405
+ "trial_credits_expiry_idx": {
3406
+ "name": "trial_credits_expiry_idx",
3407
+ "columns": [
3408
+ {
3409
+ "expression": "status",
3410
+ "isExpression": false,
3411
+ "asc": true,
3412
+ "nulls": "last"
3413
+ },
3414
+ {
3415
+ "expression": "trial_end_date",
3416
+ "isExpression": false,
3417
+ "asc": true,
3418
+ "nulls": "last"
3419
+ }
3420
+ ],
3421
+ "isUnique": false,
3422
+ "concurrently": false,
3423
+ "method": "btree",
3424
+ "with": {}
3425
+ },
3426
+ "trial_credits_normalized_email_idx": {
3427
+ "name": "trial_credits_normalized_email_idx",
3428
+ "columns": [
3429
+ {
3430
+ "expression": "normalized_email",
3431
+ "isExpression": false,
3432
+ "asc": true,
3433
+ "nulls": "last"
3434
+ }
3435
+ ],
3436
+ "isUnique": false,
3437
+ "concurrently": false,
3438
+ "method": "btree",
3439
+ "with": {}
3440
+ }
3441
+ },
3442
+ "foreignKeys": {
3443
+ "trial_credits_workspace_id_organization_id_fk": {
3444
+ "name": "trial_credits_workspace_id_organization_id_fk",
3445
+ "tableFrom": "trial_credits",
3446
+ "tableTo": "organization",
3447
+ "columnsFrom": ["workspace_id"],
3448
+ "columnsTo": ["id"],
3449
+ "onDelete": "cascade",
3450
+ "onUpdate": "no action"
3451
+ }
3452
+ },
3453
+ "compositePrimaryKeys": {},
3454
+ "uniqueConstraints": {
3455
+ "trial_credits_workspace_id_unique": {
3456
+ "name": "trial_credits_workspace_id_unique",
3457
+ "nullsNotDistinct": false,
3458
+ "columns": ["workspace_id"]
3459
+ }
3460
+ },
3461
+ "policies": {},
3462
+ "checkConstraints": {},
3463
+ "isRLSEnabled": false
3464
+ },
3465
+ "public.usage_records": {
3466
+ "name": "usage_records",
3467
+ "schema": "",
3468
+ "columns": {
3469
+ "id": {
3470
+ "name": "id",
3471
+ "type": "text",
3472
+ "primaryKey": true,
3473
+ "notNull": true
3474
+ },
3475
+ "workspace_id": {
3476
+ "name": "workspace_id",
3477
+ "type": "text",
3478
+ "primaryKey": false,
3479
+ "notNull": true
3480
+ },
3481
+ "user_id": {
3482
+ "name": "user_id",
3483
+ "type": "text",
3484
+ "primaryKey": false,
3485
+ "notNull": false
3486
+ },
3487
+ "type": {
3488
+ "name": "type",
3489
+ "type": "text",
3490
+ "primaryKey": false,
3491
+ "notNull": true
3492
+ },
3493
+ "model": {
3494
+ "name": "model",
3495
+ "type": "text",
3496
+ "primaryKey": false,
3497
+ "notNull": false
3498
+ },
3499
+ "agent": {
3500
+ "name": "agent",
3501
+ "type": "text",
3502
+ "primaryKey": false,
3503
+ "notNull": false
3504
+ },
3505
+ "input_tokens": {
3506
+ "name": "input_tokens",
3507
+ "type": "integer",
3508
+ "primaryKey": false,
3509
+ "notNull": true,
3510
+ "default": 0
3511
+ },
3512
+ "output_tokens": {
3513
+ "name": "output_tokens",
3514
+ "type": "integer",
3515
+ "primaryKey": false,
3516
+ "notNull": true,
3517
+ "default": 0
3518
+ },
3519
+ "total_tokens": {
3520
+ "name": "total_tokens",
3521
+ "type": "integer",
3522
+ "primaryKey": false,
3523
+ "notNull": true,
3524
+ "default": 0
3525
+ },
3526
+ "provider_cost_micros": {
3527
+ "name": "provider_cost_micros",
3528
+ "type": "bigint",
3529
+ "primaryKey": false,
3530
+ "notNull": true,
3531
+ "default": 0
3532
+ },
3533
+ "margin_bp": {
3534
+ "name": "margin_bp",
3535
+ "type": "integer",
3536
+ "primaryKey": false,
3537
+ "notNull": true,
3538
+ "default": 0
3539
+ },
3540
+ "usd_rate_micros": {
3541
+ "name": "usd_rate_micros",
3542
+ "type": "bigint",
3543
+ "primaryKey": false,
3544
+ "notNull": true,
3545
+ "default": 0
3546
+ },
3547
+ "charged_micros": {
3548
+ "name": "charged_micros",
3549
+ "type": "bigint",
3550
+ "primaryKey": false,
3551
+ "notNull": true,
3552
+ "default": 0
3553
+ },
3554
+ "currency": {
3555
+ "name": "currency",
3556
+ "type": "text",
3557
+ "primaryKey": false,
3558
+ "notNull": true,
3559
+ "default": "'USD'"
3560
+ },
3561
+ "request_id": {
3562
+ "name": "request_id",
3563
+ "type": "text",
3564
+ "primaryKey": false,
3565
+ "notNull": false
3566
+ },
3567
+ "execution_id": {
3568
+ "name": "execution_id",
3569
+ "type": "text",
3570
+ "primaryKey": false,
3571
+ "notNull": false
3572
+ },
3573
+ "conversation_id": {
3574
+ "name": "conversation_id",
3575
+ "type": "text",
3576
+ "primaryKey": false,
3577
+ "notNull": false
3578
+ },
3579
+ "metadata": {
3580
+ "name": "metadata",
3581
+ "type": "text",
3582
+ "primaryKey": false,
3583
+ "notNull": false
3584
+ },
3585
+ "recorded_at": {
3586
+ "name": "recorded_at",
3587
+ "type": "timestamp",
3588
+ "primaryKey": false,
3589
+ "notNull": true,
3590
+ "default": "now()"
3591
+ }
3592
+ },
3593
+ "indexes": {
3594
+ "usage_records_workspace_id_idx": {
3595
+ "name": "usage_records_workspace_id_idx",
3596
+ "columns": [
3597
+ {
3598
+ "expression": "workspace_id",
3599
+ "isExpression": false,
3600
+ "asc": true,
3601
+ "nulls": "last"
3602
+ }
3603
+ ],
3604
+ "isUnique": false,
3605
+ "concurrently": false,
3606
+ "method": "btree",
3607
+ "with": {}
3608
+ },
3609
+ "usage_records_workspace_recorded_at_idx": {
3610
+ "name": "usage_records_workspace_recorded_at_idx",
3611
+ "columns": [
3612
+ {
3613
+ "expression": "workspace_id",
3614
+ "isExpression": false,
3615
+ "asc": true,
3616
+ "nulls": "last"
3617
+ },
3618
+ {
3619
+ "expression": "recorded_at",
3620
+ "isExpression": false,
3621
+ "asc": true,
3622
+ "nulls": "last"
3623
+ }
3624
+ ],
3625
+ "isUnique": false,
3626
+ "concurrently": false,
3627
+ "method": "btree",
3628
+ "with": {}
3629
+ },
3630
+ "usage_records_workspace_type_idx": {
3631
+ "name": "usage_records_workspace_type_idx",
3632
+ "columns": [
3633
+ {
3634
+ "expression": "workspace_id",
3635
+ "isExpression": false,
3636
+ "asc": true,
3637
+ "nulls": "last"
3638
+ },
3639
+ {
3640
+ "expression": "type",
3641
+ "isExpression": false,
3642
+ "asc": true,
3643
+ "nulls": "last"
3644
+ }
3645
+ ],
3646
+ "isUnique": false,
3647
+ "concurrently": false,
3648
+ "method": "btree",
3649
+ "with": {}
3650
+ },
3651
+ "usage_records_conversation_id_idx": {
3652
+ "name": "usage_records_conversation_id_idx",
3653
+ "columns": [
3654
+ {
3655
+ "expression": "conversation_id",
3656
+ "isExpression": false,
3657
+ "asc": true,
3658
+ "nulls": "last"
3659
+ }
3660
+ ],
3661
+ "isUnique": false,
3662
+ "concurrently": false,
3663
+ "method": "btree",
3664
+ "with": {}
3665
+ },
3666
+ "usage_records_execution_id_idx": {
3667
+ "name": "usage_records_execution_id_idx",
3668
+ "columns": [
3669
+ {
3670
+ "expression": "execution_id",
3671
+ "isExpression": false,
3672
+ "asc": true,
3673
+ "nulls": "last"
3674
+ }
3675
+ ],
3676
+ "isUnique": false,
3677
+ "concurrently": false,
3678
+ "method": "btree",
3679
+ "with": {}
3680
+ }
3681
+ },
3682
+ "foreignKeys": {
3683
+ "usage_records_workspace_id_organization_id_fk": {
3684
+ "name": "usage_records_workspace_id_organization_id_fk",
3685
+ "tableFrom": "usage_records",
3686
+ "tableTo": "organization",
3687
+ "columnsFrom": ["workspace_id"],
3688
+ "columnsTo": ["id"],
3689
+ "onDelete": "cascade",
3690
+ "onUpdate": "no action"
3691
+ },
3692
+ "usage_records_user_id_users_id_fk": {
3693
+ "name": "usage_records_user_id_users_id_fk",
3694
+ "tableFrom": "usage_records",
3695
+ "tableTo": "users",
3696
+ "columnsFrom": ["user_id"],
3697
+ "columnsTo": ["id"],
3698
+ "onDelete": "cascade",
3699
+ "onUpdate": "no action"
3700
+ }
3701
+ },
3702
+ "compositePrimaryKeys": {},
3703
+ "uniqueConstraints": {},
3704
+ "policies": {},
3705
+ "checkConstraints": {},
3706
+ "isRLSEnabled": false
3707
+ },
3708
+ "public.user_quotas": {
3709
+ "name": "user_quotas",
3710
+ "schema": "",
3711
+ "columns": {
3712
+ "id": {
3713
+ "name": "id",
3714
+ "type": "text",
3715
+ "primaryKey": true,
3716
+ "notNull": true
3717
+ },
3718
+ "user_id": {
3719
+ "name": "user_id",
3720
+ "type": "text",
3721
+ "primaryKey": false,
3722
+ "notNull": true
3723
+ },
3724
+ "workspace_id": {
3725
+ "name": "workspace_id",
3726
+ "type": "text",
3727
+ "primaryKey": false,
3728
+ "notNull": true
3729
+ },
3730
+ "plan": {
3731
+ "name": "plan",
3732
+ "type": "text",
3733
+ "primaryKey": false,
3734
+ "notNull": true,
3735
+ "default": "'free'"
3736
+ },
3737
+ "usage": {
3738
+ "name": "usage",
3739
+ "type": "jsonb",
3740
+ "primaryKey": false,
3741
+ "notNull": true,
3742
+ "default": "'{}'::jsonb"
3743
+ },
3744
+ "total_cost_usd": {
3745
+ "name": "total_cost_usd",
3746
+ "type": "real",
3747
+ "primaryKey": false,
3748
+ "notNull": true,
3749
+ "default": 0
3750
+ },
3751
+ "created_at": {
3752
+ "name": "created_at",
3753
+ "type": "timestamp",
3754
+ "primaryKey": false,
3755
+ "notNull": true,
3756
+ "default": "now()"
3757
+ },
3758
+ "updated_at": {
3759
+ "name": "updated_at",
3760
+ "type": "timestamp",
3761
+ "primaryKey": false,
3762
+ "notNull": true,
3763
+ "default": "now()"
3764
+ }
3765
+ },
3766
+ "indexes": {
3767
+ "user_quotas_user_id_idx": {
3768
+ "name": "user_quotas_user_id_idx",
3769
+ "columns": [
3770
+ {
3771
+ "expression": "user_id",
3772
+ "isExpression": false,
3773
+ "asc": true,
3774
+ "nulls": "last"
3775
+ }
3776
+ ],
3777
+ "isUnique": false,
3778
+ "concurrently": false,
3779
+ "method": "btree",
3780
+ "with": {}
3781
+ },
3782
+ "user_quotas_workspace_id_idx": {
3783
+ "name": "user_quotas_workspace_id_idx",
3784
+ "columns": [
3785
+ {
3786
+ "expression": "workspace_id",
3787
+ "isExpression": false,
3788
+ "asc": true,
3789
+ "nulls": "last"
3790
+ }
3791
+ ],
3792
+ "isUnique": false,
3793
+ "concurrently": false,
3794
+ "method": "btree",
3795
+ "with": {}
3796
+ }
3797
+ },
3798
+ "foreignKeys": {
3799
+ "user_quotas_user_id_users_id_fk": {
3800
+ "name": "user_quotas_user_id_users_id_fk",
3801
+ "tableFrom": "user_quotas",
3802
+ "tableTo": "users",
3803
+ "columnsFrom": ["user_id"],
3804
+ "columnsTo": ["id"],
3805
+ "onDelete": "cascade",
3806
+ "onUpdate": "no action"
3807
+ },
3808
+ "user_quotas_workspace_id_organization_id_fk": {
3809
+ "name": "user_quotas_workspace_id_organization_id_fk",
3810
+ "tableFrom": "user_quotas",
3811
+ "tableTo": "organization",
3812
+ "columnsFrom": ["workspace_id"],
3813
+ "columnsTo": ["id"],
3814
+ "onDelete": "cascade",
3815
+ "onUpdate": "no action"
3816
+ }
3817
+ },
3818
+ "compositePrimaryKeys": {},
3819
+ "uniqueConstraints": {
3820
+ "user_quotas_user_workspace_unique": {
3821
+ "name": "user_quotas_user_workspace_unique",
3822
+ "nullsNotDistinct": false,
3823
+ "columns": ["user_id", "workspace_id"]
3824
+ }
3825
+ },
3826
+ "policies": {},
3827
+ "checkConstraints": {},
3828
+ "isRLSEnabled": false
3829
+ },
3830
+ "public.notifications": {
3831
+ "name": "notifications",
3832
+ "schema": "",
3833
+ "columns": {
3834
+ "id": {
3835
+ "name": "id",
3836
+ "type": "text",
3837
+ "primaryKey": true,
3838
+ "notNull": true
3839
+ },
3840
+ "user_id": {
3841
+ "name": "user_id",
3842
+ "type": "text",
3843
+ "primaryKey": false,
3844
+ "notNull": true
3845
+ },
3846
+ "workspace_id": {
3847
+ "name": "workspace_id",
3848
+ "type": "text",
3849
+ "primaryKey": false,
3850
+ "notNull": false
3851
+ },
3852
+ "type": {
3853
+ "name": "type",
3854
+ "type": "text",
3855
+ "primaryKey": false,
3856
+ "notNull": true
3857
+ },
3858
+ "title": {
3859
+ "name": "title",
3860
+ "type": "text",
3861
+ "primaryKey": false,
3862
+ "notNull": true
3863
+ },
3864
+ "message": {
3865
+ "name": "message",
3866
+ "type": "text",
3867
+ "primaryKey": false,
3868
+ "notNull": true
3869
+ },
3870
+ "is_read": {
3871
+ "name": "is_read",
3872
+ "type": "boolean",
3873
+ "primaryKey": false,
3874
+ "notNull": true,
3875
+ "default": false
3876
+ },
3877
+ "metadata": {
3878
+ "name": "metadata",
3879
+ "type": "text",
3880
+ "primaryKey": false,
3881
+ "notNull": false
3882
+ },
3883
+ "created_at": {
3884
+ "name": "created_at",
3885
+ "type": "timestamp",
3886
+ "primaryKey": false,
3887
+ "notNull": true,
3888
+ "default": "now()"
3889
+ }
3890
+ },
3891
+ "indexes": {
3892
+ "notifications_user_id_idx": {
3893
+ "name": "notifications_user_id_idx",
3894
+ "columns": [
3895
+ {
3896
+ "expression": "user_id",
3897
+ "isExpression": false,
3898
+ "asc": true,
3899
+ "nulls": "last"
3900
+ }
3901
+ ],
3902
+ "isUnique": false,
3903
+ "concurrently": false,
3904
+ "method": "btree",
3905
+ "with": {}
3906
+ },
3907
+ "notifications_user_id_is_read_idx": {
3908
+ "name": "notifications_user_id_is_read_idx",
3909
+ "columns": [
3910
+ {
3911
+ "expression": "user_id",
3912
+ "isExpression": false,
3913
+ "asc": true,
3914
+ "nulls": "last"
3915
+ },
3916
+ {
3917
+ "expression": "is_read",
3918
+ "isExpression": false,
3919
+ "asc": true,
3920
+ "nulls": "last"
3921
+ }
3922
+ ],
3923
+ "isUnique": false,
3924
+ "concurrently": false,
3925
+ "method": "btree",
3926
+ "with": {}
3927
+ },
3928
+ "notifications_created_at_idx": {
3929
+ "name": "notifications_created_at_idx",
3930
+ "columns": [
3931
+ {
3932
+ "expression": "created_at",
3933
+ "isExpression": false,
3934
+ "asc": true,
3935
+ "nulls": "last"
3936
+ }
3937
+ ],
3938
+ "isUnique": false,
3939
+ "concurrently": false,
3940
+ "method": "btree",
3941
+ "with": {}
3942
+ }
3943
+ },
3944
+ "foreignKeys": {},
3945
+ "compositePrimaryKeys": {},
3946
+ "uniqueConstraints": {},
3947
+ "policies": {},
3948
+ "checkConstraints": {},
3949
+ "isRLSEnabled": false
3950
+ },
3951
+ "public.audit_events": {
3952
+ "name": "audit_events",
3953
+ "schema": "",
3954
+ "columns": {
3955
+ "id": {
3956
+ "name": "id",
3957
+ "type": "text",
3958
+ "primaryKey": true,
3959
+ "notNull": true
3960
+ },
3961
+ "workspace_id": {
3962
+ "name": "workspace_id",
3963
+ "type": "text",
3964
+ "primaryKey": false,
3965
+ "notNull": false
3966
+ },
3967
+ "actor_id": {
3968
+ "name": "actor_id",
3969
+ "type": "text",
3970
+ "primaryKey": false,
3971
+ "notNull": false
3972
+ },
3973
+ "actor_kind": {
3974
+ "name": "actor_kind",
3975
+ "type": "text",
3976
+ "primaryKey": false,
3977
+ "notNull": true,
3978
+ "default": "'user'"
3979
+ },
3980
+ "action": {
3981
+ "name": "action",
3982
+ "type": "text",
3983
+ "primaryKey": false,
3984
+ "notNull": true
3985
+ },
3986
+ "resource_kind": {
3987
+ "name": "resource_kind",
3988
+ "type": "text",
3989
+ "primaryKey": false,
3990
+ "notNull": true
3991
+ },
3992
+ "resource_id": {
3993
+ "name": "resource_id",
3994
+ "type": "text",
3995
+ "primaryKey": false,
3996
+ "notNull": false
3997
+ },
3998
+ "outcome": {
3999
+ "name": "outcome",
4000
+ "type": "text",
4001
+ "primaryKey": false,
4002
+ "notNull": true,
4003
+ "default": "'ok'"
4004
+ },
4005
+ "metadata": {
4006
+ "name": "metadata",
4007
+ "type": "jsonb",
4008
+ "primaryKey": false,
4009
+ "notNull": false
4010
+ },
4011
+ "created_at": {
4012
+ "name": "created_at",
4013
+ "type": "timestamp",
4014
+ "primaryKey": false,
4015
+ "notNull": true,
4016
+ "default": "now()"
4017
+ }
4018
+ },
4019
+ "indexes": {
4020
+ "audit_events_workspace_created_idx": {
4021
+ "name": "audit_events_workspace_created_idx",
4022
+ "columns": [
4023
+ {
4024
+ "expression": "workspace_id",
4025
+ "isExpression": false,
4026
+ "asc": true,
4027
+ "nulls": "last"
4028
+ },
4029
+ {
4030
+ "expression": "created_at",
4031
+ "isExpression": false,
4032
+ "asc": true,
4033
+ "nulls": "last"
4034
+ }
4035
+ ],
4036
+ "isUnique": false,
4037
+ "concurrently": false,
4038
+ "method": "btree",
4039
+ "with": {}
4040
+ },
4041
+ "audit_events_action_idx": {
4042
+ "name": "audit_events_action_idx",
4043
+ "columns": [
4044
+ {
4045
+ "expression": "action",
4046
+ "isExpression": false,
4047
+ "asc": true,
4048
+ "nulls": "last"
4049
+ },
4050
+ {
4051
+ "expression": "created_at",
4052
+ "isExpression": false,
4053
+ "asc": true,
4054
+ "nulls": "last"
4055
+ }
4056
+ ],
4057
+ "isUnique": false,
4058
+ "concurrently": false,
4059
+ "method": "btree",
4060
+ "with": {}
4061
+ },
4062
+ "audit_events_resource_idx": {
4063
+ "name": "audit_events_resource_idx",
4064
+ "columns": [
4065
+ {
4066
+ "expression": "resource_kind",
4067
+ "isExpression": false,
4068
+ "asc": true,
4069
+ "nulls": "last"
4070
+ },
4071
+ {
4072
+ "expression": "resource_id",
4073
+ "isExpression": false,
4074
+ "asc": true,
4075
+ "nulls": "last"
4076
+ }
4077
+ ],
4078
+ "isUnique": false,
4079
+ "concurrently": false,
4080
+ "method": "btree",
4081
+ "with": {}
4082
+ }
4083
+ },
4084
+ "foreignKeys": {
4085
+ "audit_events_workspace_id_organization_id_fk": {
4086
+ "name": "audit_events_workspace_id_organization_id_fk",
4087
+ "tableFrom": "audit_events",
4088
+ "tableTo": "organization",
4089
+ "columnsFrom": ["workspace_id"],
4090
+ "columnsTo": ["id"],
4091
+ "onDelete": "set null",
4092
+ "onUpdate": "no action"
4093
+ },
4094
+ "audit_events_actor_id_users_id_fk": {
4095
+ "name": "audit_events_actor_id_users_id_fk",
4096
+ "tableFrom": "audit_events",
4097
+ "tableTo": "users",
4098
+ "columnsFrom": ["actor_id"],
4099
+ "columnsTo": ["id"],
4100
+ "onDelete": "set null",
4101
+ "onUpdate": "no action"
4102
+ }
4103
+ },
4104
+ "compositePrimaryKeys": {},
4105
+ "uniqueConstraints": {},
4106
+ "policies": {},
4107
+ "checkConstraints": {},
4108
+ "isRLSEnabled": false
4109
+ },
4110
+ "public.executions": {
4111
+ "name": "executions",
4112
+ "schema": "",
4113
+ "columns": {
4114
+ "id": {
4115
+ "name": "id",
4116
+ "type": "text",
4117
+ "primaryKey": true,
4118
+ "notNull": true
4119
+ },
4120
+ "workspace_id": {
4121
+ "name": "workspace_id",
4122
+ "type": "text",
4123
+ "primaryKey": false,
4124
+ "notNull": true
4125
+ },
4126
+ "user_id": {
4127
+ "name": "user_id",
4128
+ "type": "text",
4129
+ "primaryKey": false,
4130
+ "notNull": false
4131
+ },
4132
+ "capability": {
4133
+ "name": "capability",
4134
+ "type": "text",
4135
+ "primaryKey": false,
4136
+ "notNull": true
4137
+ },
4138
+ "request_id": {
4139
+ "name": "request_id",
4140
+ "type": "text",
4141
+ "primaryKey": false,
4142
+ "notNull": true
4143
+ },
4144
+ "status": {
4145
+ "name": "status",
4146
+ "type": "text",
4147
+ "primaryKey": false,
4148
+ "notNull": true,
4149
+ "default": "'running'"
4150
+ },
4151
+ "model": {
4152
+ "name": "model",
4153
+ "type": "text",
4154
+ "primaryKey": false,
4155
+ "notNull": false
4156
+ },
4157
+ "input_tokens": {
4158
+ "name": "input_tokens",
4159
+ "type": "integer",
4160
+ "primaryKey": false,
4161
+ "notNull": false
4162
+ },
4163
+ "output_tokens": {
4164
+ "name": "output_tokens",
4165
+ "type": "integer",
4166
+ "primaryKey": false,
4167
+ "notNull": false
4168
+ },
4169
+ "total_tokens": {
4170
+ "name": "total_tokens",
4171
+ "type": "integer",
4172
+ "primaryKey": false,
4173
+ "notNull": false
4174
+ },
4175
+ "charged_micros": {
4176
+ "name": "charged_micros",
4177
+ "type": "bigint",
4178
+ "primaryKey": false,
4179
+ "notNull": false
4180
+ },
4181
+ "reserved_micros": {
4182
+ "name": "reserved_micros",
4183
+ "type": "bigint",
4184
+ "primaryKey": false,
4185
+ "notNull": false
4186
+ },
4187
+ "price_micros": {
4188
+ "name": "price_micros",
4189
+ "type": "bigint",
4190
+ "primaryKey": false,
4191
+ "notNull": false
4192
+ },
4193
+ "currency": {
4194
+ "name": "currency",
4195
+ "type": "text",
4196
+ "primaryKey": false,
4197
+ "notNull": false
4198
+ },
4199
+ "refusal_reason": {
4200
+ "name": "refusal_reason",
4201
+ "type": "text",
4202
+ "primaryKey": false,
4203
+ "notNull": false
4204
+ },
4205
+ "error_message": {
4206
+ "name": "error_message",
4207
+ "type": "text",
4208
+ "primaryKey": false,
4209
+ "notNull": false
4210
+ },
4211
+ "started_at": {
4212
+ "name": "started_at",
4213
+ "type": "timestamp",
4214
+ "primaryKey": false,
4215
+ "notNull": true,
4216
+ "default": "now()"
4217
+ },
4218
+ "finished_at": {
4219
+ "name": "finished_at",
4220
+ "type": "timestamp",
4221
+ "primaryKey": false,
4222
+ "notNull": false
4223
+ },
4224
+ "duration_ms": {
4225
+ "name": "duration_ms",
4226
+ "type": "integer",
4227
+ "primaryKey": false,
4228
+ "notNull": false
4229
+ },
4230
+ "metadata": {
4231
+ "name": "metadata",
4232
+ "type": "jsonb",
4233
+ "primaryKey": false,
4234
+ "notNull": false
4235
+ }
4236
+ },
4237
+ "indexes": {
4238
+ "executions_workspace_started_idx": {
4239
+ "name": "executions_workspace_started_idx",
4240
+ "columns": [
4241
+ {
4242
+ "expression": "workspace_id",
4243
+ "isExpression": false,
4244
+ "asc": true,
4245
+ "nulls": "last"
4246
+ },
4247
+ {
4248
+ "expression": "started_at",
4249
+ "isExpression": false,
4250
+ "asc": true,
4251
+ "nulls": "last"
4252
+ }
4253
+ ],
4254
+ "isUnique": false,
4255
+ "concurrently": false,
4256
+ "method": "btree",
4257
+ "with": {}
4258
+ },
4259
+ "executions_status_idx": {
4260
+ "name": "executions_status_idx",
4261
+ "columns": [
4262
+ {
4263
+ "expression": "status",
4264
+ "isExpression": false,
4265
+ "asc": true,
4266
+ "nulls": "last"
4267
+ },
4268
+ {
4269
+ "expression": "started_at",
4270
+ "isExpression": false,
4271
+ "asc": true,
4272
+ "nulls": "last"
4273
+ }
4274
+ ],
4275
+ "isUnique": false,
4276
+ "concurrently": false,
4277
+ "method": "btree",
4278
+ "with": {}
4279
+ },
4280
+ "executions_capability_idx": {
4281
+ "name": "executions_capability_idx",
4282
+ "columns": [
4283
+ {
4284
+ "expression": "capability",
4285
+ "isExpression": false,
4286
+ "asc": true,
4287
+ "nulls": "last"
4288
+ },
4289
+ {
4290
+ "expression": "started_at",
4291
+ "isExpression": false,
4292
+ "asc": true,
4293
+ "nulls": "last"
4294
+ }
4295
+ ],
4296
+ "isUnique": false,
4297
+ "concurrently": false,
4298
+ "method": "btree",
4299
+ "with": {}
4300
+ }
4301
+ },
4302
+ "foreignKeys": {
4303
+ "executions_workspace_id_organization_id_fk": {
4304
+ "name": "executions_workspace_id_organization_id_fk",
4305
+ "tableFrom": "executions",
4306
+ "tableTo": "organization",
4307
+ "columnsFrom": ["workspace_id"],
4308
+ "columnsTo": ["id"],
4309
+ "onDelete": "cascade",
4310
+ "onUpdate": "no action"
4311
+ },
4312
+ "executions_user_id_users_id_fk": {
4313
+ "name": "executions_user_id_users_id_fk",
4314
+ "tableFrom": "executions",
4315
+ "tableTo": "users",
4316
+ "columnsFrom": ["user_id"],
4317
+ "columnsTo": ["id"],
4318
+ "onDelete": "set null",
4319
+ "onUpdate": "no action"
4320
+ }
4321
+ },
4322
+ "compositePrimaryKeys": {},
4323
+ "uniqueConstraints": {
4324
+ "executions_request_id_unique": {
4325
+ "name": "executions_request_id_unique",
4326
+ "nullsNotDistinct": false,
4327
+ "columns": ["request_id"]
4328
+ }
4329
+ },
4330
+ "policies": {},
4331
+ "checkConstraints": {},
4332
+ "isRLSEnabled": false
4333
+ },
4334
+ "public.jobs": {
4335
+ "name": "jobs",
4336
+ "schema": "",
4337
+ "columns": {
4338
+ "id": {
4339
+ "name": "id",
4340
+ "type": "text",
4341
+ "primaryKey": true,
4342
+ "notNull": true
4343
+ },
4344
+ "workspace_id": {
4345
+ "name": "workspace_id",
4346
+ "type": "text",
4347
+ "primaryKey": false,
4348
+ "notNull": false
4349
+ },
4350
+ "kind": {
4351
+ "name": "kind",
4352
+ "type": "text",
4353
+ "primaryKey": false,
4354
+ "notNull": true
4355
+ },
4356
+ "payload": {
4357
+ "name": "payload",
4358
+ "type": "jsonb",
4359
+ "primaryKey": false,
4360
+ "notNull": false
4361
+ },
4362
+ "status": {
4363
+ "name": "status",
4364
+ "type": "text",
4365
+ "primaryKey": false,
4366
+ "notNull": true,
4367
+ "default": "'pending'"
4368
+ },
4369
+ "attempts": {
4370
+ "name": "attempts",
4371
+ "type": "integer",
4372
+ "primaryKey": false,
4373
+ "notNull": true,
4374
+ "default": 0
4375
+ },
4376
+ "max_attempts": {
4377
+ "name": "max_attempts",
4378
+ "type": "integer",
4379
+ "primaryKey": false,
4380
+ "notNull": true,
4381
+ "default": 3
4382
+ },
4383
+ "run_at": {
4384
+ "name": "run_at",
4385
+ "type": "timestamp",
4386
+ "primaryKey": false,
4387
+ "notNull": true,
4388
+ "default": "now()"
4389
+ },
4390
+ "started_at": {
4391
+ "name": "started_at",
4392
+ "type": "timestamp",
4393
+ "primaryKey": false,
4394
+ "notNull": false
4395
+ },
4396
+ "finished_at": {
4397
+ "name": "finished_at",
4398
+ "type": "timestamp",
4399
+ "primaryKey": false,
4400
+ "notNull": false
4401
+ },
4402
+ "last_error": {
4403
+ "name": "last_error",
4404
+ "type": "text",
4405
+ "primaryKey": false,
4406
+ "notNull": false
4407
+ },
4408
+ "created_at": {
4409
+ "name": "created_at",
4410
+ "type": "timestamp",
4411
+ "primaryKey": false,
4412
+ "notNull": true,
4413
+ "default": "now()"
4414
+ }
4415
+ },
4416
+ "indexes": {
4417
+ "jobs_claim_idx": {
4418
+ "name": "jobs_claim_idx",
4419
+ "columns": [
4420
+ {
4421
+ "expression": "status",
4422
+ "isExpression": false,
4423
+ "asc": true,
4424
+ "nulls": "last"
4425
+ },
4426
+ {
4427
+ "expression": "run_at",
4428
+ "isExpression": false,
4429
+ "asc": true,
4430
+ "nulls": "last"
4431
+ }
4432
+ ],
4433
+ "isUnique": false,
4434
+ "concurrently": false,
4435
+ "method": "btree",
4436
+ "with": {}
4437
+ },
4438
+ "jobs_kind_idx": {
4439
+ "name": "jobs_kind_idx",
4440
+ "columns": [
4441
+ {
4442
+ "expression": "kind",
4443
+ "isExpression": false,
4444
+ "asc": true,
4445
+ "nulls": "last"
4446
+ },
4447
+ {
4448
+ "expression": "status",
4449
+ "isExpression": false,
4450
+ "asc": true,
4451
+ "nulls": "last"
4452
+ }
4453
+ ],
4454
+ "isUnique": false,
4455
+ "concurrently": false,
4456
+ "method": "btree",
4457
+ "with": {}
4458
+ },
4459
+ "jobs_workspace_idx": {
4460
+ "name": "jobs_workspace_idx",
4461
+ "columns": [
4462
+ {
4463
+ "expression": "workspace_id",
4464
+ "isExpression": false,
4465
+ "asc": true,
4466
+ "nulls": "last"
4467
+ }
4468
+ ],
4469
+ "isUnique": false,
4470
+ "concurrently": false,
4471
+ "method": "btree",
4472
+ "with": {}
4473
+ }
4474
+ },
4475
+ "foreignKeys": {
4476
+ "jobs_workspace_id_organization_id_fk": {
4477
+ "name": "jobs_workspace_id_organization_id_fk",
4478
+ "tableFrom": "jobs",
4479
+ "tableTo": "organization",
4480
+ "columnsFrom": ["workspace_id"],
4481
+ "columnsTo": ["id"],
4482
+ "onDelete": "cascade",
4483
+ "onUpdate": "no action"
4484
+ }
4485
+ },
4486
+ "compositePrimaryKeys": {},
4487
+ "uniqueConstraints": {},
4488
+ "policies": {},
4489
+ "checkConstraints": {},
4490
+ "isRLSEnabled": false
4491
+ }
4492
+ },
4493
+ "enums": {},
4494
+ "schemas": {},
4495
+ "sequences": {},
4496
+ "roles": {},
4497
+ "policies": {},
4498
+ "views": {},
4499
+ "_meta": {
4500
+ "columns": {},
4501
+ "schemas": {},
4502
+ "tables": {}
4503
+ }
4504
+ }