@claroshq/claros 0.8.3 → 0.8.12

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.
@@ -0,0 +1,3873 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "ff4b0492-b141-4641-8165-c905113695d7",
5
+ "prevId": "4d9b7c75-4258-4d88-ba1f-674a3cfc9dd4",
6
+ "tables": {
7
+ "api_keys": {
8
+ "name": "api_keys",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "text",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": false
16
+ },
17
+ "tenant_id": {
18
+ "name": "tenant_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": false,
22
+ "autoincrement": false
23
+ },
24
+ "key_hash": {
25
+ "name": "key_hash",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "prefix": {
32
+ "name": "prefix",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": true,
36
+ "autoincrement": false
37
+ },
38
+ "label": {
39
+ "name": "label",
40
+ "type": "text",
41
+ "primaryKey": false,
42
+ "notNull": false,
43
+ "autoincrement": false
44
+ },
45
+ "kind": {
46
+ "name": "kind",
47
+ "type": "text",
48
+ "primaryKey": false,
49
+ "notNull": true,
50
+ "autoincrement": false,
51
+ "default": "'secret'"
52
+ },
53
+ "allowed_origins": {
54
+ "name": "allowed_origins",
55
+ "type": "text",
56
+ "primaryKey": false,
57
+ "notNull": false,
58
+ "autoincrement": false
59
+ },
60
+ "scopes": {
61
+ "name": "scopes",
62
+ "type": "text",
63
+ "primaryKey": false,
64
+ "notNull": false,
65
+ "autoincrement": false
66
+ },
67
+ "last_used_at": {
68
+ "name": "last_used_at",
69
+ "type": "integer",
70
+ "primaryKey": false,
71
+ "notNull": false,
72
+ "autoincrement": false
73
+ },
74
+ "created_at": {
75
+ "name": "created_at",
76
+ "type": "integer",
77
+ "primaryKey": false,
78
+ "notNull": false,
79
+ "autoincrement": false
80
+ },
81
+ "revoked_at": {
82
+ "name": "revoked_at",
83
+ "type": "integer",
84
+ "primaryKey": false,
85
+ "notNull": false,
86
+ "autoincrement": false
87
+ }
88
+ },
89
+ "indexes": {
90
+ "uq_api_keys_hash_active": {
91
+ "name": "uq_api_keys_hash_active",
92
+ "columns": [
93
+ "key_hash"
94
+ ],
95
+ "isUnique": true,
96
+ "where": "revoked_at IS NULL"
97
+ },
98
+ "idx_api_keys_tenant": {
99
+ "name": "idx_api_keys_tenant",
100
+ "columns": [
101
+ "tenant_id"
102
+ ],
103
+ "isUnique": false
104
+ }
105
+ },
106
+ "foreignKeys": {
107
+ "api_keys_tenant_id_tenants_id_fk": {
108
+ "name": "api_keys_tenant_id_tenants_id_fk",
109
+ "tableFrom": "api_keys",
110
+ "tableTo": "tenants",
111
+ "columnsFrom": [
112
+ "tenant_id"
113
+ ],
114
+ "columnsTo": [
115
+ "id"
116
+ ],
117
+ "onDelete": "no action",
118
+ "onUpdate": "no action"
119
+ }
120
+ },
121
+ "compositePrimaryKeys": {},
122
+ "uniqueConstraints": {},
123
+ "checkConstraints": {}
124
+ },
125
+ "brand_assets": {
126
+ "name": "brand_assets",
127
+ "columns": {
128
+ "tenant_id": {
129
+ "name": "tenant_id",
130
+ "type": "text",
131
+ "primaryKey": false,
132
+ "notNull": true,
133
+ "autoincrement": false
134
+ },
135
+ "kind": {
136
+ "name": "kind",
137
+ "type": "text",
138
+ "primaryKey": false,
139
+ "notNull": true,
140
+ "autoincrement": false
141
+ },
142
+ "content_type": {
143
+ "name": "content_type",
144
+ "type": "text",
145
+ "primaryKey": false,
146
+ "notNull": true,
147
+ "autoincrement": false
148
+ },
149
+ "bytes": {
150
+ "name": "bytes",
151
+ "type": "blob",
152
+ "primaryKey": false,
153
+ "notNull": true,
154
+ "autoincrement": false
155
+ },
156
+ "width": {
157
+ "name": "width",
158
+ "type": "integer",
159
+ "primaryKey": false,
160
+ "notNull": true,
161
+ "autoincrement": false
162
+ },
163
+ "height": {
164
+ "name": "height",
165
+ "type": "integer",
166
+ "primaryKey": false,
167
+ "notNull": true,
168
+ "autoincrement": false
169
+ },
170
+ "sha256": {
171
+ "name": "sha256",
172
+ "type": "text",
173
+ "primaryKey": false,
174
+ "notNull": true,
175
+ "autoincrement": false
176
+ },
177
+ "updated_at": {
178
+ "name": "updated_at",
179
+ "type": "integer",
180
+ "primaryKey": false,
181
+ "notNull": true,
182
+ "autoincrement": false
183
+ }
184
+ },
185
+ "indexes": {},
186
+ "foreignKeys": {
187
+ "brand_assets_tenant_id_tenants_id_fk": {
188
+ "name": "brand_assets_tenant_id_tenants_id_fk",
189
+ "tableFrom": "brand_assets",
190
+ "tableTo": "tenants",
191
+ "columnsFrom": [
192
+ "tenant_id"
193
+ ],
194
+ "columnsTo": [
195
+ "id"
196
+ ],
197
+ "onDelete": "no action",
198
+ "onUpdate": "no action"
199
+ }
200
+ },
201
+ "compositePrimaryKeys": {
202
+ "brand_assets_pkey": {
203
+ "columns": [
204
+ "tenant_id",
205
+ "kind"
206
+ ],
207
+ "name": "brand_assets_pkey"
208
+ }
209
+ },
210
+ "uniqueConstraints": {},
211
+ "checkConstraints": {}
212
+ },
213
+ "claim_tokens": {
214
+ "name": "claim_tokens",
215
+ "columns": {
216
+ "id": {
217
+ "name": "id",
218
+ "type": "text",
219
+ "primaryKey": true,
220
+ "notNull": true,
221
+ "autoincrement": false
222
+ },
223
+ "token_hash": {
224
+ "name": "token_hash",
225
+ "type": "text",
226
+ "primaryKey": false,
227
+ "notNull": true,
228
+ "autoincrement": false
229
+ },
230
+ "expires_at": {
231
+ "name": "expires_at",
232
+ "type": "integer",
233
+ "primaryKey": false,
234
+ "notNull": true,
235
+ "autoincrement": false
236
+ },
237
+ "consumed_at": {
238
+ "name": "consumed_at",
239
+ "type": "integer",
240
+ "primaryKey": false,
241
+ "notNull": false,
242
+ "autoincrement": false
243
+ },
244
+ "created_at": {
245
+ "name": "created_at",
246
+ "type": "integer",
247
+ "primaryKey": false,
248
+ "notNull": false,
249
+ "autoincrement": false
250
+ }
251
+ },
252
+ "indexes": {
253
+ "uq_claim_tokens_token_hash": {
254
+ "name": "uq_claim_tokens_token_hash",
255
+ "columns": [
256
+ "token_hash"
257
+ ],
258
+ "isUnique": true
259
+ }
260
+ },
261
+ "foreignKeys": {},
262
+ "compositePrimaryKeys": {},
263
+ "uniqueConstraints": {},
264
+ "checkConstraints": {}
265
+ },
266
+ "contact_conflicts": {
267
+ "name": "contact_conflicts",
268
+ "columns": {
269
+ "id": {
270
+ "name": "id",
271
+ "type": "text",
272
+ "primaryKey": true,
273
+ "notNull": true,
274
+ "autoincrement": false
275
+ },
276
+ "tenant_id": {
277
+ "name": "tenant_id",
278
+ "type": "text",
279
+ "primaryKey": false,
280
+ "notNull": true,
281
+ "autoincrement": false
282
+ },
283
+ "contact_id": {
284
+ "name": "contact_id",
285
+ "type": "text",
286
+ "primaryKey": false,
287
+ "notNull": true,
288
+ "autoincrement": false
289
+ },
290
+ "field": {
291
+ "name": "field",
292
+ "type": "text",
293
+ "primaryKey": false,
294
+ "notNull": true,
295
+ "autoincrement": false
296
+ },
297
+ "rejected_value": {
298
+ "name": "rejected_value",
299
+ "type": "text",
300
+ "primaryKey": false,
301
+ "notNull": true,
302
+ "autoincrement": false
303
+ },
304
+ "event_id": {
305
+ "name": "event_id",
306
+ "type": "text",
307
+ "primaryKey": false,
308
+ "notNull": true,
309
+ "autoincrement": false
310
+ },
311
+ "created_at": {
312
+ "name": "created_at",
313
+ "type": "integer",
314
+ "primaryKey": false,
315
+ "notNull": false,
316
+ "autoincrement": false
317
+ }
318
+ },
319
+ "indexes": {
320
+ "idx_contact_conflicts_tenant": {
321
+ "name": "idx_contact_conflicts_tenant",
322
+ "columns": [
323
+ "tenant_id",
324
+ "created_at"
325
+ ],
326
+ "isUnique": false
327
+ },
328
+ "idx_contact_conflicts_contact": {
329
+ "name": "idx_contact_conflicts_contact",
330
+ "columns": [
331
+ "contact_id"
332
+ ],
333
+ "isUnique": false
334
+ }
335
+ },
336
+ "foreignKeys": {
337
+ "contact_conflicts_tenant_id_tenants_id_fk": {
338
+ "name": "contact_conflicts_tenant_id_tenants_id_fk",
339
+ "tableFrom": "contact_conflicts",
340
+ "tableTo": "tenants",
341
+ "columnsFrom": [
342
+ "tenant_id"
343
+ ],
344
+ "columnsTo": [
345
+ "id"
346
+ ],
347
+ "onDelete": "no action",
348
+ "onUpdate": "no action"
349
+ },
350
+ "contact_conflicts_contact_id_contacts_id_fk": {
351
+ "name": "contact_conflicts_contact_id_contacts_id_fk",
352
+ "tableFrom": "contact_conflicts",
353
+ "tableTo": "contacts",
354
+ "columnsFrom": [
355
+ "contact_id"
356
+ ],
357
+ "columnsTo": [
358
+ "id"
359
+ ],
360
+ "onDelete": "no action",
361
+ "onUpdate": "no action"
362
+ }
363
+ },
364
+ "compositePrimaryKeys": {},
365
+ "uniqueConstraints": {},
366
+ "checkConstraints": {}
367
+ },
368
+ "contact_dates": {
369
+ "name": "contact_dates",
370
+ "columns": {
371
+ "tenant_id": {
372
+ "name": "tenant_id",
373
+ "type": "text",
374
+ "primaryKey": false,
375
+ "notNull": true,
376
+ "autoincrement": false
377
+ },
378
+ "contact_id": {
379
+ "name": "contact_id",
380
+ "type": "text",
381
+ "primaryKey": false,
382
+ "notNull": true,
383
+ "autoincrement": false
384
+ },
385
+ "property": {
386
+ "name": "property",
387
+ "type": "text",
388
+ "primaryKey": false,
389
+ "notNull": true,
390
+ "autoincrement": false
391
+ },
392
+ "value": {
393
+ "name": "value",
394
+ "type": "integer",
395
+ "primaryKey": false,
396
+ "notNull": true,
397
+ "autoincrement": false
398
+ },
399
+ "updated_at": {
400
+ "name": "updated_at",
401
+ "type": "integer",
402
+ "primaryKey": false,
403
+ "notNull": false,
404
+ "autoincrement": false
405
+ }
406
+ },
407
+ "indexes": {
408
+ "idx_contact_dates_scan": {
409
+ "name": "idx_contact_dates_scan",
410
+ "columns": [
411
+ "tenant_id",
412
+ "property",
413
+ "value"
414
+ ],
415
+ "isUnique": false
416
+ }
417
+ },
418
+ "foreignKeys": {
419
+ "contact_dates_tenant_id_tenants_id_fk": {
420
+ "name": "contact_dates_tenant_id_tenants_id_fk",
421
+ "tableFrom": "contact_dates",
422
+ "tableTo": "tenants",
423
+ "columnsFrom": [
424
+ "tenant_id"
425
+ ],
426
+ "columnsTo": [
427
+ "id"
428
+ ],
429
+ "onDelete": "no action",
430
+ "onUpdate": "no action"
431
+ },
432
+ "contact_dates_contact_id_contacts_id_fk": {
433
+ "name": "contact_dates_contact_id_contacts_id_fk",
434
+ "tableFrom": "contact_dates",
435
+ "tableTo": "contacts",
436
+ "columnsFrom": [
437
+ "contact_id"
438
+ ],
439
+ "columnsTo": [
440
+ "id"
441
+ ],
442
+ "onDelete": "no action",
443
+ "onUpdate": "no action"
444
+ }
445
+ },
446
+ "compositePrimaryKeys": {
447
+ "contact_dates_pkey": {
448
+ "columns": [
449
+ "tenant_id",
450
+ "contact_id",
451
+ "property"
452
+ ],
453
+ "name": "contact_dates_pkey"
454
+ }
455
+ },
456
+ "uniqueConstraints": {},
457
+ "checkConstraints": {}
458
+ },
459
+ "contact_topics": {
460
+ "name": "contact_topics",
461
+ "columns": {
462
+ "tenant_id": {
463
+ "name": "tenant_id",
464
+ "type": "text",
465
+ "primaryKey": false,
466
+ "notNull": true,
467
+ "autoincrement": false
468
+ },
469
+ "contact_id": {
470
+ "name": "contact_id",
471
+ "type": "text",
472
+ "primaryKey": false,
473
+ "notNull": true,
474
+ "autoincrement": false
475
+ },
476
+ "topic_id": {
477
+ "name": "topic_id",
478
+ "type": "text",
479
+ "primaryKey": false,
480
+ "notNull": true,
481
+ "autoincrement": false
482
+ },
483
+ "status": {
484
+ "name": "status",
485
+ "type": "text",
486
+ "primaryKey": false,
487
+ "notNull": true,
488
+ "autoincrement": false
489
+ },
490
+ "updated_at": {
491
+ "name": "updated_at",
492
+ "type": "integer",
493
+ "primaryKey": false,
494
+ "notNull": false,
495
+ "autoincrement": false
496
+ },
497
+ "source": {
498
+ "name": "source",
499
+ "type": "text",
500
+ "primaryKey": false,
501
+ "notNull": false,
502
+ "autoincrement": false
503
+ }
504
+ },
505
+ "indexes": {
506
+ "idx_contact_topics_tenant_topic": {
507
+ "name": "idx_contact_topics_tenant_topic",
508
+ "columns": [
509
+ "tenant_id",
510
+ "topic_id"
511
+ ],
512
+ "isUnique": false
513
+ }
514
+ },
515
+ "foreignKeys": {
516
+ "contact_topics_tenant_id_tenants_id_fk": {
517
+ "name": "contact_topics_tenant_id_tenants_id_fk",
518
+ "tableFrom": "contact_topics",
519
+ "tableTo": "tenants",
520
+ "columnsFrom": [
521
+ "tenant_id"
522
+ ],
523
+ "columnsTo": [
524
+ "id"
525
+ ],
526
+ "onDelete": "no action",
527
+ "onUpdate": "no action"
528
+ },
529
+ "contact_topics_contact_id_contacts_id_fk": {
530
+ "name": "contact_topics_contact_id_contacts_id_fk",
531
+ "tableFrom": "contact_topics",
532
+ "tableTo": "contacts",
533
+ "columnsFrom": [
534
+ "contact_id"
535
+ ],
536
+ "columnsTo": [
537
+ "id"
538
+ ],
539
+ "onDelete": "no action",
540
+ "onUpdate": "no action"
541
+ },
542
+ "contact_topics_topic_id_topics_id_fk": {
543
+ "name": "contact_topics_topic_id_topics_id_fk",
544
+ "tableFrom": "contact_topics",
545
+ "tableTo": "topics",
546
+ "columnsFrom": [
547
+ "topic_id"
548
+ ],
549
+ "columnsTo": [
550
+ "id"
551
+ ],
552
+ "onDelete": "no action",
553
+ "onUpdate": "no action"
554
+ }
555
+ },
556
+ "compositePrimaryKeys": {
557
+ "contact_topics_pkey": {
558
+ "columns": [
559
+ "contact_id",
560
+ "topic_id"
561
+ ],
562
+ "name": "contact_topics_pkey"
563
+ }
564
+ },
565
+ "uniqueConstraints": {},
566
+ "checkConstraints": {}
567
+ },
568
+ "contacts": {
569
+ "name": "contacts",
570
+ "columns": {
571
+ "id": {
572
+ "name": "id",
573
+ "type": "text",
574
+ "primaryKey": true,
575
+ "notNull": true,
576
+ "autoincrement": false
577
+ },
578
+ "tenant_id": {
579
+ "name": "tenant_id",
580
+ "type": "text",
581
+ "primaryKey": false,
582
+ "notNull": true,
583
+ "autoincrement": false
584
+ },
585
+ "external_id": {
586
+ "name": "external_id",
587
+ "type": "text",
588
+ "primaryKey": false,
589
+ "notNull": true,
590
+ "autoincrement": false
591
+ },
592
+ "email": {
593
+ "name": "email",
594
+ "type": "text",
595
+ "primaryKey": false,
596
+ "notNull": false,
597
+ "autoincrement": false
598
+ },
599
+ "name": {
600
+ "name": "name",
601
+ "type": "text",
602
+ "primaryKey": false,
603
+ "notNull": false,
604
+ "autoincrement": false
605
+ },
606
+ "company": {
607
+ "name": "company",
608
+ "type": "text",
609
+ "primaryKey": false,
610
+ "notNull": false,
611
+ "autoincrement": false
612
+ },
613
+ "properties": {
614
+ "name": "properties",
615
+ "type": "text",
616
+ "primaryKey": false,
617
+ "notNull": false,
618
+ "autoincrement": false
619
+ },
620
+ "lifecycle_state": {
621
+ "name": "lifecycle_state",
622
+ "type": "text",
623
+ "primaryKey": false,
624
+ "notNull": true,
625
+ "autoincrement": false
626
+ },
627
+ "engagement_depth": {
628
+ "name": "engagement_depth",
629
+ "type": "text",
630
+ "primaryKey": false,
631
+ "notNull": false,
632
+ "autoincrement": false
633
+ },
634
+ "payment_status": {
635
+ "name": "payment_status",
636
+ "type": "text",
637
+ "primaryKey": false,
638
+ "notNull": false,
639
+ "autoincrement": false,
640
+ "default": "'free'"
641
+ },
642
+ "first_seen_at": {
643
+ "name": "first_seen_at",
644
+ "type": "integer",
645
+ "primaryKey": false,
646
+ "notNull": false,
647
+ "autoincrement": false
648
+ },
649
+ "last_seen_at": {
650
+ "name": "last_seen_at",
651
+ "type": "integer",
652
+ "primaryKey": false,
653
+ "notNull": false,
654
+ "autoincrement": false
655
+ },
656
+ "activated_at": {
657
+ "name": "activated_at",
658
+ "type": "integer",
659
+ "primaryKey": false,
660
+ "notNull": false,
661
+ "autoincrement": false
662
+ },
663
+ "created_at": {
664
+ "name": "created_at",
665
+ "type": "integer",
666
+ "primaryKey": false,
667
+ "notNull": false,
668
+ "autoincrement": false
669
+ },
670
+ "event_count_bucket_current": {
671
+ "name": "event_count_bucket_current",
672
+ "type": "integer",
673
+ "primaryKey": false,
674
+ "notNull": false,
675
+ "autoincrement": false,
676
+ "default": 0
677
+ },
678
+ "event_count_bucket_prev": {
679
+ "name": "event_count_bucket_prev",
680
+ "type": "integer",
681
+ "primaryKey": false,
682
+ "notNull": false,
683
+ "autoincrement": false,
684
+ "default": 0
685
+ },
686
+ "last_counter_reset_at": {
687
+ "name": "last_counter_reset_at",
688
+ "type": "integer",
689
+ "primaryKey": false,
690
+ "notNull": false,
691
+ "autoincrement": false
692
+ }
693
+ },
694
+ "indexes": {
695
+ "uq_contacts_tenant_external_id": {
696
+ "name": "uq_contacts_tenant_external_id",
697
+ "columns": [
698
+ "tenant_id",
699
+ "external_id"
700
+ ],
701
+ "isUnique": true
702
+ },
703
+ "uq_contacts_tenant_email": {
704
+ "name": "uq_contacts_tenant_email",
705
+ "columns": [
706
+ "tenant_id",
707
+ "email"
708
+ ],
709
+ "isUnique": true,
710
+ "where": "email IS NOT NULL"
711
+ },
712
+ "idx_contacts_tenant_state": {
713
+ "name": "idx_contacts_tenant_state",
714
+ "columns": [
715
+ "tenant_id",
716
+ "lifecycle_state"
717
+ ],
718
+ "isUnique": false
719
+ },
720
+ "idx_contacts_last_seen": {
721
+ "name": "idx_contacts_last_seen",
722
+ "columns": [
723
+ "tenant_id",
724
+ "last_seen_at"
725
+ ],
726
+ "isUnique": false
727
+ },
728
+ "idx_contacts_tenant_created": {
729
+ "name": "idx_contacts_tenant_created",
730
+ "columns": [
731
+ "tenant_id",
732
+ "created_at",
733
+ "id"
734
+ ],
735
+ "isUnique": false
736
+ }
737
+ },
738
+ "foreignKeys": {
739
+ "contacts_tenant_id_tenants_id_fk": {
740
+ "name": "contacts_tenant_id_tenants_id_fk",
741
+ "tableFrom": "contacts",
742
+ "tableTo": "tenants",
743
+ "columnsFrom": [
744
+ "tenant_id"
745
+ ],
746
+ "columnsTo": [
747
+ "id"
748
+ ],
749
+ "onDelete": "no action",
750
+ "onUpdate": "no action"
751
+ }
752
+ },
753
+ "compositePrimaryKeys": {},
754
+ "uniqueConstraints": {},
755
+ "checkConstraints": {}
756
+ },
757
+ "events": {
758
+ "name": "events",
759
+ "columns": {
760
+ "id": {
761
+ "name": "id",
762
+ "type": "text",
763
+ "primaryKey": true,
764
+ "notNull": true,
765
+ "autoincrement": false
766
+ },
767
+ "tenant_id": {
768
+ "name": "tenant_id",
769
+ "type": "text",
770
+ "primaryKey": false,
771
+ "notNull": true,
772
+ "autoincrement": false
773
+ },
774
+ "contact_id": {
775
+ "name": "contact_id",
776
+ "type": "text",
777
+ "primaryKey": false,
778
+ "notNull": true,
779
+ "autoincrement": false
780
+ },
781
+ "type": {
782
+ "name": "type",
783
+ "type": "text",
784
+ "primaryKey": false,
785
+ "notNull": true,
786
+ "autoincrement": false
787
+ },
788
+ "event_name": {
789
+ "name": "event_name",
790
+ "type": "text",
791
+ "primaryKey": false,
792
+ "notNull": false,
793
+ "autoincrement": false
794
+ },
795
+ "properties": {
796
+ "name": "properties",
797
+ "type": "text",
798
+ "primaryKey": false,
799
+ "notNull": false,
800
+ "autoincrement": false
801
+ },
802
+ "context": {
803
+ "name": "context",
804
+ "type": "text",
805
+ "primaryKey": false,
806
+ "notNull": false,
807
+ "autoincrement": false
808
+ },
809
+ "message_id": {
810
+ "name": "message_id",
811
+ "type": "text",
812
+ "primaryKey": false,
813
+ "notNull": false,
814
+ "autoincrement": false
815
+ },
816
+ "timestamp": {
817
+ "name": "timestamp",
818
+ "type": "integer",
819
+ "primaryKey": false,
820
+ "notNull": true,
821
+ "autoincrement": false
822
+ },
823
+ "received_at": {
824
+ "name": "received_at",
825
+ "type": "integer",
826
+ "primaryKey": false,
827
+ "notNull": true,
828
+ "autoincrement": false
829
+ }
830
+ },
831
+ "indexes": {
832
+ "idx_events_contact_time": {
833
+ "name": "idx_events_contact_time",
834
+ "columns": [
835
+ "contact_id",
836
+ "timestamp"
837
+ ],
838
+ "isUnique": false
839
+ },
840
+ "idx_events_tenant_name": {
841
+ "name": "idx_events_tenant_name",
842
+ "columns": [
843
+ "tenant_id",
844
+ "event_name",
845
+ "timestamp"
846
+ ],
847
+ "isUnique": false
848
+ },
849
+ "idx_events_tenant_time": {
850
+ "name": "idx_events_tenant_time",
851
+ "columns": [
852
+ "tenant_id",
853
+ "timestamp"
854
+ ],
855
+ "isUnique": false
856
+ },
857
+ "idx_events_dedup_lookup": {
858
+ "name": "idx_events_dedup_lookup",
859
+ "columns": [
860
+ "tenant_id",
861
+ "message_id"
862
+ ],
863
+ "isUnique": false,
864
+ "where": "message_id IS NOT NULL"
865
+ }
866
+ },
867
+ "foreignKeys": {
868
+ "events_tenant_id_tenants_id_fk": {
869
+ "name": "events_tenant_id_tenants_id_fk",
870
+ "tableFrom": "events",
871
+ "tableTo": "tenants",
872
+ "columnsFrom": [
873
+ "tenant_id"
874
+ ],
875
+ "columnsTo": [
876
+ "id"
877
+ ],
878
+ "onDelete": "no action",
879
+ "onUpdate": "no action"
880
+ },
881
+ "events_contact_id_contacts_id_fk": {
882
+ "name": "events_contact_id_contacts_id_fk",
883
+ "tableFrom": "events",
884
+ "tableTo": "contacts",
885
+ "columnsFrom": [
886
+ "contact_id"
887
+ ],
888
+ "columnsTo": [
889
+ "id"
890
+ ],
891
+ "onDelete": "no action",
892
+ "onUpdate": "no action"
893
+ }
894
+ },
895
+ "compositePrimaryKeys": {},
896
+ "uniqueConstraints": {},
897
+ "checkConstraints": {}
898
+ },
899
+ "flow_memberships": {
900
+ "name": "flow_memberships",
901
+ "columns": {
902
+ "id": {
903
+ "name": "id",
904
+ "type": "text",
905
+ "primaryKey": true,
906
+ "notNull": true,
907
+ "autoincrement": false
908
+ },
909
+ "tenant_id": {
910
+ "name": "tenant_id",
911
+ "type": "text",
912
+ "primaryKey": false,
913
+ "notNull": true,
914
+ "autoincrement": false
915
+ },
916
+ "contact_id": {
917
+ "name": "contact_id",
918
+ "type": "text",
919
+ "primaryKey": false,
920
+ "notNull": true,
921
+ "autoincrement": false
922
+ },
923
+ "flow_id": {
924
+ "name": "flow_id",
925
+ "type": "text",
926
+ "primaryKey": false,
927
+ "notNull": true,
928
+ "autoincrement": false
929
+ },
930
+ "current_step": {
931
+ "name": "current_step",
932
+ "type": "integer",
933
+ "primaryKey": false,
934
+ "notNull": true,
935
+ "autoincrement": false,
936
+ "default": 1
937
+ },
938
+ "status": {
939
+ "name": "status",
940
+ "type": "text",
941
+ "primaryKey": false,
942
+ "notNull": true,
943
+ "autoincrement": false,
944
+ "default": "'active'"
945
+ },
946
+ "entered_at": {
947
+ "name": "entered_at",
948
+ "type": "integer",
949
+ "primaryKey": false,
950
+ "notNull": true,
951
+ "autoincrement": false
952
+ },
953
+ "completed_at": {
954
+ "name": "completed_at",
955
+ "type": "integer",
956
+ "primaryKey": false,
957
+ "notNull": false,
958
+ "autoincrement": false
959
+ },
960
+ "exited_at": {
961
+ "name": "exited_at",
962
+ "type": "integer",
963
+ "primaryKey": false,
964
+ "notNull": false,
965
+ "autoincrement": false
966
+ },
967
+ "exit_reason": {
968
+ "name": "exit_reason",
969
+ "type": "text",
970
+ "primaryKey": false,
971
+ "notNull": false,
972
+ "autoincrement": false
973
+ },
974
+ "condition_error": {
975
+ "name": "condition_error",
976
+ "type": "text",
977
+ "primaryKey": false,
978
+ "notNull": false,
979
+ "autoincrement": false
980
+ },
981
+ "anchor_at": {
982
+ "name": "anchor_at",
983
+ "type": "integer",
984
+ "primaryKey": false,
985
+ "notNull": false,
986
+ "autoincrement": false
987
+ },
988
+ "trigger_properties": {
989
+ "name": "trigger_properties",
990
+ "type": "text",
991
+ "primaryKey": false,
992
+ "notNull": false,
993
+ "autoincrement": false
994
+ }
995
+ },
996
+ "indexes": {
997
+ "uq_flow_membership_active": {
998
+ "name": "uq_flow_membership_active",
999
+ "columns": [
1000
+ "contact_id",
1001
+ "flow_id"
1002
+ ],
1003
+ "isUnique": true,
1004
+ "where": "status = 'active'"
1005
+ },
1006
+ "uq_flow_membership_anchor": {
1007
+ "name": "uq_flow_membership_anchor",
1008
+ "columns": [
1009
+ "tenant_id",
1010
+ "flow_id",
1011
+ "contact_id",
1012
+ "anchor_at"
1013
+ ],
1014
+ "isUnique": true,
1015
+ "where": "anchor_at IS NOT NULL"
1016
+ },
1017
+ "idx_flow_members_contact": {
1018
+ "name": "idx_flow_members_contact",
1019
+ "columns": [
1020
+ "contact_id",
1021
+ "status"
1022
+ ],
1023
+ "isUnique": false
1024
+ },
1025
+ "idx_flow_members_flow": {
1026
+ "name": "idx_flow_members_flow",
1027
+ "columns": [
1028
+ "flow_id",
1029
+ "status",
1030
+ "current_step"
1031
+ ],
1032
+ "isUnique": false
1033
+ }
1034
+ },
1035
+ "foreignKeys": {
1036
+ "flow_memberships_tenant_id_tenants_id_fk": {
1037
+ "name": "flow_memberships_tenant_id_tenants_id_fk",
1038
+ "tableFrom": "flow_memberships",
1039
+ "tableTo": "tenants",
1040
+ "columnsFrom": [
1041
+ "tenant_id"
1042
+ ],
1043
+ "columnsTo": [
1044
+ "id"
1045
+ ],
1046
+ "onDelete": "no action",
1047
+ "onUpdate": "no action"
1048
+ },
1049
+ "flow_memberships_contact_id_contacts_id_fk": {
1050
+ "name": "flow_memberships_contact_id_contacts_id_fk",
1051
+ "tableFrom": "flow_memberships",
1052
+ "tableTo": "contacts",
1053
+ "columnsFrom": [
1054
+ "contact_id"
1055
+ ],
1056
+ "columnsTo": [
1057
+ "id"
1058
+ ],
1059
+ "onDelete": "no action",
1060
+ "onUpdate": "no action"
1061
+ },
1062
+ "flow_memberships_flow_id_flows_id_fk": {
1063
+ "name": "flow_memberships_flow_id_flows_id_fk",
1064
+ "tableFrom": "flow_memberships",
1065
+ "tableTo": "flows",
1066
+ "columnsFrom": [
1067
+ "flow_id"
1068
+ ],
1069
+ "columnsTo": [
1070
+ "id"
1071
+ ],
1072
+ "onDelete": "no action",
1073
+ "onUpdate": "no action"
1074
+ }
1075
+ },
1076
+ "compositePrimaryKeys": {},
1077
+ "uniqueConstraints": {},
1078
+ "checkConstraints": {}
1079
+ },
1080
+ "flows": {
1081
+ "name": "flows",
1082
+ "columns": {
1083
+ "id": {
1084
+ "name": "id",
1085
+ "type": "text",
1086
+ "primaryKey": true,
1087
+ "notNull": true,
1088
+ "autoincrement": false
1089
+ },
1090
+ "tenant_id": {
1091
+ "name": "tenant_id",
1092
+ "type": "text",
1093
+ "primaryKey": false,
1094
+ "notNull": true,
1095
+ "autoincrement": false
1096
+ },
1097
+ "name": {
1098
+ "name": "name",
1099
+ "type": "text",
1100
+ "primaryKey": false,
1101
+ "notNull": true,
1102
+ "autoincrement": false
1103
+ },
1104
+ "description": {
1105
+ "name": "description",
1106
+ "type": "text",
1107
+ "primaryKey": false,
1108
+ "notNull": false,
1109
+ "autoincrement": false
1110
+ },
1111
+ "priority": {
1112
+ "name": "priority",
1113
+ "type": "integer",
1114
+ "primaryKey": false,
1115
+ "notNull": false,
1116
+ "autoincrement": false,
1117
+ "default": 0
1118
+ },
1119
+ "trigger_type": {
1120
+ "name": "trigger_type",
1121
+ "type": "text",
1122
+ "primaryKey": false,
1123
+ "notNull": true,
1124
+ "autoincrement": false
1125
+ },
1126
+ "trigger_config": {
1127
+ "name": "trigger_config",
1128
+ "type": "text",
1129
+ "primaryKey": false,
1130
+ "notNull": true,
1131
+ "autoincrement": false
1132
+ },
1133
+ "steps": {
1134
+ "name": "steps",
1135
+ "type": "text",
1136
+ "primaryKey": false,
1137
+ "notNull": true,
1138
+ "autoincrement": false
1139
+ },
1140
+ "source": {
1141
+ "name": "source",
1142
+ "type": "text",
1143
+ "primaryKey": false,
1144
+ "notNull": false,
1145
+ "autoincrement": false,
1146
+ "default": "'manual'"
1147
+ },
1148
+ "content_mode": {
1149
+ "name": "content_mode",
1150
+ "type": "text",
1151
+ "primaryKey": false,
1152
+ "notNull": false,
1153
+ "autoincrement": false,
1154
+ "default": "'ai_drafted'"
1155
+ },
1156
+ "status": {
1157
+ "name": "status",
1158
+ "type": "text",
1159
+ "primaryKey": false,
1160
+ "notNull": false,
1161
+ "autoincrement": false,
1162
+ "default": "'draft'"
1163
+ },
1164
+ "approval_mode": {
1165
+ "name": "approval_mode",
1166
+ "type": "text",
1167
+ "primaryKey": false,
1168
+ "notNull": false,
1169
+ "autoincrement": false,
1170
+ "default": "'require'"
1171
+ },
1172
+ "flow_class": {
1173
+ "name": "flow_class",
1174
+ "type": "text",
1175
+ "primaryKey": false,
1176
+ "notNull": true,
1177
+ "autoincrement": false,
1178
+ "default": "'nurture'"
1179
+ },
1180
+ "reentry_policy": {
1181
+ "name": "reentry_policy",
1182
+ "type": "text",
1183
+ "primaryKey": false,
1184
+ "notNull": true,
1185
+ "autoincrement": false,
1186
+ "default": "'cooldown'"
1187
+ },
1188
+ "reentry_cooldown_days": {
1189
+ "name": "reentry_cooldown_days",
1190
+ "type": "integer",
1191
+ "primaryKey": false,
1192
+ "notNull": false,
1193
+ "autoincrement": false,
1194
+ "default": 30
1195
+ },
1196
+ "prompt_source": {
1197
+ "name": "prompt_source",
1198
+ "type": "text",
1199
+ "primaryKey": false,
1200
+ "notNull": false,
1201
+ "autoincrement": false
1202
+ },
1203
+ "compiled_plan": {
1204
+ "name": "compiled_plan",
1205
+ "type": "text",
1206
+ "primaryKey": false,
1207
+ "notNull": false,
1208
+ "autoincrement": false
1209
+ },
1210
+ "compiled_at": {
1211
+ "name": "compiled_at",
1212
+ "type": "integer",
1213
+ "primaryKey": false,
1214
+ "notNull": false,
1215
+ "autoincrement": false
1216
+ },
1217
+ "compile_status": {
1218
+ "name": "compile_status",
1219
+ "type": "text",
1220
+ "primaryKey": false,
1221
+ "notNull": false,
1222
+ "autoincrement": false
1223
+ },
1224
+ "compile_error": {
1225
+ "name": "compile_error",
1226
+ "type": "text",
1227
+ "primaryKey": false,
1228
+ "notNull": false,
1229
+ "autoincrement": false
1230
+ },
1231
+ "topic_id": {
1232
+ "name": "topic_id",
1233
+ "type": "text",
1234
+ "primaryKey": false,
1235
+ "notNull": false,
1236
+ "autoincrement": false
1237
+ },
1238
+ "slug": {
1239
+ "name": "slug",
1240
+ "type": "text",
1241
+ "primaryKey": false,
1242
+ "notNull": false,
1243
+ "autoincrement": false
1244
+ },
1245
+ "created_at": {
1246
+ "name": "created_at",
1247
+ "type": "integer",
1248
+ "primaryKey": false,
1249
+ "notNull": false,
1250
+ "autoincrement": false
1251
+ },
1252
+ "updated_at": {
1253
+ "name": "updated_at",
1254
+ "type": "integer",
1255
+ "primaryKey": false,
1256
+ "notNull": false,
1257
+ "autoincrement": false
1258
+ }
1259
+ },
1260
+ "indexes": {
1261
+ "uq_flows_tenant_slug": {
1262
+ "name": "uq_flows_tenant_slug",
1263
+ "columns": [
1264
+ "tenant_id",
1265
+ "slug"
1266
+ ],
1267
+ "isUnique": true,
1268
+ "where": "slug IS NOT NULL"
1269
+ }
1270
+ },
1271
+ "foreignKeys": {
1272
+ "flows_tenant_id_tenants_id_fk": {
1273
+ "name": "flows_tenant_id_tenants_id_fk",
1274
+ "tableFrom": "flows",
1275
+ "tableTo": "tenants",
1276
+ "columnsFrom": [
1277
+ "tenant_id"
1278
+ ],
1279
+ "columnsTo": [
1280
+ "id"
1281
+ ],
1282
+ "onDelete": "no action",
1283
+ "onUpdate": "no action"
1284
+ },
1285
+ "flows_topic_id_topics_id_fk": {
1286
+ "name": "flows_topic_id_topics_id_fk",
1287
+ "tableFrom": "flows",
1288
+ "tableTo": "topics",
1289
+ "columnsFrom": [
1290
+ "topic_id"
1291
+ ],
1292
+ "columnsTo": [
1293
+ "id"
1294
+ ],
1295
+ "onDelete": "no action",
1296
+ "onUpdate": "no action"
1297
+ }
1298
+ },
1299
+ "compositePrimaryKeys": {},
1300
+ "uniqueConstraints": {},
1301
+ "checkConstraints": {}
1302
+ },
1303
+ "instance_settings": {
1304
+ "name": "instance_settings",
1305
+ "columns": {
1306
+ "key": {
1307
+ "name": "key",
1308
+ "type": "text",
1309
+ "primaryKey": true,
1310
+ "notNull": true,
1311
+ "autoincrement": false
1312
+ },
1313
+ "value": {
1314
+ "name": "value",
1315
+ "type": "text",
1316
+ "primaryKey": false,
1317
+ "notNull": true,
1318
+ "autoincrement": false
1319
+ },
1320
+ "updated_at": {
1321
+ "name": "updated_at",
1322
+ "type": "integer",
1323
+ "primaryKey": false,
1324
+ "notNull": false,
1325
+ "autoincrement": false
1326
+ }
1327
+ },
1328
+ "indexes": {},
1329
+ "foreignKeys": {},
1330
+ "compositePrimaryKeys": {},
1331
+ "uniqueConstraints": {},
1332
+ "checkConstraints": {}
1333
+ },
1334
+ "invites": {
1335
+ "name": "invites",
1336
+ "columns": {
1337
+ "id": {
1338
+ "name": "id",
1339
+ "type": "text",
1340
+ "primaryKey": true,
1341
+ "notNull": true,
1342
+ "autoincrement": false
1343
+ },
1344
+ "tenant_id": {
1345
+ "name": "tenant_id",
1346
+ "type": "text",
1347
+ "primaryKey": false,
1348
+ "notNull": true,
1349
+ "autoincrement": false
1350
+ },
1351
+ "email": {
1352
+ "name": "email",
1353
+ "type": "text",
1354
+ "primaryKey": false,
1355
+ "notNull": true,
1356
+ "autoincrement": false
1357
+ },
1358
+ "role": {
1359
+ "name": "role",
1360
+ "type": "text",
1361
+ "primaryKey": false,
1362
+ "notNull": true,
1363
+ "autoincrement": false,
1364
+ "default": "'member'"
1365
+ },
1366
+ "token_hash": {
1367
+ "name": "token_hash",
1368
+ "type": "text",
1369
+ "primaryKey": false,
1370
+ "notNull": true,
1371
+ "autoincrement": false
1372
+ },
1373
+ "invited_by": {
1374
+ "name": "invited_by",
1375
+ "type": "text",
1376
+ "primaryKey": false,
1377
+ "notNull": true,
1378
+ "autoincrement": false
1379
+ },
1380
+ "expires_at": {
1381
+ "name": "expires_at",
1382
+ "type": "integer",
1383
+ "primaryKey": false,
1384
+ "notNull": true,
1385
+ "autoincrement": false
1386
+ },
1387
+ "accepted_at": {
1388
+ "name": "accepted_at",
1389
+ "type": "integer",
1390
+ "primaryKey": false,
1391
+ "notNull": false,
1392
+ "autoincrement": false
1393
+ },
1394
+ "created_at": {
1395
+ "name": "created_at",
1396
+ "type": "integer",
1397
+ "primaryKey": false,
1398
+ "notNull": false,
1399
+ "autoincrement": false
1400
+ }
1401
+ },
1402
+ "indexes": {
1403
+ "idx_invites_token_hash": {
1404
+ "name": "idx_invites_token_hash",
1405
+ "columns": [
1406
+ "token_hash"
1407
+ ],
1408
+ "isUnique": false
1409
+ },
1410
+ "idx_invites_tenant": {
1411
+ "name": "idx_invites_tenant",
1412
+ "columns": [
1413
+ "tenant_id"
1414
+ ],
1415
+ "isUnique": false
1416
+ }
1417
+ },
1418
+ "foreignKeys": {
1419
+ "invites_tenant_id_tenants_id_fk": {
1420
+ "name": "invites_tenant_id_tenants_id_fk",
1421
+ "tableFrom": "invites",
1422
+ "tableTo": "tenants",
1423
+ "columnsFrom": [
1424
+ "tenant_id"
1425
+ ],
1426
+ "columnsTo": [
1427
+ "id"
1428
+ ],
1429
+ "onDelete": "no action",
1430
+ "onUpdate": "no action"
1431
+ },
1432
+ "invites_invited_by_users_id_fk": {
1433
+ "name": "invites_invited_by_users_id_fk",
1434
+ "tableFrom": "invites",
1435
+ "tableTo": "users",
1436
+ "columnsFrom": [
1437
+ "invited_by"
1438
+ ],
1439
+ "columnsTo": [
1440
+ "id"
1441
+ ],
1442
+ "onDelete": "no action",
1443
+ "onUpdate": "no action"
1444
+ }
1445
+ },
1446
+ "compositePrimaryKeys": {},
1447
+ "uniqueConstraints": {},
1448
+ "checkConstraints": {}
1449
+ },
1450
+ "kb_entries": {
1451
+ "name": "kb_entries",
1452
+ "columns": {
1453
+ "id": {
1454
+ "name": "id",
1455
+ "type": "text",
1456
+ "primaryKey": true,
1457
+ "notNull": true,
1458
+ "autoincrement": false
1459
+ },
1460
+ "tenant_id": {
1461
+ "name": "tenant_id",
1462
+ "type": "text",
1463
+ "primaryKey": false,
1464
+ "notNull": true,
1465
+ "autoincrement": false
1466
+ },
1467
+ "title": {
1468
+ "name": "title",
1469
+ "type": "text",
1470
+ "primaryKey": false,
1471
+ "notNull": true,
1472
+ "autoincrement": false
1473
+ },
1474
+ "content": {
1475
+ "name": "content",
1476
+ "type": "text",
1477
+ "primaryKey": false,
1478
+ "notNull": true,
1479
+ "autoincrement": false
1480
+ },
1481
+ "content_type": {
1482
+ "name": "content_type",
1483
+ "type": "text",
1484
+ "primaryKey": false,
1485
+ "notNull": false,
1486
+ "autoincrement": false,
1487
+ "default": "'markdown'"
1488
+ },
1489
+ "source": {
1490
+ "name": "source",
1491
+ "type": "text",
1492
+ "primaryKey": false,
1493
+ "notNull": false,
1494
+ "autoincrement": false,
1495
+ "default": "'manual'"
1496
+ },
1497
+ "source_url": {
1498
+ "name": "source_url",
1499
+ "type": "text",
1500
+ "primaryKey": false,
1501
+ "notNull": false,
1502
+ "autoincrement": false
1503
+ },
1504
+ "tags": {
1505
+ "name": "tags",
1506
+ "type": "text",
1507
+ "primaryKey": false,
1508
+ "notNull": false,
1509
+ "autoincrement": false
1510
+ },
1511
+ "embedding": {
1512
+ "name": "embedding",
1513
+ "type": "text",
1514
+ "primaryKey": false,
1515
+ "notNull": false,
1516
+ "autoincrement": false
1517
+ },
1518
+ "embedding_status": {
1519
+ "name": "embedding_status",
1520
+ "type": "text",
1521
+ "primaryKey": false,
1522
+ "notNull": false,
1523
+ "autoincrement": false
1524
+ },
1525
+ "embedding_error": {
1526
+ "name": "embedding_error",
1527
+ "type": "text",
1528
+ "primaryKey": false,
1529
+ "notNull": false,
1530
+ "autoincrement": false
1531
+ },
1532
+ "is_active": {
1533
+ "name": "is_active",
1534
+ "type": "integer",
1535
+ "primaryKey": false,
1536
+ "notNull": false,
1537
+ "autoincrement": false,
1538
+ "default": true
1539
+ },
1540
+ "category": {
1541
+ "name": "category",
1542
+ "type": "text",
1543
+ "primaryKey": false,
1544
+ "notNull": false,
1545
+ "autoincrement": false
1546
+ },
1547
+ "external_key": {
1548
+ "name": "external_key",
1549
+ "type": "text",
1550
+ "primaryKey": false,
1551
+ "notNull": false,
1552
+ "autoincrement": false
1553
+ },
1554
+ "data": {
1555
+ "name": "data",
1556
+ "type": "text",
1557
+ "primaryKey": false,
1558
+ "notNull": false,
1559
+ "autoincrement": false
1560
+ },
1561
+ "pinned": {
1562
+ "name": "pinned",
1563
+ "type": "integer",
1564
+ "primaryKey": false,
1565
+ "notNull": true,
1566
+ "autoincrement": false,
1567
+ "default": false
1568
+ },
1569
+ "imported_at": {
1570
+ "name": "imported_at",
1571
+ "type": "integer",
1572
+ "primaryKey": false,
1573
+ "notNull": false,
1574
+ "autoincrement": false
1575
+ },
1576
+ "created_at": {
1577
+ "name": "created_at",
1578
+ "type": "integer",
1579
+ "primaryKey": false,
1580
+ "notNull": false,
1581
+ "autoincrement": false
1582
+ },
1583
+ "updated_at": {
1584
+ "name": "updated_at",
1585
+ "type": "integer",
1586
+ "primaryKey": false,
1587
+ "notNull": false,
1588
+ "autoincrement": false
1589
+ }
1590
+ },
1591
+ "indexes": {
1592
+ "idx_kb_entries_tenant_created": {
1593
+ "name": "idx_kb_entries_tenant_created",
1594
+ "columns": [
1595
+ "tenant_id",
1596
+ "created_at",
1597
+ "id"
1598
+ ],
1599
+ "isUnique": false
1600
+ },
1601
+ "uq_kb_entries_external_key": {
1602
+ "name": "uq_kb_entries_external_key",
1603
+ "columns": [
1604
+ "tenant_id",
1605
+ "external_key"
1606
+ ],
1607
+ "isUnique": true,
1608
+ "where": "external_key IS NOT NULL"
1609
+ },
1610
+ "idx_kb_entries_category": {
1611
+ "name": "idx_kb_entries_category",
1612
+ "columns": [
1613
+ "tenant_id",
1614
+ "category"
1615
+ ],
1616
+ "isUnique": false
1617
+ }
1618
+ },
1619
+ "foreignKeys": {
1620
+ "kb_entries_tenant_id_tenants_id_fk": {
1621
+ "name": "kb_entries_tenant_id_tenants_id_fk",
1622
+ "tableFrom": "kb_entries",
1623
+ "tableTo": "tenants",
1624
+ "columnsFrom": [
1625
+ "tenant_id"
1626
+ ],
1627
+ "columnsTo": [
1628
+ "id"
1629
+ ],
1630
+ "onDelete": "no action",
1631
+ "onUpdate": "no action"
1632
+ }
1633
+ },
1634
+ "compositePrimaryKeys": {},
1635
+ "uniqueConstraints": {},
1636
+ "checkConstraints": {}
1637
+ },
1638
+ "lifecycle_messages": {
1639
+ "name": "lifecycle_messages",
1640
+ "columns": {
1641
+ "id": {
1642
+ "name": "id",
1643
+ "type": "text",
1644
+ "primaryKey": true,
1645
+ "notNull": true,
1646
+ "autoincrement": false
1647
+ },
1648
+ "tenant_id": {
1649
+ "name": "tenant_id",
1650
+ "type": "text",
1651
+ "primaryKey": false,
1652
+ "notNull": true,
1653
+ "autoincrement": false
1654
+ },
1655
+ "contact_id": {
1656
+ "name": "contact_id",
1657
+ "type": "text",
1658
+ "primaryKey": false,
1659
+ "notNull": true,
1660
+ "autoincrement": false
1661
+ },
1662
+ "flow_id": {
1663
+ "name": "flow_id",
1664
+ "type": "text",
1665
+ "primaryKey": false,
1666
+ "notNull": true,
1667
+ "autoincrement": false
1668
+ },
1669
+ "membership_id": {
1670
+ "name": "membership_id",
1671
+ "type": "text",
1672
+ "primaryKey": false,
1673
+ "notNull": true,
1674
+ "autoincrement": false
1675
+ },
1676
+ "flow_step_order": {
1677
+ "name": "flow_step_order",
1678
+ "type": "integer",
1679
+ "primaryKey": false,
1680
+ "notNull": false,
1681
+ "autoincrement": false
1682
+ },
1683
+ "status": {
1684
+ "name": "status",
1685
+ "type": "text",
1686
+ "primaryKey": false,
1687
+ "notNull": true,
1688
+ "autoincrement": false
1689
+ },
1690
+ "feedback": {
1691
+ "name": "feedback",
1692
+ "type": "text",
1693
+ "primaryKey": false,
1694
+ "notNull": false,
1695
+ "autoincrement": false
1696
+ },
1697
+ "subject": {
1698
+ "name": "subject",
1699
+ "type": "text",
1700
+ "primaryKey": false,
1701
+ "notNull": false,
1702
+ "autoincrement": false
1703
+ },
1704
+ "body_html": {
1705
+ "name": "body_html",
1706
+ "type": "text",
1707
+ "primaryKey": false,
1708
+ "notNull": false,
1709
+ "autoincrement": false
1710
+ },
1711
+ "body_text": {
1712
+ "name": "body_text",
1713
+ "type": "text",
1714
+ "primaryKey": false,
1715
+ "notNull": false,
1716
+ "autoincrement": false
1717
+ },
1718
+ "brain_reasoning": {
1719
+ "name": "brain_reasoning",
1720
+ "type": "text",
1721
+ "primaryKey": false,
1722
+ "notNull": false,
1723
+ "autoincrement": false
1724
+ },
1725
+ "brain_action_type": {
1726
+ "name": "brain_action_type",
1727
+ "type": "text",
1728
+ "primaryKey": false,
1729
+ "notNull": false,
1730
+ "autoincrement": false
1731
+ },
1732
+ "scheduled_send_at": {
1733
+ "name": "scheduled_send_at",
1734
+ "type": "integer",
1735
+ "primaryKey": false,
1736
+ "notNull": false,
1737
+ "autoincrement": false
1738
+ },
1739
+ "approved_at": {
1740
+ "name": "approved_at",
1741
+ "type": "integer",
1742
+ "primaryKey": false,
1743
+ "notNull": false,
1744
+ "autoincrement": false
1745
+ },
1746
+ "sent_at": {
1747
+ "name": "sent_at",
1748
+ "type": "integer",
1749
+ "primaryKey": false,
1750
+ "notNull": false,
1751
+ "autoincrement": false
1752
+ },
1753
+ "retry_count": {
1754
+ "name": "retry_count",
1755
+ "type": "integer",
1756
+ "primaryKey": false,
1757
+ "notNull": false,
1758
+ "autoincrement": false,
1759
+ "default": 0
1760
+ },
1761
+ "provider_message_id": {
1762
+ "name": "provider_message_id",
1763
+ "type": "text",
1764
+ "primaryKey": false,
1765
+ "notNull": false,
1766
+ "autoincrement": false
1767
+ },
1768
+ "recipient_address": {
1769
+ "name": "recipient_address",
1770
+ "type": "text",
1771
+ "primaryKey": false,
1772
+ "notNull": false,
1773
+ "autoincrement": false
1774
+ },
1775
+ "topic_id": {
1776
+ "name": "topic_id",
1777
+ "type": "text",
1778
+ "primaryKey": false,
1779
+ "notNull": false,
1780
+ "autoincrement": false
1781
+ },
1782
+ "transport_id": {
1783
+ "name": "transport_id",
1784
+ "type": "text",
1785
+ "primaryKey": false,
1786
+ "notNull": false,
1787
+ "autoincrement": false
1788
+ },
1789
+ "status_reason": {
1790
+ "name": "status_reason",
1791
+ "type": "text",
1792
+ "primaryKey": false,
1793
+ "notNull": false,
1794
+ "autoincrement": false
1795
+ },
1796
+ "approved_by": {
1797
+ "name": "approved_by",
1798
+ "type": "text",
1799
+ "primaryKey": false,
1800
+ "notNull": false,
1801
+ "autoincrement": false
1802
+ },
1803
+ "rejected_by": {
1804
+ "name": "rejected_by",
1805
+ "type": "text",
1806
+ "primaryKey": false,
1807
+ "notNull": false,
1808
+ "autoincrement": false
1809
+ },
1810
+ "edited_by": {
1811
+ "name": "edited_by",
1812
+ "type": "text",
1813
+ "primaryKey": false,
1814
+ "notNull": false,
1815
+ "autoincrement": false
1816
+ },
1817
+ "edited_at": {
1818
+ "name": "edited_at",
1819
+ "type": "integer",
1820
+ "primaryKey": false,
1821
+ "notNull": false,
1822
+ "autoincrement": false
1823
+ },
1824
+ "original_subject": {
1825
+ "name": "original_subject",
1826
+ "type": "text",
1827
+ "primaryKey": false,
1828
+ "notNull": false,
1829
+ "autoincrement": false
1830
+ },
1831
+ "original_body_html": {
1832
+ "name": "original_body_html",
1833
+ "type": "text",
1834
+ "primaryKey": false,
1835
+ "notNull": false,
1836
+ "autoincrement": false
1837
+ },
1838
+ "original_body_text": {
1839
+ "name": "original_body_text",
1840
+ "type": "text",
1841
+ "primaryKey": false,
1842
+ "notNull": false,
1843
+ "autoincrement": false
1844
+ },
1845
+ "forced_action_type": {
1846
+ "name": "forced_action_type",
1847
+ "type": "text",
1848
+ "primaryKey": false,
1849
+ "notNull": false,
1850
+ "autoincrement": false
1851
+ },
1852
+ "kb_entry_id": {
1853
+ "name": "kb_entry_id",
1854
+ "type": "text",
1855
+ "primaryKey": false,
1856
+ "notNull": false,
1857
+ "autoincrement": false
1858
+ },
1859
+ "imported": {
1860
+ "name": "imported",
1861
+ "type": "integer",
1862
+ "primaryKey": false,
1863
+ "notNull": true,
1864
+ "autoincrement": false,
1865
+ "default": false
1866
+ },
1867
+ "import_key": {
1868
+ "name": "import_key",
1869
+ "type": "text",
1870
+ "primaryKey": false,
1871
+ "notNull": false,
1872
+ "autoincrement": false
1873
+ },
1874
+ "expires_at": {
1875
+ "name": "expires_at",
1876
+ "type": "integer",
1877
+ "primaryKey": false,
1878
+ "notNull": false,
1879
+ "autoincrement": false
1880
+ },
1881
+ "context_snapshot": {
1882
+ "name": "context_snapshot",
1883
+ "type": "text",
1884
+ "primaryKey": false,
1885
+ "notNull": false,
1886
+ "autoincrement": false
1887
+ },
1888
+ "choose_decision": {
1889
+ "name": "choose_decision",
1890
+ "type": "text",
1891
+ "primaryKey": false,
1892
+ "notNull": false,
1893
+ "autoincrement": false
1894
+ },
1895
+ "opening_line": {
1896
+ "name": "opening_line",
1897
+ "type": "text",
1898
+ "primaryKey": false,
1899
+ "notNull": false,
1900
+ "autoincrement": false
1901
+ },
1902
+ "created_at": {
1903
+ "name": "created_at",
1904
+ "type": "integer",
1905
+ "primaryKey": false,
1906
+ "notNull": false,
1907
+ "autoincrement": false
1908
+ },
1909
+ "updated_at": {
1910
+ "name": "updated_at",
1911
+ "type": "integer",
1912
+ "primaryKey": false,
1913
+ "notNull": false,
1914
+ "autoincrement": false
1915
+ }
1916
+ },
1917
+ "indexes": {
1918
+ "idx_messages_drain": {
1919
+ "name": "idx_messages_drain",
1920
+ "columns": [
1921
+ "tenant_id",
1922
+ "status",
1923
+ "scheduled_send_at"
1924
+ ],
1925
+ "isUnique": false,
1926
+ "where": "status IN ('approved', 'sending')"
1927
+ },
1928
+ "idx_messages_contact": {
1929
+ "name": "idx_messages_contact",
1930
+ "columns": [
1931
+ "contact_id",
1932
+ "status",
1933
+ "created_at"
1934
+ ],
1935
+ "isUnique": false
1936
+ },
1937
+ "idx_messages_contact_sent": {
1938
+ "name": "idx_messages_contact_sent",
1939
+ "columns": [
1940
+ "contact_id",
1941
+ "sent_at"
1942
+ ],
1943
+ "isUnique": false,
1944
+ "where": "status IN ('sending', 'sent')"
1945
+ },
1946
+ "uq_messages_membership_step": {
1947
+ "name": "uq_messages_membership_step",
1948
+ "columns": [
1949
+ "membership_id",
1950
+ "flow_step_order"
1951
+ ],
1952
+ "isUnique": true
1953
+ },
1954
+ "idx_messages_generation": {
1955
+ "name": "idx_messages_generation",
1956
+ "columns": [
1957
+ "tenant_id",
1958
+ "status",
1959
+ "created_at"
1960
+ ],
1961
+ "isUnique": false,
1962
+ "where": "status IN ('pending_generation', 'generating')"
1963
+ },
1964
+ "idx_messages_provider_id": {
1965
+ "name": "idx_messages_provider_id",
1966
+ "columns": [
1967
+ "provider_message_id"
1968
+ ],
1969
+ "isUnique": false,
1970
+ "where": "provider_message_id IS NOT NULL"
1971
+ },
1972
+ "idx_messages_tenant_sent": {
1973
+ "name": "idx_messages_tenant_sent",
1974
+ "columns": [
1975
+ "tenant_id",
1976
+ "sent_at"
1977
+ ],
1978
+ "isUnique": false,
1979
+ "where": "sent_at IS NOT NULL"
1980
+ },
1981
+ "uq_messages_import_key": {
1982
+ "name": "uq_messages_import_key",
1983
+ "columns": [
1984
+ "tenant_id",
1985
+ "import_key"
1986
+ ],
1987
+ "isUnique": true,
1988
+ "where": "import_key IS NOT NULL"
1989
+ },
1990
+ "idx_messages_kb_entry": {
1991
+ "name": "idx_messages_kb_entry",
1992
+ "columns": [
1993
+ "tenant_id",
1994
+ "contact_id",
1995
+ "kb_entry_id"
1996
+ ],
1997
+ "isUnique": false,
1998
+ "where": "kb_entry_id IS NOT NULL"
1999
+ },
2000
+ "idx_messages_expires": {
2001
+ "name": "idx_messages_expires",
2002
+ "columns": [
2003
+ "tenant_id",
2004
+ "expires_at"
2005
+ ],
2006
+ "isUnique": false,
2007
+ "where": "expires_at IS NOT NULL"
2008
+ }
2009
+ },
2010
+ "foreignKeys": {
2011
+ "lifecycle_messages_tenant_id_tenants_id_fk": {
2012
+ "name": "lifecycle_messages_tenant_id_tenants_id_fk",
2013
+ "tableFrom": "lifecycle_messages",
2014
+ "tableTo": "tenants",
2015
+ "columnsFrom": [
2016
+ "tenant_id"
2017
+ ],
2018
+ "columnsTo": [
2019
+ "id"
2020
+ ],
2021
+ "onDelete": "no action",
2022
+ "onUpdate": "no action"
2023
+ },
2024
+ "lifecycle_messages_contact_id_contacts_id_fk": {
2025
+ "name": "lifecycle_messages_contact_id_contacts_id_fk",
2026
+ "tableFrom": "lifecycle_messages",
2027
+ "tableTo": "contacts",
2028
+ "columnsFrom": [
2029
+ "contact_id"
2030
+ ],
2031
+ "columnsTo": [
2032
+ "id"
2033
+ ],
2034
+ "onDelete": "no action",
2035
+ "onUpdate": "no action"
2036
+ },
2037
+ "lifecycle_messages_flow_id_flows_id_fk": {
2038
+ "name": "lifecycle_messages_flow_id_flows_id_fk",
2039
+ "tableFrom": "lifecycle_messages",
2040
+ "tableTo": "flows",
2041
+ "columnsFrom": [
2042
+ "flow_id"
2043
+ ],
2044
+ "columnsTo": [
2045
+ "id"
2046
+ ],
2047
+ "onDelete": "no action",
2048
+ "onUpdate": "no action"
2049
+ },
2050
+ "lifecycle_messages_membership_id_flow_memberships_id_fk": {
2051
+ "name": "lifecycle_messages_membership_id_flow_memberships_id_fk",
2052
+ "tableFrom": "lifecycle_messages",
2053
+ "tableTo": "flow_memberships",
2054
+ "columnsFrom": [
2055
+ "membership_id"
2056
+ ],
2057
+ "columnsTo": [
2058
+ "id"
2059
+ ],
2060
+ "onDelete": "no action",
2061
+ "onUpdate": "no action"
2062
+ }
2063
+ },
2064
+ "compositePrimaryKeys": {},
2065
+ "uniqueConstraints": {},
2066
+ "checkConstraints": {}
2067
+ },
2068
+ "lifecycle_transitions": {
2069
+ "name": "lifecycle_transitions",
2070
+ "columns": {
2071
+ "id": {
2072
+ "name": "id",
2073
+ "type": "text",
2074
+ "primaryKey": true,
2075
+ "notNull": true,
2076
+ "autoincrement": false
2077
+ },
2078
+ "tenant_id": {
2079
+ "name": "tenant_id",
2080
+ "type": "text",
2081
+ "primaryKey": false,
2082
+ "notNull": true,
2083
+ "autoincrement": false
2084
+ },
2085
+ "contact_id": {
2086
+ "name": "contact_id",
2087
+ "type": "text",
2088
+ "primaryKey": false,
2089
+ "notNull": true,
2090
+ "autoincrement": false
2091
+ },
2092
+ "from_state": {
2093
+ "name": "from_state",
2094
+ "type": "text",
2095
+ "primaryKey": false,
2096
+ "notNull": true,
2097
+ "autoincrement": false
2098
+ },
2099
+ "to_state": {
2100
+ "name": "to_state",
2101
+ "type": "text",
2102
+ "primaryKey": false,
2103
+ "notNull": true,
2104
+ "autoincrement": false
2105
+ },
2106
+ "trigger_event_id": {
2107
+ "name": "trigger_event_id",
2108
+ "type": "text",
2109
+ "primaryKey": false,
2110
+ "notNull": false,
2111
+ "autoincrement": false
2112
+ },
2113
+ "metadata": {
2114
+ "name": "metadata",
2115
+ "type": "text",
2116
+ "primaryKey": false,
2117
+ "notNull": false,
2118
+ "autoincrement": false
2119
+ },
2120
+ "transitioned_at": {
2121
+ "name": "transitioned_at",
2122
+ "type": "integer",
2123
+ "primaryKey": false,
2124
+ "notNull": true,
2125
+ "autoincrement": false
2126
+ }
2127
+ },
2128
+ "indexes": {
2129
+ "idx_transitions_contact": {
2130
+ "name": "idx_transitions_contact",
2131
+ "columns": [
2132
+ "contact_id",
2133
+ "transitioned_at"
2134
+ ],
2135
+ "isUnique": false
2136
+ },
2137
+ "idx_transitions_tenant_time": {
2138
+ "name": "idx_transitions_tenant_time",
2139
+ "columns": [
2140
+ "tenant_id",
2141
+ "transitioned_at"
2142
+ ],
2143
+ "isUnique": false
2144
+ }
2145
+ },
2146
+ "foreignKeys": {
2147
+ "lifecycle_transitions_tenant_id_tenants_id_fk": {
2148
+ "name": "lifecycle_transitions_tenant_id_tenants_id_fk",
2149
+ "tableFrom": "lifecycle_transitions",
2150
+ "tableTo": "tenants",
2151
+ "columnsFrom": [
2152
+ "tenant_id"
2153
+ ],
2154
+ "columnsTo": [
2155
+ "id"
2156
+ ],
2157
+ "onDelete": "no action",
2158
+ "onUpdate": "no action"
2159
+ },
2160
+ "lifecycle_transitions_contact_id_contacts_id_fk": {
2161
+ "name": "lifecycle_transitions_contact_id_contacts_id_fk",
2162
+ "tableFrom": "lifecycle_transitions",
2163
+ "tableTo": "contacts",
2164
+ "columnsFrom": [
2165
+ "contact_id"
2166
+ ],
2167
+ "columnsTo": [
2168
+ "id"
2169
+ ],
2170
+ "onDelete": "no action",
2171
+ "onUpdate": "no action"
2172
+ }
2173
+ },
2174
+ "compositePrimaryKeys": {},
2175
+ "uniqueConstraints": {},
2176
+ "checkConstraints": {}
2177
+ },
2178
+ "llm_configs": {
2179
+ "name": "llm_configs",
2180
+ "columns": {
2181
+ "id": {
2182
+ "name": "id",
2183
+ "type": "text",
2184
+ "primaryKey": true,
2185
+ "notNull": true,
2186
+ "autoincrement": false
2187
+ },
2188
+ "tenant_id": {
2189
+ "name": "tenant_id",
2190
+ "type": "text",
2191
+ "primaryKey": false,
2192
+ "notNull": true,
2193
+ "autoincrement": false
2194
+ },
2195
+ "provider": {
2196
+ "name": "provider",
2197
+ "type": "text",
2198
+ "primaryKey": false,
2199
+ "notNull": true,
2200
+ "autoincrement": false
2201
+ },
2202
+ "config": {
2203
+ "name": "config",
2204
+ "type": "text",
2205
+ "primaryKey": false,
2206
+ "notNull": true,
2207
+ "autoincrement": false
2208
+ },
2209
+ "is_active": {
2210
+ "name": "is_active",
2211
+ "type": "integer",
2212
+ "primaryKey": false,
2213
+ "notNull": false,
2214
+ "autoincrement": false,
2215
+ "default": true
2216
+ },
2217
+ "created_at": {
2218
+ "name": "created_at",
2219
+ "type": "integer",
2220
+ "primaryKey": false,
2221
+ "notNull": false,
2222
+ "autoincrement": false
2223
+ }
2224
+ },
2225
+ "indexes": {},
2226
+ "foreignKeys": {
2227
+ "llm_configs_tenant_id_tenants_id_fk": {
2228
+ "name": "llm_configs_tenant_id_tenants_id_fk",
2229
+ "tableFrom": "llm_configs",
2230
+ "tableTo": "tenants",
2231
+ "columnsFrom": [
2232
+ "tenant_id"
2233
+ ],
2234
+ "columnsTo": [
2235
+ "id"
2236
+ ],
2237
+ "onDelete": "no action",
2238
+ "onUpdate": "no action"
2239
+ }
2240
+ },
2241
+ "compositePrimaryKeys": {},
2242
+ "uniqueConstraints": {},
2243
+ "checkConstraints": {}
2244
+ },
2245
+ "magic_link_tokens": {
2246
+ "name": "magic_link_tokens",
2247
+ "columns": {
2248
+ "id": {
2249
+ "name": "id",
2250
+ "type": "text",
2251
+ "primaryKey": true,
2252
+ "notNull": true,
2253
+ "autoincrement": false
2254
+ },
2255
+ "tenant_id": {
2256
+ "name": "tenant_id",
2257
+ "type": "text",
2258
+ "primaryKey": false,
2259
+ "notNull": true,
2260
+ "autoincrement": false
2261
+ },
2262
+ "user_id": {
2263
+ "name": "user_id",
2264
+ "type": "text",
2265
+ "primaryKey": false,
2266
+ "notNull": true,
2267
+ "autoincrement": false
2268
+ },
2269
+ "token_hash": {
2270
+ "name": "token_hash",
2271
+ "type": "text",
2272
+ "primaryKey": false,
2273
+ "notNull": true,
2274
+ "autoincrement": false
2275
+ },
2276
+ "expires_at": {
2277
+ "name": "expires_at",
2278
+ "type": "integer",
2279
+ "primaryKey": false,
2280
+ "notNull": true,
2281
+ "autoincrement": false
2282
+ },
2283
+ "consumed_at": {
2284
+ "name": "consumed_at",
2285
+ "type": "integer",
2286
+ "primaryKey": false,
2287
+ "notNull": false,
2288
+ "autoincrement": false
2289
+ },
2290
+ "created_at": {
2291
+ "name": "created_at",
2292
+ "type": "integer",
2293
+ "primaryKey": false,
2294
+ "notNull": false,
2295
+ "autoincrement": false
2296
+ }
2297
+ },
2298
+ "indexes": {
2299
+ "idx_magic_link_tokens_hash": {
2300
+ "name": "idx_magic_link_tokens_hash",
2301
+ "columns": [
2302
+ "token_hash"
2303
+ ],
2304
+ "isUnique": false
2305
+ }
2306
+ },
2307
+ "foreignKeys": {
2308
+ "magic_link_tokens_tenant_id_tenants_id_fk": {
2309
+ "name": "magic_link_tokens_tenant_id_tenants_id_fk",
2310
+ "tableFrom": "magic_link_tokens",
2311
+ "tableTo": "tenants",
2312
+ "columnsFrom": [
2313
+ "tenant_id"
2314
+ ],
2315
+ "columnsTo": [
2316
+ "id"
2317
+ ],
2318
+ "onDelete": "no action",
2319
+ "onUpdate": "no action"
2320
+ },
2321
+ "magic_link_tokens_user_id_users_id_fk": {
2322
+ "name": "magic_link_tokens_user_id_users_id_fk",
2323
+ "tableFrom": "magic_link_tokens",
2324
+ "tableTo": "users",
2325
+ "columnsFrom": [
2326
+ "user_id"
2327
+ ],
2328
+ "columnsTo": [
2329
+ "id"
2330
+ ],
2331
+ "onDelete": "cascade",
2332
+ "onUpdate": "no action"
2333
+ }
2334
+ },
2335
+ "compositePrimaryKeys": {},
2336
+ "uniqueConstraints": {},
2337
+ "checkConstraints": {}
2338
+ },
2339
+ "memberships": {
2340
+ "name": "memberships",
2341
+ "columns": {
2342
+ "user_id": {
2343
+ "name": "user_id",
2344
+ "type": "text",
2345
+ "primaryKey": false,
2346
+ "notNull": true,
2347
+ "autoincrement": false
2348
+ },
2349
+ "tenant_id": {
2350
+ "name": "tenant_id",
2351
+ "type": "text",
2352
+ "primaryKey": false,
2353
+ "notNull": true,
2354
+ "autoincrement": false
2355
+ },
2356
+ "role": {
2357
+ "name": "role",
2358
+ "type": "text",
2359
+ "primaryKey": false,
2360
+ "notNull": true,
2361
+ "autoincrement": false
2362
+ },
2363
+ "created_at": {
2364
+ "name": "created_at",
2365
+ "type": "integer",
2366
+ "primaryKey": false,
2367
+ "notNull": false,
2368
+ "autoincrement": false
2369
+ }
2370
+ },
2371
+ "indexes": {
2372
+ "idx_memberships_tenant": {
2373
+ "name": "idx_memberships_tenant",
2374
+ "columns": [
2375
+ "tenant_id"
2376
+ ],
2377
+ "isUnique": false
2378
+ }
2379
+ },
2380
+ "foreignKeys": {
2381
+ "memberships_user_id_users_id_fk": {
2382
+ "name": "memberships_user_id_users_id_fk",
2383
+ "tableFrom": "memberships",
2384
+ "tableTo": "users",
2385
+ "columnsFrom": [
2386
+ "user_id"
2387
+ ],
2388
+ "columnsTo": [
2389
+ "id"
2390
+ ],
2391
+ "onDelete": "cascade",
2392
+ "onUpdate": "no action"
2393
+ },
2394
+ "memberships_tenant_id_tenants_id_fk": {
2395
+ "name": "memberships_tenant_id_tenants_id_fk",
2396
+ "tableFrom": "memberships",
2397
+ "tableTo": "tenants",
2398
+ "columnsFrom": [
2399
+ "tenant_id"
2400
+ ],
2401
+ "columnsTo": [
2402
+ "id"
2403
+ ],
2404
+ "onDelete": "no action",
2405
+ "onUpdate": "no action"
2406
+ }
2407
+ },
2408
+ "compositePrimaryKeys": {
2409
+ "memberships_pkey": {
2410
+ "columns": [
2411
+ "user_id",
2412
+ "tenant_id"
2413
+ ],
2414
+ "name": "memberships_pkey"
2415
+ }
2416
+ },
2417
+ "uniqueConstraints": {},
2418
+ "checkConstraints": {}
2419
+ },
2420
+ "message_events": {
2421
+ "name": "message_events",
2422
+ "columns": {
2423
+ "id": {
2424
+ "name": "id",
2425
+ "type": "text",
2426
+ "primaryKey": true,
2427
+ "notNull": true,
2428
+ "autoincrement": false
2429
+ },
2430
+ "tenant_id": {
2431
+ "name": "tenant_id",
2432
+ "type": "text",
2433
+ "primaryKey": false,
2434
+ "notNull": true,
2435
+ "autoincrement": false
2436
+ },
2437
+ "message_id": {
2438
+ "name": "message_id",
2439
+ "type": "text",
2440
+ "primaryKey": false,
2441
+ "notNull": true,
2442
+ "autoincrement": false
2443
+ },
2444
+ "event_type": {
2445
+ "name": "event_type",
2446
+ "type": "text",
2447
+ "primaryKey": false,
2448
+ "notNull": true,
2449
+ "autoincrement": false
2450
+ },
2451
+ "occurred_at": {
2452
+ "name": "occurred_at",
2453
+ "type": "integer",
2454
+ "primaryKey": false,
2455
+ "notNull": true,
2456
+ "autoincrement": false
2457
+ },
2458
+ "provider_event_id": {
2459
+ "name": "provider_event_id",
2460
+ "type": "text",
2461
+ "primaryKey": false,
2462
+ "notNull": false,
2463
+ "autoincrement": false
2464
+ },
2465
+ "metadata": {
2466
+ "name": "metadata",
2467
+ "type": "text",
2468
+ "primaryKey": false,
2469
+ "notNull": false,
2470
+ "autoincrement": false
2471
+ },
2472
+ "created_at": {
2473
+ "name": "created_at",
2474
+ "type": "integer",
2475
+ "primaryKey": false,
2476
+ "notNull": false,
2477
+ "autoincrement": false
2478
+ }
2479
+ },
2480
+ "indexes": {
2481
+ "idx_message_events_message": {
2482
+ "name": "idx_message_events_message",
2483
+ "columns": [
2484
+ "message_id",
2485
+ "occurred_at"
2486
+ ],
2487
+ "isUnique": false
2488
+ },
2489
+ "idx_message_events_tenant_type_day": {
2490
+ "name": "idx_message_events_tenant_type_day",
2491
+ "columns": [
2492
+ "tenant_id",
2493
+ "event_type",
2494
+ "occurred_at"
2495
+ ],
2496
+ "isUnique": false
2497
+ },
2498
+ "uq_message_events_provider_dedup": {
2499
+ "name": "uq_message_events_provider_dedup",
2500
+ "columns": [
2501
+ "tenant_id",
2502
+ "provider_event_id"
2503
+ ],
2504
+ "isUnique": true,
2505
+ "where": "provider_event_id IS NOT NULL"
2506
+ }
2507
+ },
2508
+ "foreignKeys": {
2509
+ "message_events_tenant_id_tenants_id_fk": {
2510
+ "name": "message_events_tenant_id_tenants_id_fk",
2511
+ "tableFrom": "message_events",
2512
+ "tableTo": "tenants",
2513
+ "columnsFrom": [
2514
+ "tenant_id"
2515
+ ],
2516
+ "columnsTo": [
2517
+ "id"
2518
+ ],
2519
+ "onDelete": "no action",
2520
+ "onUpdate": "no action"
2521
+ },
2522
+ "message_events_message_id_lifecycle_messages_id_fk": {
2523
+ "name": "message_events_message_id_lifecycle_messages_id_fk",
2524
+ "tableFrom": "message_events",
2525
+ "tableTo": "lifecycle_messages",
2526
+ "columnsFrom": [
2527
+ "message_id"
2528
+ ],
2529
+ "columnsTo": [
2530
+ "id"
2531
+ ],
2532
+ "onDelete": "no action",
2533
+ "onUpdate": "no action"
2534
+ }
2535
+ },
2536
+ "compositePrimaryKeys": {},
2537
+ "uniqueConstraints": {},
2538
+ "checkConstraints": {}
2539
+ },
2540
+ "ops_alerts": {
2541
+ "name": "ops_alerts",
2542
+ "columns": {
2543
+ "fingerprint": {
2544
+ "name": "fingerprint",
2545
+ "type": "text",
2546
+ "primaryKey": true,
2547
+ "notNull": true,
2548
+ "autoincrement": false
2549
+ },
2550
+ "kind": {
2551
+ "name": "kind",
2552
+ "type": "text",
2553
+ "primaryKey": false,
2554
+ "notNull": true,
2555
+ "autoincrement": false
2556
+ },
2557
+ "tenant_id": {
2558
+ "name": "tenant_id",
2559
+ "type": "text",
2560
+ "primaryKey": false,
2561
+ "notNull": false,
2562
+ "autoincrement": false
2563
+ },
2564
+ "severity": {
2565
+ "name": "severity",
2566
+ "type": "text",
2567
+ "primaryKey": false,
2568
+ "notNull": true,
2569
+ "autoincrement": false
2570
+ },
2571
+ "message": {
2572
+ "name": "message",
2573
+ "type": "text",
2574
+ "primaryKey": false,
2575
+ "notNull": true,
2576
+ "autoincrement": false
2577
+ },
2578
+ "first_at": {
2579
+ "name": "first_at",
2580
+ "type": "integer",
2581
+ "primaryKey": false,
2582
+ "notNull": true,
2583
+ "autoincrement": false
2584
+ },
2585
+ "last_at": {
2586
+ "name": "last_at",
2587
+ "type": "integer",
2588
+ "primaryKey": false,
2589
+ "notNull": true,
2590
+ "autoincrement": false
2591
+ },
2592
+ "count": {
2593
+ "name": "count",
2594
+ "type": "integer",
2595
+ "primaryKey": false,
2596
+ "notNull": true,
2597
+ "autoincrement": false,
2598
+ "default": 1
2599
+ },
2600
+ "last_notified_at": {
2601
+ "name": "last_notified_at",
2602
+ "type": "integer",
2603
+ "primaryKey": false,
2604
+ "notNull": false,
2605
+ "autoincrement": false
2606
+ },
2607
+ "notified_count": {
2608
+ "name": "notified_count",
2609
+ "type": "integer",
2610
+ "primaryKey": false,
2611
+ "notNull": true,
2612
+ "autoincrement": false,
2613
+ "default": 0
2614
+ },
2615
+ "status": {
2616
+ "name": "status",
2617
+ "type": "text",
2618
+ "primaryKey": false,
2619
+ "notNull": true,
2620
+ "autoincrement": false,
2621
+ "default": "'open'"
2622
+ },
2623
+ "muted_until": {
2624
+ "name": "muted_until",
2625
+ "type": "integer",
2626
+ "primaryKey": false,
2627
+ "notNull": false,
2628
+ "autoincrement": false
2629
+ }
2630
+ },
2631
+ "indexes": {},
2632
+ "foreignKeys": {},
2633
+ "compositePrimaryKeys": {},
2634
+ "uniqueConstraints": {},
2635
+ "checkConstraints": {}
2636
+ },
2637
+ "ops_events": {
2638
+ "name": "ops_events",
2639
+ "columns": {
2640
+ "id": {
2641
+ "name": "id",
2642
+ "type": "text",
2643
+ "primaryKey": true,
2644
+ "notNull": true,
2645
+ "autoincrement": false
2646
+ },
2647
+ "at": {
2648
+ "name": "at",
2649
+ "type": "integer",
2650
+ "primaryKey": false,
2651
+ "notNull": true,
2652
+ "autoincrement": false
2653
+ },
2654
+ "tenant_id": {
2655
+ "name": "tenant_id",
2656
+ "type": "text",
2657
+ "primaryKey": false,
2658
+ "notNull": false,
2659
+ "autoincrement": false
2660
+ },
2661
+ "kind": {
2662
+ "name": "kind",
2663
+ "type": "text",
2664
+ "primaryKey": false,
2665
+ "notNull": true,
2666
+ "autoincrement": false
2667
+ },
2668
+ "severity": {
2669
+ "name": "severity",
2670
+ "type": "text",
2671
+ "primaryKey": false,
2672
+ "notNull": true,
2673
+ "autoincrement": false
2674
+ },
2675
+ "fingerprint": {
2676
+ "name": "fingerprint",
2677
+ "type": "text",
2678
+ "primaryKey": false,
2679
+ "notNull": true,
2680
+ "autoincrement": false
2681
+ },
2682
+ "message": {
2683
+ "name": "message",
2684
+ "type": "text",
2685
+ "primaryKey": false,
2686
+ "notNull": true,
2687
+ "autoincrement": false
2688
+ },
2689
+ "context": {
2690
+ "name": "context",
2691
+ "type": "text",
2692
+ "primaryKey": false,
2693
+ "notNull": false,
2694
+ "autoincrement": false
2695
+ }
2696
+ },
2697
+ "indexes": {
2698
+ "idx_ops_events_fingerprint_at": {
2699
+ "name": "idx_ops_events_fingerprint_at",
2700
+ "columns": [
2701
+ "fingerprint",
2702
+ "at"
2703
+ ],
2704
+ "isUnique": false
2705
+ },
2706
+ "idx_ops_events_at": {
2707
+ "name": "idx_ops_events_at",
2708
+ "columns": [
2709
+ "at"
2710
+ ],
2711
+ "isUnique": false
2712
+ }
2713
+ },
2714
+ "foreignKeys": {},
2715
+ "compositePrimaryKeys": {},
2716
+ "uniqueConstraints": {},
2717
+ "checkConstraints": {}
2718
+ },
2719
+ "retention_grid_snapshots": {
2720
+ "name": "retention_grid_snapshots",
2721
+ "columns": {
2722
+ "tenant_id": {
2723
+ "name": "tenant_id",
2724
+ "type": "text",
2725
+ "primaryKey": false,
2726
+ "notNull": true,
2727
+ "autoincrement": false
2728
+ },
2729
+ "snapshot_date": {
2730
+ "name": "snapshot_date",
2731
+ "type": "text",
2732
+ "primaryKey": false,
2733
+ "notNull": true,
2734
+ "autoincrement": false
2735
+ },
2736
+ "tenure_bucket": {
2737
+ "name": "tenure_bucket",
2738
+ "type": "text",
2739
+ "primaryKey": false,
2740
+ "notNull": true,
2741
+ "autoincrement": false
2742
+ },
2743
+ "recency_bucket": {
2744
+ "name": "recency_bucket",
2745
+ "type": "text",
2746
+ "primaryKey": false,
2747
+ "notNull": true,
2748
+ "autoincrement": false
2749
+ },
2750
+ "contact_count": {
2751
+ "name": "contact_count",
2752
+ "type": "integer",
2753
+ "primaryKey": false,
2754
+ "notNull": true,
2755
+ "autoincrement": false
2756
+ },
2757
+ "paying_count": {
2758
+ "name": "paying_count",
2759
+ "type": "integer",
2760
+ "primaryKey": false,
2761
+ "notNull": true,
2762
+ "autoincrement": false
2763
+ }
2764
+ },
2765
+ "indexes": {},
2766
+ "foreignKeys": {
2767
+ "retention_grid_snapshots_tenant_id_tenants_id_fk": {
2768
+ "name": "retention_grid_snapshots_tenant_id_tenants_id_fk",
2769
+ "tableFrom": "retention_grid_snapshots",
2770
+ "tableTo": "tenants",
2771
+ "columnsFrom": [
2772
+ "tenant_id"
2773
+ ],
2774
+ "columnsTo": [
2775
+ "id"
2776
+ ],
2777
+ "onDelete": "no action",
2778
+ "onUpdate": "no action"
2779
+ }
2780
+ },
2781
+ "compositePrimaryKeys": {
2782
+ "retention_grid_snapshots_tenant_id_snapshot_date_tenure_bucket_recency_bucket_pk": {
2783
+ "columns": [
2784
+ "tenant_id",
2785
+ "snapshot_date",
2786
+ "tenure_bucket",
2787
+ "recency_bucket"
2788
+ ],
2789
+ "name": "retention_grid_snapshots_tenant_id_snapshot_date_tenure_bucket_recency_bucket_pk"
2790
+ }
2791
+ },
2792
+ "uniqueConstraints": {},
2793
+ "checkConstraints": {}
2794
+ },
2795
+ "scan_checkpoints": {
2796
+ "name": "scan_checkpoints",
2797
+ "columns": {
2798
+ "scan_phase": {
2799
+ "name": "scan_phase",
2800
+ "type": "text",
2801
+ "primaryKey": false,
2802
+ "notNull": true,
2803
+ "autoincrement": false
2804
+ },
2805
+ "tenant_id": {
2806
+ "name": "tenant_id",
2807
+ "type": "text",
2808
+ "primaryKey": false,
2809
+ "notNull": true,
2810
+ "autoincrement": false
2811
+ },
2812
+ "last_id": {
2813
+ "name": "last_id",
2814
+ "type": "text",
2815
+ "primaryKey": false,
2816
+ "notNull": true,
2817
+ "autoincrement": false
2818
+ },
2819
+ "started_at": {
2820
+ "name": "started_at",
2821
+ "type": "integer",
2822
+ "primaryKey": false,
2823
+ "notNull": true,
2824
+ "autoincrement": false
2825
+ },
2826
+ "discard_count": {
2827
+ "name": "discard_count",
2828
+ "type": "integer",
2829
+ "primaryKey": false,
2830
+ "notNull": true,
2831
+ "autoincrement": false,
2832
+ "default": 0
2833
+ }
2834
+ },
2835
+ "indexes": {},
2836
+ "foreignKeys": {
2837
+ "scan_checkpoints_tenant_id_tenants_id_fk": {
2838
+ "name": "scan_checkpoints_tenant_id_tenants_id_fk",
2839
+ "tableFrom": "scan_checkpoints",
2840
+ "tableTo": "tenants",
2841
+ "columnsFrom": [
2842
+ "tenant_id"
2843
+ ],
2844
+ "columnsTo": [
2845
+ "id"
2846
+ ],
2847
+ "onDelete": "no action",
2848
+ "onUpdate": "no action"
2849
+ }
2850
+ },
2851
+ "compositePrimaryKeys": {
2852
+ "scan_checkpoints_scan_phase_tenant_id_pk": {
2853
+ "columns": [
2854
+ "scan_phase",
2855
+ "tenant_id"
2856
+ ],
2857
+ "name": "scan_checkpoints_scan_phase_tenant_id_pk"
2858
+ }
2859
+ },
2860
+ "uniqueConstraints": {},
2861
+ "checkConstraints": {}
2862
+ },
2863
+ "sessions": {
2864
+ "name": "sessions",
2865
+ "columns": {
2866
+ "id": {
2867
+ "name": "id",
2868
+ "type": "text",
2869
+ "primaryKey": true,
2870
+ "notNull": true,
2871
+ "autoincrement": false
2872
+ },
2873
+ "tenant_id": {
2874
+ "name": "tenant_id",
2875
+ "type": "text",
2876
+ "primaryKey": false,
2877
+ "notNull": true,
2878
+ "autoincrement": false
2879
+ },
2880
+ "user_id": {
2881
+ "name": "user_id",
2882
+ "type": "text",
2883
+ "primaryKey": false,
2884
+ "notNull": true,
2885
+ "autoincrement": false
2886
+ },
2887
+ "expires_at": {
2888
+ "name": "expires_at",
2889
+ "type": "integer",
2890
+ "primaryKey": false,
2891
+ "notNull": true,
2892
+ "autoincrement": false
2893
+ },
2894
+ "created_at": {
2895
+ "name": "created_at",
2896
+ "type": "integer",
2897
+ "primaryKey": false,
2898
+ "notNull": false,
2899
+ "autoincrement": false
2900
+ }
2901
+ },
2902
+ "indexes": {},
2903
+ "foreignKeys": {
2904
+ "sessions_tenant_id_tenants_id_fk": {
2905
+ "name": "sessions_tenant_id_tenants_id_fk",
2906
+ "tableFrom": "sessions",
2907
+ "tableTo": "tenants",
2908
+ "columnsFrom": [
2909
+ "tenant_id"
2910
+ ],
2911
+ "columnsTo": [
2912
+ "id"
2913
+ ],
2914
+ "onDelete": "no action",
2915
+ "onUpdate": "no action"
2916
+ },
2917
+ "sessions_user_id_users_id_fk": {
2918
+ "name": "sessions_user_id_users_id_fk",
2919
+ "tableFrom": "sessions",
2920
+ "tableTo": "users",
2921
+ "columnsFrom": [
2922
+ "user_id"
2923
+ ],
2924
+ "columnsTo": [
2925
+ "id"
2926
+ ],
2927
+ "onDelete": "cascade",
2928
+ "onUpdate": "no action"
2929
+ }
2930
+ },
2931
+ "compositePrimaryKeys": {},
2932
+ "uniqueConstraints": {},
2933
+ "checkConstraints": {}
2934
+ },
2935
+ "suppressions": {
2936
+ "name": "suppressions",
2937
+ "columns": {
2938
+ "id": {
2939
+ "name": "id",
2940
+ "type": "text",
2941
+ "primaryKey": true,
2942
+ "notNull": true,
2943
+ "autoincrement": false
2944
+ },
2945
+ "tenant_id": {
2946
+ "name": "tenant_id",
2947
+ "type": "text",
2948
+ "primaryKey": false,
2949
+ "notNull": true,
2950
+ "autoincrement": false
2951
+ },
2952
+ "email": {
2953
+ "name": "email",
2954
+ "type": "text",
2955
+ "primaryKey": false,
2956
+ "notNull": true,
2957
+ "autoincrement": false
2958
+ },
2959
+ "reason": {
2960
+ "name": "reason",
2961
+ "type": "text",
2962
+ "primaryKey": false,
2963
+ "notNull": true,
2964
+ "autoincrement": false
2965
+ },
2966
+ "source": {
2967
+ "name": "source",
2968
+ "type": "text",
2969
+ "primaryKey": false,
2970
+ "notNull": false,
2971
+ "autoincrement": false
2972
+ },
2973
+ "created_at": {
2974
+ "name": "created_at",
2975
+ "type": "integer",
2976
+ "primaryKey": false,
2977
+ "notNull": false,
2978
+ "autoincrement": false
2979
+ }
2980
+ },
2981
+ "indexes": {},
2982
+ "foreignKeys": {
2983
+ "suppressions_tenant_id_tenants_id_fk": {
2984
+ "name": "suppressions_tenant_id_tenants_id_fk",
2985
+ "tableFrom": "suppressions",
2986
+ "tableTo": "tenants",
2987
+ "columnsFrom": [
2988
+ "tenant_id"
2989
+ ],
2990
+ "columnsTo": [
2991
+ "id"
2992
+ ],
2993
+ "onDelete": "no action",
2994
+ "onUpdate": "no action"
2995
+ }
2996
+ },
2997
+ "compositePrimaryKeys": {},
2998
+ "uniqueConstraints": {},
2999
+ "checkConstraints": {}
3000
+ },
3001
+ "templates": {
3002
+ "name": "templates",
3003
+ "columns": {
3004
+ "id": {
3005
+ "name": "id",
3006
+ "type": "text",
3007
+ "primaryKey": true,
3008
+ "notNull": true,
3009
+ "autoincrement": false
3010
+ },
3011
+ "tenant_id": {
3012
+ "name": "tenant_id",
3013
+ "type": "text",
3014
+ "primaryKey": false,
3015
+ "notNull": true,
3016
+ "autoincrement": false
3017
+ },
3018
+ "name": {
3019
+ "name": "name",
3020
+ "type": "text",
3021
+ "primaryKey": false,
3022
+ "notNull": true,
3023
+ "autoincrement": false
3024
+ },
3025
+ "slug": {
3026
+ "name": "slug",
3027
+ "type": "text",
3028
+ "primaryKey": false,
3029
+ "notNull": true,
3030
+ "autoincrement": false
3031
+ },
3032
+ "subject": {
3033
+ "name": "subject",
3034
+ "type": "text",
3035
+ "primaryKey": false,
3036
+ "notNull": true,
3037
+ "autoincrement": false
3038
+ },
3039
+ "body_html": {
3040
+ "name": "body_html",
3041
+ "type": "text",
3042
+ "primaryKey": false,
3043
+ "notNull": true,
3044
+ "autoincrement": false
3045
+ },
3046
+ "body_text": {
3047
+ "name": "body_text",
3048
+ "type": "text",
3049
+ "primaryKey": false,
3050
+ "notNull": false,
3051
+ "autoincrement": false
3052
+ },
3053
+ "variables": {
3054
+ "name": "variables",
3055
+ "type": "text",
3056
+ "primaryKey": false,
3057
+ "notNull": false,
3058
+ "autoincrement": false
3059
+ },
3060
+ "category": {
3061
+ "name": "category",
3062
+ "type": "text",
3063
+ "primaryKey": false,
3064
+ "notNull": false,
3065
+ "autoincrement": false
3066
+ },
3067
+ "is_active": {
3068
+ "name": "is_active",
3069
+ "type": "integer",
3070
+ "primaryKey": false,
3071
+ "notNull": false,
3072
+ "autoincrement": false,
3073
+ "default": true
3074
+ },
3075
+ "created_at": {
3076
+ "name": "created_at",
3077
+ "type": "integer",
3078
+ "primaryKey": false,
3079
+ "notNull": false,
3080
+ "autoincrement": false
3081
+ }
3082
+ },
3083
+ "indexes": {
3084
+ "uq_templates_tenant_slug": {
3085
+ "name": "uq_templates_tenant_slug",
3086
+ "columns": [
3087
+ "tenant_id",
3088
+ "slug"
3089
+ ],
3090
+ "isUnique": true
3091
+ }
3092
+ },
3093
+ "foreignKeys": {
3094
+ "templates_tenant_id_tenants_id_fk": {
3095
+ "name": "templates_tenant_id_tenants_id_fk",
3096
+ "tableFrom": "templates",
3097
+ "tableTo": "tenants",
3098
+ "columnsFrom": [
3099
+ "tenant_id"
3100
+ ],
3101
+ "columnsTo": [
3102
+ "id"
3103
+ ],
3104
+ "onDelete": "no action",
3105
+ "onUpdate": "no action"
3106
+ }
3107
+ },
3108
+ "compositePrimaryKeys": {},
3109
+ "uniqueConstraints": {},
3110
+ "checkConstraints": {}
3111
+ },
3112
+ "tenant_daily_usage": {
3113
+ "name": "tenant_daily_usage",
3114
+ "columns": {
3115
+ "tenant_id": {
3116
+ "name": "tenant_id",
3117
+ "type": "text",
3118
+ "primaryKey": false,
3119
+ "notNull": true,
3120
+ "autoincrement": false
3121
+ },
3122
+ "day": {
3123
+ "name": "day",
3124
+ "type": "text",
3125
+ "primaryKey": false,
3126
+ "notNull": true,
3127
+ "autoincrement": false
3128
+ },
3129
+ "llm_tokens": {
3130
+ "name": "llm_tokens",
3131
+ "type": "integer",
3132
+ "primaryKey": false,
3133
+ "notNull": true,
3134
+ "autoincrement": false,
3135
+ "default": 0
3136
+ },
3137
+ "digest_sent_at": {
3138
+ "name": "digest_sent_at",
3139
+ "type": "integer",
3140
+ "primaryKey": false,
3141
+ "notNull": false,
3142
+ "autoincrement": false
3143
+ }
3144
+ },
3145
+ "indexes": {},
3146
+ "foreignKeys": {
3147
+ "tenant_daily_usage_tenant_id_tenants_id_fk": {
3148
+ "name": "tenant_daily_usage_tenant_id_tenants_id_fk",
3149
+ "tableFrom": "tenant_daily_usage",
3150
+ "tableTo": "tenants",
3151
+ "columnsFrom": [
3152
+ "tenant_id"
3153
+ ],
3154
+ "columnsTo": [
3155
+ "id"
3156
+ ],
3157
+ "onDelete": "no action",
3158
+ "onUpdate": "no action"
3159
+ }
3160
+ },
3161
+ "compositePrimaryKeys": {
3162
+ "tenant_daily_usage_pkey": {
3163
+ "columns": [
3164
+ "tenant_id",
3165
+ "day"
3166
+ ],
3167
+ "name": "tenant_daily_usage_pkey"
3168
+ }
3169
+ },
3170
+ "uniqueConstraints": {},
3171
+ "checkConstraints": {}
3172
+ },
3173
+ "tenants": {
3174
+ "name": "tenants",
3175
+ "columns": {
3176
+ "id": {
3177
+ "name": "id",
3178
+ "type": "text",
3179
+ "primaryKey": true,
3180
+ "notNull": true,
3181
+ "autoincrement": false
3182
+ },
3183
+ "name": {
3184
+ "name": "name",
3185
+ "type": "text",
3186
+ "primaryKey": false,
3187
+ "notNull": true,
3188
+ "autoincrement": false
3189
+ },
3190
+ "slug": {
3191
+ "name": "slug",
3192
+ "type": "text",
3193
+ "primaryKey": false,
3194
+ "notNull": true,
3195
+ "autoincrement": false
3196
+ },
3197
+ "plan": {
3198
+ "name": "plan",
3199
+ "type": "text",
3200
+ "primaryKey": false,
3201
+ "notNull": false,
3202
+ "autoincrement": false,
3203
+ "default": "'free'"
3204
+ },
3205
+ "settings": {
3206
+ "name": "settings",
3207
+ "type": "text",
3208
+ "primaryKey": false,
3209
+ "notNull": false,
3210
+ "autoincrement": false
3211
+ },
3212
+ "business_model": {
3213
+ "name": "business_model",
3214
+ "type": "text",
3215
+ "primaryKey": false,
3216
+ "notNull": false,
3217
+ "autoincrement": false
3218
+ },
3219
+ "created_at": {
3220
+ "name": "created_at",
3221
+ "type": "integer",
3222
+ "primaryKey": false,
3223
+ "notNull": false,
3224
+ "autoincrement": false
3225
+ },
3226
+ "archived_at": {
3227
+ "name": "archived_at",
3228
+ "type": "integer",
3229
+ "primaryKey": false,
3230
+ "notNull": false,
3231
+ "autoincrement": false
3232
+ },
3233
+ "public_host": {
3234
+ "name": "public_host",
3235
+ "type": "text",
3236
+ "primaryKey": false,
3237
+ "notNull": false,
3238
+ "autoincrement": false
3239
+ },
3240
+ "locale": {
3241
+ "name": "locale",
3242
+ "type": "text",
3243
+ "primaryKey": false,
3244
+ "notNull": false,
3245
+ "autoincrement": false
3246
+ },
3247
+ "config_version": {
3248
+ "name": "config_version",
3249
+ "type": "integer",
3250
+ "primaryKey": false,
3251
+ "notNull": true,
3252
+ "autoincrement": false,
3253
+ "default": 0
3254
+ }
3255
+ },
3256
+ "indexes": {
3257
+ "tenants_slug_unique": {
3258
+ "name": "tenants_slug_unique",
3259
+ "columns": [
3260
+ "slug"
3261
+ ],
3262
+ "isUnique": true
3263
+ },
3264
+ "uq_tenants_public_host": {
3265
+ "name": "uq_tenants_public_host",
3266
+ "columns": [
3267
+ "public_host"
3268
+ ],
3269
+ "isUnique": true,
3270
+ "where": "public_host IS NOT NULL"
3271
+ }
3272
+ },
3273
+ "foreignKeys": {},
3274
+ "compositePrimaryKeys": {},
3275
+ "uniqueConstraints": {},
3276
+ "checkConstraints": {}
3277
+ },
3278
+ "topics": {
3279
+ "name": "topics",
3280
+ "columns": {
3281
+ "id": {
3282
+ "name": "id",
3283
+ "type": "text",
3284
+ "primaryKey": true,
3285
+ "notNull": true,
3286
+ "autoincrement": false
3287
+ },
3288
+ "tenant_id": {
3289
+ "name": "tenant_id",
3290
+ "type": "text",
3291
+ "primaryKey": false,
3292
+ "notNull": true,
3293
+ "autoincrement": false
3294
+ },
3295
+ "slug": {
3296
+ "name": "slug",
3297
+ "type": "text",
3298
+ "primaryKey": false,
3299
+ "notNull": true,
3300
+ "autoincrement": false
3301
+ },
3302
+ "name": {
3303
+ "name": "name",
3304
+ "type": "text",
3305
+ "primaryKey": false,
3306
+ "notNull": true,
3307
+ "autoincrement": false
3308
+ },
3309
+ "kind": {
3310
+ "name": "kind",
3311
+ "type": "text",
3312
+ "primaryKey": false,
3313
+ "notNull": true,
3314
+ "autoincrement": false
3315
+ },
3316
+ "description": {
3317
+ "name": "description",
3318
+ "type": "text",
3319
+ "primaryKey": false,
3320
+ "notNull": false,
3321
+ "autoincrement": false
3322
+ },
3323
+ "default_subscribed": {
3324
+ "name": "default_subscribed",
3325
+ "type": "integer",
3326
+ "primaryKey": false,
3327
+ "notNull": true,
3328
+ "autoincrement": false,
3329
+ "default": true
3330
+ },
3331
+ "mirror_only": {
3332
+ "name": "mirror_only",
3333
+ "type": "integer",
3334
+ "primaryKey": false,
3335
+ "notNull": true,
3336
+ "autoincrement": false,
3337
+ "default": false
3338
+ },
3339
+ "created_at": {
3340
+ "name": "created_at",
3341
+ "type": "integer",
3342
+ "primaryKey": false,
3343
+ "notNull": false,
3344
+ "autoincrement": false
3345
+ }
3346
+ },
3347
+ "indexes": {
3348
+ "uq_topics_tenant_slug": {
3349
+ "name": "uq_topics_tenant_slug",
3350
+ "columns": [
3351
+ "tenant_id",
3352
+ "slug"
3353
+ ],
3354
+ "isUnique": true
3355
+ }
3356
+ },
3357
+ "foreignKeys": {
3358
+ "topics_tenant_id_tenants_id_fk": {
3359
+ "name": "topics_tenant_id_tenants_id_fk",
3360
+ "tableFrom": "topics",
3361
+ "tableTo": "tenants",
3362
+ "columnsFrom": [
3363
+ "tenant_id"
3364
+ ],
3365
+ "columnsTo": [
3366
+ "id"
3367
+ ],
3368
+ "onDelete": "no action",
3369
+ "onUpdate": "no action"
3370
+ }
3371
+ },
3372
+ "compositePrimaryKeys": {},
3373
+ "uniqueConstraints": {},
3374
+ "checkConstraints": {}
3375
+ },
3376
+ "transport_configs": {
3377
+ "name": "transport_configs",
3378
+ "columns": {
3379
+ "id": {
3380
+ "name": "id",
3381
+ "type": "text",
3382
+ "primaryKey": true,
3383
+ "notNull": true,
3384
+ "autoincrement": false
3385
+ },
3386
+ "tenant_id": {
3387
+ "name": "tenant_id",
3388
+ "type": "text",
3389
+ "primaryKey": false,
3390
+ "notNull": true,
3391
+ "autoincrement": false
3392
+ },
3393
+ "provider": {
3394
+ "name": "provider",
3395
+ "type": "text",
3396
+ "primaryKey": false,
3397
+ "notNull": true,
3398
+ "autoincrement": false
3399
+ },
3400
+ "config": {
3401
+ "name": "config",
3402
+ "type": "text",
3403
+ "primaryKey": false,
3404
+ "notNull": true,
3405
+ "autoincrement": false
3406
+ },
3407
+ "is_active": {
3408
+ "name": "is_active",
3409
+ "type": "integer",
3410
+ "primaryKey": false,
3411
+ "notNull": false,
3412
+ "autoincrement": false,
3413
+ "default": true
3414
+ },
3415
+ "dkim_verified": {
3416
+ "name": "dkim_verified",
3417
+ "type": "integer",
3418
+ "primaryKey": false,
3419
+ "notNull": false,
3420
+ "autoincrement": false,
3421
+ "default": false
3422
+ },
3423
+ "from_email": {
3424
+ "name": "from_email",
3425
+ "type": "text",
3426
+ "primaryKey": false,
3427
+ "notNull": true,
3428
+ "autoincrement": false
3429
+ },
3430
+ "from_name": {
3431
+ "name": "from_name",
3432
+ "type": "text",
3433
+ "primaryKey": false,
3434
+ "notNull": false,
3435
+ "autoincrement": false
3436
+ },
3437
+ "daily_limit": {
3438
+ "name": "daily_limit",
3439
+ "type": "integer",
3440
+ "primaryKey": false,
3441
+ "notNull": false,
3442
+ "autoincrement": false
3443
+ },
3444
+ "kind": {
3445
+ "name": "kind",
3446
+ "type": "text",
3447
+ "primaryKey": false,
3448
+ "notNull": false,
3449
+ "autoincrement": false
3450
+ },
3451
+ "name": {
3452
+ "name": "name",
3453
+ "type": "text",
3454
+ "primaryKey": false,
3455
+ "notNull": false,
3456
+ "autoincrement": false
3457
+ },
3458
+ "reply_to": {
3459
+ "name": "reply_to",
3460
+ "type": "text",
3461
+ "primaryKey": false,
3462
+ "notNull": false,
3463
+ "autoincrement": false
3464
+ },
3465
+ "created_at": {
3466
+ "name": "created_at",
3467
+ "type": "integer",
3468
+ "primaryKey": false,
3469
+ "notNull": false,
3470
+ "autoincrement": false
3471
+ }
3472
+ },
3473
+ "indexes": {},
3474
+ "foreignKeys": {
3475
+ "transport_configs_tenant_id_tenants_id_fk": {
3476
+ "name": "transport_configs_tenant_id_tenants_id_fk",
3477
+ "tableFrom": "transport_configs",
3478
+ "tableTo": "tenants",
3479
+ "columnsFrom": [
3480
+ "tenant_id"
3481
+ ],
3482
+ "columnsTo": [
3483
+ "id"
3484
+ ],
3485
+ "onDelete": "no action",
3486
+ "onUpdate": "no action"
3487
+ }
3488
+ },
3489
+ "compositePrimaryKeys": {},
3490
+ "uniqueConstraints": {},
3491
+ "checkConstraints": {}
3492
+ },
3493
+ "users": {
3494
+ "name": "users",
3495
+ "columns": {
3496
+ "id": {
3497
+ "name": "id",
3498
+ "type": "text",
3499
+ "primaryKey": true,
3500
+ "notNull": true,
3501
+ "autoincrement": false
3502
+ },
3503
+ "tenant_id": {
3504
+ "name": "tenant_id",
3505
+ "type": "text",
3506
+ "primaryKey": false,
3507
+ "notNull": true,
3508
+ "autoincrement": false
3509
+ },
3510
+ "email": {
3511
+ "name": "email",
3512
+ "type": "text",
3513
+ "primaryKey": false,
3514
+ "notNull": true,
3515
+ "autoincrement": false
3516
+ },
3517
+ "name": {
3518
+ "name": "name",
3519
+ "type": "text",
3520
+ "primaryKey": false,
3521
+ "notNull": false,
3522
+ "autoincrement": false
3523
+ },
3524
+ "role": {
3525
+ "name": "role",
3526
+ "type": "text",
3527
+ "primaryKey": false,
3528
+ "notNull": true,
3529
+ "autoincrement": false,
3530
+ "default": "'member'"
3531
+ },
3532
+ "instance_role": {
3533
+ "name": "instance_role",
3534
+ "type": "text",
3535
+ "primaryKey": false,
3536
+ "notNull": false,
3537
+ "autoincrement": false
3538
+ },
3539
+ "last_login_at": {
3540
+ "name": "last_login_at",
3541
+ "type": "integer",
3542
+ "primaryKey": false,
3543
+ "notNull": false,
3544
+ "autoincrement": false
3545
+ },
3546
+ "deactivated_at": {
3547
+ "name": "deactivated_at",
3548
+ "type": "integer",
3549
+ "primaryKey": false,
3550
+ "notNull": false,
3551
+ "autoincrement": false
3552
+ },
3553
+ "pending_email": {
3554
+ "name": "pending_email",
3555
+ "type": "text",
3556
+ "primaryKey": false,
3557
+ "notNull": false,
3558
+ "autoincrement": false
3559
+ },
3560
+ "pending_email_token_hash": {
3561
+ "name": "pending_email_token_hash",
3562
+ "type": "text",
3563
+ "primaryKey": false,
3564
+ "notNull": false,
3565
+ "autoincrement": false
3566
+ },
3567
+ "pending_email_expires_at": {
3568
+ "name": "pending_email_expires_at",
3569
+ "type": "integer",
3570
+ "primaryKey": false,
3571
+ "notNull": false,
3572
+ "autoincrement": false
3573
+ },
3574
+ "created_at": {
3575
+ "name": "created_at",
3576
+ "type": "integer",
3577
+ "primaryKey": false,
3578
+ "notNull": false,
3579
+ "autoincrement": false
3580
+ }
3581
+ },
3582
+ "indexes": {
3583
+ "uq_users_tenant_email": {
3584
+ "name": "uq_users_tenant_email",
3585
+ "columns": [
3586
+ "tenant_id",
3587
+ "email"
3588
+ ],
3589
+ "isUnique": true
3590
+ }
3591
+ },
3592
+ "foreignKeys": {
3593
+ "users_tenant_id_tenants_id_fk": {
3594
+ "name": "users_tenant_id_tenants_id_fk",
3595
+ "tableFrom": "users",
3596
+ "tableTo": "tenants",
3597
+ "columnsFrom": [
3598
+ "tenant_id"
3599
+ ],
3600
+ "columnsTo": [
3601
+ "id"
3602
+ ],
3603
+ "onDelete": "no action",
3604
+ "onUpdate": "no action"
3605
+ }
3606
+ },
3607
+ "compositePrimaryKeys": {},
3608
+ "uniqueConstraints": {},
3609
+ "checkConstraints": {}
3610
+ },
3611
+ "webhook_endpoints": {
3612
+ "name": "webhook_endpoints",
3613
+ "columns": {
3614
+ "id": {
3615
+ "name": "id",
3616
+ "type": "text",
3617
+ "primaryKey": true,
3618
+ "notNull": true,
3619
+ "autoincrement": false
3620
+ },
3621
+ "tenant_id": {
3622
+ "name": "tenant_id",
3623
+ "type": "text",
3624
+ "primaryKey": false,
3625
+ "notNull": true,
3626
+ "autoincrement": false
3627
+ },
3628
+ "slug": {
3629
+ "name": "slug",
3630
+ "type": "text",
3631
+ "primaryKey": false,
3632
+ "notNull": true,
3633
+ "autoincrement": false
3634
+ },
3635
+ "kind": {
3636
+ "name": "kind",
3637
+ "type": "text",
3638
+ "primaryKey": false,
3639
+ "notNull": true,
3640
+ "autoincrement": false,
3641
+ "default": "'webhook'"
3642
+ },
3643
+ "url": {
3644
+ "name": "url",
3645
+ "type": "text",
3646
+ "primaryKey": false,
3647
+ "notNull": true,
3648
+ "autoincrement": false
3649
+ },
3650
+ "secret": {
3651
+ "name": "secret",
3652
+ "type": "text",
3653
+ "primaryKey": false,
3654
+ "notNull": false,
3655
+ "autoincrement": false
3656
+ },
3657
+ "events": {
3658
+ "name": "events",
3659
+ "type": "text",
3660
+ "primaryKey": false,
3661
+ "notNull": true,
3662
+ "autoincrement": false
3663
+ },
3664
+ "config": {
3665
+ "name": "config",
3666
+ "type": "text",
3667
+ "primaryKey": false,
3668
+ "notNull": false,
3669
+ "autoincrement": false
3670
+ },
3671
+ "enabled": {
3672
+ "name": "enabled",
3673
+ "type": "integer",
3674
+ "primaryKey": false,
3675
+ "notNull": true,
3676
+ "autoincrement": false,
3677
+ "default": true
3678
+ },
3679
+ "created_at": {
3680
+ "name": "created_at",
3681
+ "type": "integer",
3682
+ "primaryKey": false,
3683
+ "notNull": false,
3684
+ "autoincrement": false
3685
+ },
3686
+ "updated_at": {
3687
+ "name": "updated_at",
3688
+ "type": "integer",
3689
+ "primaryKey": false,
3690
+ "notNull": false,
3691
+ "autoincrement": false
3692
+ }
3693
+ },
3694
+ "indexes": {
3695
+ "uq_webhook_endpoints_tenant_slug": {
3696
+ "name": "uq_webhook_endpoints_tenant_slug",
3697
+ "columns": [
3698
+ "tenant_id",
3699
+ "slug"
3700
+ ],
3701
+ "isUnique": true
3702
+ }
3703
+ },
3704
+ "foreignKeys": {
3705
+ "webhook_endpoints_tenant_id_tenants_id_fk": {
3706
+ "name": "webhook_endpoints_tenant_id_tenants_id_fk",
3707
+ "tableFrom": "webhook_endpoints",
3708
+ "tableTo": "tenants",
3709
+ "columnsFrom": [
3710
+ "tenant_id"
3711
+ ],
3712
+ "columnsTo": [
3713
+ "id"
3714
+ ],
3715
+ "onDelete": "no action",
3716
+ "onUpdate": "no action"
3717
+ }
3718
+ },
3719
+ "compositePrimaryKeys": {},
3720
+ "uniqueConstraints": {},
3721
+ "checkConstraints": {}
3722
+ },
3723
+ "webhook_outbox": {
3724
+ "name": "webhook_outbox",
3725
+ "columns": {
3726
+ "id": {
3727
+ "name": "id",
3728
+ "type": "text",
3729
+ "primaryKey": true,
3730
+ "notNull": true,
3731
+ "autoincrement": false
3732
+ },
3733
+ "tenant_id": {
3734
+ "name": "tenant_id",
3735
+ "type": "text",
3736
+ "primaryKey": false,
3737
+ "notNull": true,
3738
+ "autoincrement": false
3739
+ },
3740
+ "endpoint_id": {
3741
+ "name": "endpoint_id",
3742
+ "type": "text",
3743
+ "primaryKey": false,
3744
+ "notNull": true,
3745
+ "autoincrement": false
3746
+ },
3747
+ "event": {
3748
+ "name": "event",
3749
+ "type": "text",
3750
+ "primaryKey": false,
3751
+ "notNull": true,
3752
+ "autoincrement": false
3753
+ },
3754
+ "payload": {
3755
+ "name": "payload",
3756
+ "type": "text",
3757
+ "primaryKey": false,
3758
+ "notNull": true,
3759
+ "autoincrement": false
3760
+ },
3761
+ "status": {
3762
+ "name": "status",
3763
+ "type": "text",
3764
+ "primaryKey": false,
3765
+ "notNull": true,
3766
+ "autoincrement": false,
3767
+ "default": "'pending'"
3768
+ },
3769
+ "attempts": {
3770
+ "name": "attempts",
3771
+ "type": "integer",
3772
+ "primaryKey": false,
3773
+ "notNull": true,
3774
+ "autoincrement": false,
3775
+ "default": 0
3776
+ },
3777
+ "next_attempt_at": {
3778
+ "name": "next_attempt_at",
3779
+ "type": "integer",
3780
+ "primaryKey": false,
3781
+ "notNull": true,
3782
+ "autoincrement": false
3783
+ },
3784
+ "last_error": {
3785
+ "name": "last_error",
3786
+ "type": "text",
3787
+ "primaryKey": false,
3788
+ "notNull": false,
3789
+ "autoincrement": false
3790
+ },
3791
+ "dedup_key": {
3792
+ "name": "dedup_key",
3793
+ "type": "text",
3794
+ "primaryKey": false,
3795
+ "notNull": false,
3796
+ "autoincrement": false
3797
+ },
3798
+ "created_at": {
3799
+ "name": "created_at",
3800
+ "type": "integer",
3801
+ "primaryKey": false,
3802
+ "notNull": true,
3803
+ "autoincrement": false
3804
+ },
3805
+ "delivered_at": {
3806
+ "name": "delivered_at",
3807
+ "type": "integer",
3808
+ "primaryKey": false,
3809
+ "notNull": false,
3810
+ "autoincrement": false
3811
+ }
3812
+ },
3813
+ "indexes": {
3814
+ "idx_webhook_outbox_due": {
3815
+ "name": "idx_webhook_outbox_due",
3816
+ "columns": [
3817
+ "tenant_id",
3818
+ "next_attempt_at"
3819
+ ],
3820
+ "isUnique": false,
3821
+ "where": "status = 'pending'"
3822
+ },
3823
+ "idx_webhook_outbox_tenant_event": {
3824
+ "name": "idx_webhook_outbox_tenant_event",
3825
+ "columns": [
3826
+ "tenant_id",
3827
+ "event",
3828
+ "created_at"
3829
+ ],
3830
+ "isUnique": false
3831
+ },
3832
+ "uq_webhook_outbox_dedup": {
3833
+ "name": "uq_webhook_outbox_dedup",
3834
+ "columns": [
3835
+ "tenant_id",
3836
+ "endpoint_id",
3837
+ "dedup_key"
3838
+ ],
3839
+ "isUnique": true,
3840
+ "where": "dedup_key IS NOT NULL"
3841
+ }
3842
+ },
3843
+ "foreignKeys": {
3844
+ "webhook_outbox_tenant_id_tenants_id_fk": {
3845
+ "name": "webhook_outbox_tenant_id_tenants_id_fk",
3846
+ "tableFrom": "webhook_outbox",
3847
+ "tableTo": "tenants",
3848
+ "columnsFrom": [
3849
+ "tenant_id"
3850
+ ],
3851
+ "columnsTo": [
3852
+ "id"
3853
+ ],
3854
+ "onDelete": "no action",
3855
+ "onUpdate": "no action"
3856
+ }
3857
+ },
3858
+ "compositePrimaryKeys": {},
3859
+ "uniqueConstraints": {},
3860
+ "checkConstraints": {}
3861
+ }
3862
+ },
3863
+ "views": {},
3864
+ "enums": {},
3865
+ "_meta": {
3866
+ "schemas": {},
3867
+ "tables": {},
3868
+ "columns": {}
3869
+ },
3870
+ "internal": {
3871
+ "indexes": {}
3872
+ }
3873
+ }