@arcforgelabs/flow 2026.10.21 → 2026.10.23

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 (35) hide show
  1. package/README.md +2 -1
  2. package/VISION.md +40 -9
  3. package/npm-shrinkwrap.json +2 -414
  4. package/package.json +6 -1
  5. package/server/app.js +7 -0
  6. package/server/core/links.js +166 -0
  7. package/server/core/outbox.js +129 -0
  8. package/server/core/queue.js +142 -0
  9. package/server/core/review.js +92 -0
  10. package/server/core/secrets.js +74 -0
  11. package/server/db/migrations/0005_data_spine.sql +99 -0
  12. package/server/db/migrations/0006_prior_links.sql +18 -0
  13. package/server/db/migrations/0007_integration_settings.sql +23 -0
  14. package/server/db/migrations/meta/0005_snapshot.json +2145 -0
  15. package/server/db/migrations/meta/0006_snapshot.json +2306 -0
  16. package/server/db/migrations/meta/0007_snapshot.json +2473 -0
  17. package/server/db/migrations/meta/_journal.json +21 -0
  18. package/server/db/schema.js +187 -1
  19. package/server/import/at-start.js +69 -1
  20. package/server/index.js +28 -8
  21. package/server/integrations/index.js +9 -3
  22. package/server/integrations/port.js +101 -9
  23. package/server/integrations/seazona/index.js +25 -3
  24. package/server/integrations/setup.js +234 -0
  25. package/server/integrations/xero/client.js +13 -0
  26. package/server/integrations/xero/import.js +116 -0
  27. package/server/integrations/xero/index.js +45 -5
  28. package/server/integrations/xero/migrations/0004_xero_mirror.sql +96 -0
  29. package/server/integrations/xero/migrations/meta/_journal.json +7 -0
  30. package/server/integrations/xero/mirror.js +295 -0
  31. package/server/integrations/xero/routes.js +26 -1
  32. package/server/integrations/xero/settings.js +8 -0
  33. package/server/ui/app-page.js +1 -1
  34. package/server/ui/app.js +142 -0
  35. package/server/ui/routes.js +9 -2
@@ -0,0 +1,2473 @@
1
+ {
2
+ "id": "f70e5e44-dc1d-46f3-bde3-8d1315dee698",
3
+ "prevId": "377257f6-6e60-4e6e-acfa-334fd6c6d47d",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.background_jobs": {
8
+ "name": "background_jobs",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "default": "gen_random_uuid()"
17
+ },
18
+ "organisation_id": {
19
+ "name": "organisation_id",
20
+ "type": "uuid",
21
+ "primaryKey": false,
22
+ "notNull": true
23
+ },
24
+ "kind": {
25
+ "name": "kind",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true
29
+ },
30
+ "dedupe_key": {
31
+ "name": "dedupe_key",
32
+ "type": "text",
33
+ "primaryKey": false,
34
+ "notNull": true,
35
+ "default": "''"
36
+ },
37
+ "payload": {
38
+ "name": "payload",
39
+ "type": "jsonb",
40
+ "primaryKey": false,
41
+ "notNull": true,
42
+ "default": "'{}'::jsonb"
43
+ },
44
+ "state": {
45
+ "name": "state",
46
+ "type": "text",
47
+ "primaryKey": false,
48
+ "notNull": true,
49
+ "default": "'queued'"
50
+ },
51
+ "run_after": {
52
+ "name": "run_after",
53
+ "type": "timestamp with time zone",
54
+ "primaryKey": false,
55
+ "notNull": true,
56
+ "default": "now()"
57
+ },
58
+ "attempts": {
59
+ "name": "attempts",
60
+ "type": "integer",
61
+ "primaryKey": false,
62
+ "notNull": true,
63
+ "default": 0
64
+ },
65
+ "max_attempts": {
66
+ "name": "max_attempts",
67
+ "type": "integer",
68
+ "primaryKey": false,
69
+ "notNull": true,
70
+ "default": 8
71
+ },
72
+ "locked_by": {
73
+ "name": "locked_by",
74
+ "type": "text",
75
+ "primaryKey": false,
76
+ "notNull": false
77
+ },
78
+ "locked_until": {
79
+ "name": "locked_until",
80
+ "type": "timestamp with time zone",
81
+ "primaryKey": false,
82
+ "notNull": false
83
+ },
84
+ "result": {
85
+ "name": "result",
86
+ "type": "jsonb",
87
+ "primaryKey": false,
88
+ "notNull": false
89
+ },
90
+ "last_error": {
91
+ "name": "last_error",
92
+ "type": "text",
93
+ "primaryKey": false,
94
+ "notNull": false
95
+ },
96
+ "created_at": {
97
+ "name": "created_at",
98
+ "type": "timestamp with time zone",
99
+ "primaryKey": false,
100
+ "notNull": true,
101
+ "default": "now()"
102
+ },
103
+ "updated_at": {
104
+ "name": "updated_at",
105
+ "type": "timestamp with time zone",
106
+ "primaryKey": false,
107
+ "notNull": true,
108
+ "default": "now()"
109
+ }
110
+ },
111
+ "indexes": {
112
+ "background_jobs_one_open": {
113
+ "name": "background_jobs_one_open",
114
+ "columns": [
115
+ {
116
+ "expression": "organisation_id",
117
+ "isExpression": false,
118
+ "asc": true,
119
+ "nulls": "last"
120
+ },
121
+ {
122
+ "expression": "kind",
123
+ "isExpression": false,
124
+ "asc": true,
125
+ "nulls": "last"
126
+ },
127
+ {
128
+ "expression": "dedupe_key",
129
+ "isExpression": false,
130
+ "asc": true,
131
+ "nulls": "last"
132
+ }
133
+ ],
134
+ "isUnique": true,
135
+ "where": "state in ('queued', 'running')",
136
+ "concurrently": false,
137
+ "method": "btree",
138
+ "with": {}
139
+ },
140
+ "background_jobs_due": {
141
+ "name": "background_jobs_due",
142
+ "columns": [
143
+ {
144
+ "expression": "state",
145
+ "isExpression": false,
146
+ "asc": true,
147
+ "nulls": "last"
148
+ },
149
+ {
150
+ "expression": "run_after",
151
+ "isExpression": false,
152
+ "asc": true,
153
+ "nulls": "last"
154
+ }
155
+ ],
156
+ "isUnique": false,
157
+ "concurrently": false,
158
+ "method": "btree",
159
+ "with": {}
160
+ }
161
+ },
162
+ "foreignKeys": {
163
+ "background_jobs_organisation_id_organisations_id_fk": {
164
+ "name": "background_jobs_organisation_id_organisations_id_fk",
165
+ "tableFrom": "background_jobs",
166
+ "tableTo": "organisations",
167
+ "columnsFrom": [
168
+ "organisation_id"
169
+ ],
170
+ "columnsTo": [
171
+ "id"
172
+ ],
173
+ "onDelete": "no action",
174
+ "onUpdate": "no action"
175
+ }
176
+ },
177
+ "compositePrimaryKeys": {},
178
+ "uniqueConstraints": {},
179
+ "policies": {},
180
+ "checkConstraints": {
181
+ "background_jobs_state_valid": {
182
+ "name": "background_jobs_state_valid",
183
+ "value": "state in ('queued', 'running', 'succeeded', 'failed', 'dead')"
184
+ },
185
+ "background_jobs_attempts_valid": {
186
+ "name": "background_jobs_attempts_valid",
187
+ "value": "\"background_jobs\".\"attempts\" >= 0 and \"background_jobs\".\"max_attempts\" > 0"
188
+ }
189
+ },
190
+ "isRLSEnabled": false
191
+ },
192
+ "public.billing_obligations": {
193
+ "name": "billing_obligations",
194
+ "schema": "",
195
+ "columns": {
196
+ "id": {
197
+ "name": "id",
198
+ "type": "uuid",
199
+ "primaryKey": true,
200
+ "notNull": true,
201
+ "default": "gen_random_uuid()"
202
+ },
203
+ "organisation_id": {
204
+ "name": "organisation_id",
205
+ "type": "uuid",
206
+ "primaryKey": false,
207
+ "notNull": true
208
+ },
209
+ "source_system": {
210
+ "name": "source_system",
211
+ "type": "text",
212
+ "primaryKey": false,
213
+ "notNull": true
214
+ },
215
+ "source_job_ref": {
216
+ "name": "source_job_ref",
217
+ "type": "text",
218
+ "primaryKey": false,
219
+ "notNull": true
220
+ },
221
+ "source_invoice_ref": {
222
+ "name": "source_invoice_ref",
223
+ "type": "text",
224
+ "primaryKey": false,
225
+ "notNull": false
226
+ },
227
+ "case_ref": {
228
+ "name": "case_ref",
229
+ "type": "text",
230
+ "primaryKey": false,
231
+ "notNull": false
232
+ },
233
+ "contact_id": {
234
+ "name": "contact_id",
235
+ "type": "uuid",
236
+ "primaryKey": false,
237
+ "notNull": false
238
+ },
239
+ "practitioner": {
240
+ "name": "practitioner",
241
+ "type": "text",
242
+ "primaryKey": false,
243
+ "notNull": false
244
+ },
245
+ "shipped_on": {
246
+ "name": "shipped_on",
247
+ "type": "date",
248
+ "primaryKey": false,
249
+ "notNull": false
250
+ },
251
+ "lines": {
252
+ "name": "lines",
253
+ "type": "jsonb",
254
+ "primaryKey": false,
255
+ "notNull": true,
256
+ "default": "'[]'::jsonb"
257
+ },
258
+ "line_fingerprint": {
259
+ "name": "line_fingerprint",
260
+ "type": "text",
261
+ "primaryKey": false,
262
+ "notNull": true
263
+ },
264
+ "subtotal_cents": {
265
+ "name": "subtotal_cents",
266
+ "type": "integer",
267
+ "primaryKey": false,
268
+ "notNull": true
269
+ },
270
+ "tax_cents": {
271
+ "name": "tax_cents",
272
+ "type": "integer",
273
+ "primaryKey": false,
274
+ "notNull": true
275
+ },
276
+ "total_cents": {
277
+ "name": "total_cents",
278
+ "type": "integer",
279
+ "primaryKey": false,
280
+ "notNull": true
281
+ },
282
+ "mapping_complete": {
283
+ "name": "mapping_complete",
284
+ "type": "boolean",
285
+ "primaryKey": false,
286
+ "notNull": true
287
+ },
288
+ "source_seen_at": {
289
+ "name": "source_seen_at",
290
+ "type": "timestamp with time zone",
291
+ "primaryKey": false,
292
+ "notNull": true
293
+ },
294
+ "hold_state": {
295
+ "name": "hold_state",
296
+ "type": "text",
297
+ "primaryKey": false,
298
+ "notNull": true,
299
+ "default": "'none'"
300
+ },
301
+ "hold_reason": {
302
+ "name": "hold_reason",
303
+ "type": "text",
304
+ "primaryKey": false,
305
+ "notNull": false
306
+ },
307
+ "invoice_id": {
308
+ "name": "invoice_id",
309
+ "type": "uuid",
310
+ "primaryKey": false,
311
+ "notNull": false
312
+ },
313
+ "accounting_state": {
314
+ "name": "accounting_state",
315
+ "type": "text",
316
+ "primaryKey": false,
317
+ "notNull": true,
318
+ "default": "'unknown'"
319
+ },
320
+ "accounting_ref": {
321
+ "name": "accounting_ref",
322
+ "type": "text",
323
+ "primaryKey": false,
324
+ "notNull": false
325
+ },
326
+ "accounting_url": {
327
+ "name": "accounting_url",
328
+ "type": "text",
329
+ "primaryKey": false,
330
+ "notNull": false
331
+ },
332
+ "accounting_matched_by": {
333
+ "name": "accounting_matched_by",
334
+ "type": "text",
335
+ "primaryKey": false,
336
+ "notNull": false
337
+ },
338
+ "accounting_checked_at": {
339
+ "name": "accounting_checked_at",
340
+ "type": "timestamp with time zone",
341
+ "primaryKey": false,
342
+ "notNull": false
343
+ },
344
+ "paid_cents": {
345
+ "name": "paid_cents",
346
+ "type": "integer",
347
+ "primaryKey": false,
348
+ "notNull": true,
349
+ "default": 0
350
+ },
351
+ "created_at": {
352
+ "name": "created_at",
353
+ "type": "timestamp with time zone",
354
+ "primaryKey": false,
355
+ "notNull": true,
356
+ "default": "now()"
357
+ },
358
+ "updated_at": {
359
+ "name": "updated_at",
360
+ "type": "timestamp with time zone",
361
+ "primaryKey": false,
362
+ "notNull": true,
363
+ "default": "now()"
364
+ }
365
+ },
366
+ "indexes": {},
367
+ "foreignKeys": {
368
+ "billing_obligations_organisation_id_organisations_id_fk": {
369
+ "name": "billing_obligations_organisation_id_organisations_id_fk",
370
+ "tableFrom": "billing_obligations",
371
+ "tableTo": "organisations",
372
+ "columnsFrom": [
373
+ "organisation_id"
374
+ ],
375
+ "columnsTo": [
376
+ "id"
377
+ ],
378
+ "onDelete": "no action",
379
+ "onUpdate": "no action"
380
+ },
381
+ "billing_obligations_contact_same_org": {
382
+ "name": "billing_obligations_contact_same_org",
383
+ "tableFrom": "billing_obligations",
384
+ "tableTo": "contacts",
385
+ "columnsFrom": [
386
+ "organisation_id",
387
+ "contact_id"
388
+ ],
389
+ "columnsTo": [
390
+ "organisation_id",
391
+ "id"
392
+ ],
393
+ "onDelete": "no action",
394
+ "onUpdate": "no action"
395
+ },
396
+ "billing_obligations_invoice_same_org": {
397
+ "name": "billing_obligations_invoice_same_org",
398
+ "tableFrom": "billing_obligations",
399
+ "tableTo": "invoices",
400
+ "columnsFrom": [
401
+ "organisation_id",
402
+ "invoice_id"
403
+ ],
404
+ "columnsTo": [
405
+ "organisation_id",
406
+ "id"
407
+ ],
408
+ "onDelete": "no action",
409
+ "onUpdate": "no action"
410
+ }
411
+ },
412
+ "compositePrimaryKeys": {},
413
+ "uniqueConstraints": {
414
+ "billing_obligations_org_id": {
415
+ "name": "billing_obligations_org_id",
416
+ "nullsNotDistinct": false,
417
+ "columns": [
418
+ "organisation_id",
419
+ "id"
420
+ ]
421
+ },
422
+ "billing_obligations_source_job": {
423
+ "name": "billing_obligations_source_job",
424
+ "nullsNotDistinct": false,
425
+ "columns": [
426
+ "organisation_id",
427
+ "source_system",
428
+ "source_job_ref"
429
+ ]
430
+ },
431
+ "billing_obligations_invoice": {
432
+ "name": "billing_obligations_invoice",
433
+ "nullsNotDistinct": false,
434
+ "columns": [
435
+ "organisation_id",
436
+ "invoice_id"
437
+ ]
438
+ }
439
+ },
440
+ "policies": {},
441
+ "checkConstraints": {
442
+ "billing_obligations_hold_state_valid": {
443
+ "name": "billing_obligations_hold_state_valid",
444
+ "value": "hold_state in ('none', 'held', 'review')"
445
+ },
446
+ "billing_obligations_accounting_state_valid": {
447
+ "name": "billing_obligations_accounting_state_valid",
448
+ "value": "accounting_state in ('unknown', 'not_found', 'drafted', 'authorised', 'part_paid', 'paid', 'voided', 'deleted', 'ambiguous', 'conflict')"
449
+ },
450
+ "billing_obligations_paid_not_negative": {
451
+ "name": "billing_obligations_paid_not_negative",
452
+ "value": "\"billing_obligations\".\"paid_cents\" >= 0"
453
+ }
454
+ },
455
+ "isRLSEnabled": false
456
+ },
457
+ "public.contacts": {
458
+ "name": "contacts",
459
+ "schema": "",
460
+ "columns": {
461
+ "id": {
462
+ "name": "id",
463
+ "type": "uuid",
464
+ "primaryKey": true,
465
+ "notNull": true,
466
+ "default": "gen_random_uuid()"
467
+ },
468
+ "organisation_id": {
469
+ "name": "organisation_id",
470
+ "type": "uuid",
471
+ "primaryKey": false,
472
+ "notNull": true
473
+ },
474
+ "kind": {
475
+ "name": "kind",
476
+ "type": "text",
477
+ "primaryKey": false,
478
+ "notNull": true
479
+ },
480
+ "name": {
481
+ "name": "name",
482
+ "type": "text",
483
+ "primaryKey": false,
484
+ "notNull": true
485
+ },
486
+ "email": {
487
+ "name": "email",
488
+ "type": "text",
489
+ "primaryKey": false,
490
+ "notNull": false
491
+ },
492
+ "created_at": {
493
+ "name": "created_at",
494
+ "type": "timestamp with time zone",
495
+ "primaryKey": false,
496
+ "notNull": true,
497
+ "default": "now()"
498
+ }
499
+ },
500
+ "indexes": {},
501
+ "foreignKeys": {
502
+ "contacts_organisation_id_organisations_id_fk": {
503
+ "name": "contacts_organisation_id_organisations_id_fk",
504
+ "tableFrom": "contacts",
505
+ "tableTo": "organisations",
506
+ "columnsFrom": [
507
+ "organisation_id"
508
+ ],
509
+ "columnsTo": [
510
+ "id"
511
+ ],
512
+ "onDelete": "no action",
513
+ "onUpdate": "no action"
514
+ }
515
+ },
516
+ "compositePrimaryKeys": {},
517
+ "uniqueConstraints": {
518
+ "contacts_org_id": {
519
+ "name": "contacts_org_id",
520
+ "nullsNotDistinct": false,
521
+ "columns": [
522
+ "organisation_id",
523
+ "id"
524
+ ]
525
+ },
526
+ "contacts_org_kind_name": {
527
+ "name": "contacts_org_kind_name",
528
+ "nullsNotDistinct": false,
529
+ "columns": [
530
+ "organisation_id",
531
+ "kind",
532
+ "name"
533
+ ]
534
+ }
535
+ },
536
+ "policies": {},
537
+ "checkConstraints": {
538
+ "contacts_kind_valid": {
539
+ "name": "contacts_kind_valid",
540
+ "value": "\"contacts\".\"kind\" in ('customer', 'supplier')"
541
+ }
542
+ },
543
+ "isRLSEnabled": false
544
+ },
545
+ "public.external_links": {
546
+ "name": "external_links",
547
+ "schema": "",
548
+ "columns": {
549
+ "id": {
550
+ "name": "id",
551
+ "type": "uuid",
552
+ "primaryKey": true,
553
+ "notNull": true,
554
+ "default": "gen_random_uuid()"
555
+ },
556
+ "organisation_id": {
557
+ "name": "organisation_id",
558
+ "type": "uuid",
559
+ "primaryKey": false,
560
+ "notNull": true
561
+ },
562
+ "entity": {
563
+ "name": "entity",
564
+ "type": "text",
565
+ "primaryKey": false,
566
+ "notNull": true
567
+ },
568
+ "flow_id": {
569
+ "name": "flow_id",
570
+ "type": "uuid",
571
+ "primaryKey": false,
572
+ "notNull": true
573
+ },
574
+ "system": {
575
+ "name": "system",
576
+ "type": "text",
577
+ "primaryKey": false,
578
+ "notNull": true
579
+ },
580
+ "external_id": {
581
+ "name": "external_id",
582
+ "type": "text",
583
+ "primaryKey": false,
584
+ "notNull": true
585
+ },
586
+ "matched_by": {
587
+ "name": "matched_by",
588
+ "type": "text",
589
+ "primaryKey": false,
590
+ "notNull": true
591
+ },
592
+ "state": {
593
+ "name": "state",
594
+ "type": "text",
595
+ "primaryKey": false,
596
+ "notNull": true
597
+ },
598
+ "confirmed_by": {
599
+ "name": "confirmed_by",
600
+ "type": "uuid",
601
+ "primaryKey": false,
602
+ "notNull": false
603
+ },
604
+ "confirmed_at": {
605
+ "name": "confirmed_at",
606
+ "type": "timestamp with time zone",
607
+ "primaryKey": false,
608
+ "notNull": false
609
+ },
610
+ "created_at": {
611
+ "name": "created_at",
612
+ "type": "timestamp with time zone",
613
+ "primaryKey": false,
614
+ "notNull": true,
615
+ "default": "now()"
616
+ },
617
+ "updated_at": {
618
+ "name": "updated_at",
619
+ "type": "timestamp with time zone",
620
+ "primaryKey": false,
621
+ "notNull": true,
622
+ "default": "now()"
623
+ }
624
+ },
625
+ "indexes": {
626
+ "external_links_active_external": {
627
+ "name": "external_links_active_external",
628
+ "columns": [
629
+ {
630
+ "expression": "organisation_id",
631
+ "isExpression": false,
632
+ "asc": true,
633
+ "nulls": "last"
634
+ },
635
+ {
636
+ "expression": "system",
637
+ "isExpression": false,
638
+ "asc": true,
639
+ "nulls": "last"
640
+ },
641
+ {
642
+ "expression": "entity",
643
+ "isExpression": false,
644
+ "asc": true,
645
+ "nulls": "last"
646
+ },
647
+ {
648
+ "expression": "external_id",
649
+ "isExpression": false,
650
+ "asc": true,
651
+ "nulls": "last"
652
+ }
653
+ ],
654
+ "isUnique": true,
655
+ "where": "state = 'active'",
656
+ "concurrently": false,
657
+ "method": "btree",
658
+ "with": {}
659
+ },
660
+ "external_links_active_flow": {
661
+ "name": "external_links_active_flow",
662
+ "columns": [
663
+ {
664
+ "expression": "organisation_id",
665
+ "isExpression": false,
666
+ "asc": true,
667
+ "nulls": "last"
668
+ },
669
+ {
670
+ "expression": "system",
671
+ "isExpression": false,
672
+ "asc": true,
673
+ "nulls": "last"
674
+ },
675
+ {
676
+ "expression": "entity",
677
+ "isExpression": false,
678
+ "asc": true,
679
+ "nulls": "last"
680
+ },
681
+ {
682
+ "expression": "flow_id",
683
+ "isExpression": false,
684
+ "asc": true,
685
+ "nulls": "last"
686
+ }
687
+ ],
688
+ "isUnique": true,
689
+ "where": "state = 'active'",
690
+ "concurrently": false,
691
+ "method": "btree",
692
+ "with": {}
693
+ },
694
+ "external_links_flow": {
695
+ "name": "external_links_flow",
696
+ "columns": [
697
+ {
698
+ "expression": "organisation_id",
699
+ "isExpression": false,
700
+ "asc": true,
701
+ "nulls": "last"
702
+ },
703
+ {
704
+ "expression": "entity",
705
+ "isExpression": false,
706
+ "asc": true,
707
+ "nulls": "last"
708
+ },
709
+ {
710
+ "expression": "flow_id",
711
+ "isExpression": false,
712
+ "asc": true,
713
+ "nulls": "last"
714
+ }
715
+ ],
716
+ "isUnique": false,
717
+ "concurrently": false,
718
+ "method": "btree",
719
+ "with": {}
720
+ }
721
+ },
722
+ "foreignKeys": {
723
+ "external_links_organisation_id_organisations_id_fk": {
724
+ "name": "external_links_organisation_id_organisations_id_fk",
725
+ "tableFrom": "external_links",
726
+ "tableTo": "organisations",
727
+ "columnsFrom": [
728
+ "organisation_id"
729
+ ],
730
+ "columnsTo": [
731
+ "id"
732
+ ],
733
+ "onDelete": "no action",
734
+ "onUpdate": "no action"
735
+ },
736
+ "external_links_confirmed_by_people_id_fk": {
737
+ "name": "external_links_confirmed_by_people_id_fk",
738
+ "tableFrom": "external_links",
739
+ "tableTo": "people",
740
+ "columnsFrom": [
741
+ "confirmed_by"
742
+ ],
743
+ "columnsTo": [
744
+ "id"
745
+ ],
746
+ "onDelete": "set null",
747
+ "onUpdate": "no action"
748
+ }
749
+ },
750
+ "compositePrimaryKeys": {},
751
+ "uniqueConstraints": {
752
+ "external_links_org_id": {
753
+ "name": "external_links_org_id",
754
+ "nullsNotDistinct": false,
755
+ "columns": [
756
+ "organisation_id",
757
+ "id"
758
+ ]
759
+ }
760
+ },
761
+ "policies": {},
762
+ "checkConstraints": {
763
+ "external_links_entity_valid": {
764
+ "name": "external_links_entity_valid",
765
+ "value": "entity in ('contact', 'price_item', 'obligation', 'invoice', 'payment', 'credit_note')"
766
+ },
767
+ "external_links_matched_by_valid": {
768
+ "name": "external_links_matched_by_valid",
769
+ "value": "matched_by in ('created_by_flow', 'exact_id', 'imported', 'name', 'person')"
770
+ },
771
+ "external_links_state_valid": {
772
+ "name": "external_links_state_valid",
773
+ "value": "state in ('active', 'proposed', 'superseded')"
774
+ },
775
+ "external_links_name_needs_person": {
776
+ "name": "external_links_name_needs_person",
777
+ "value": "\"external_links\".\"matched_by\" <> 'name' or \"external_links\".\"state\" <> 'active' or \"external_links\".\"confirmed_at\" is not null"
778
+ }
779
+ },
780
+ "isRLSEnabled": false
781
+ },
782
+ "public.integration_setting_events": {
783
+ "name": "integration_setting_events",
784
+ "schema": "",
785
+ "columns": {
786
+ "id": {
787
+ "name": "id",
788
+ "type": "uuid",
789
+ "primaryKey": true,
790
+ "notNull": true,
791
+ "default": "gen_random_uuid()"
792
+ },
793
+ "adapter_id": {
794
+ "name": "adapter_id",
795
+ "type": "text",
796
+ "primaryKey": false,
797
+ "notNull": true
798
+ },
799
+ "kind": {
800
+ "name": "kind",
801
+ "type": "text",
802
+ "primaryKey": false,
803
+ "notNull": true
804
+ },
805
+ "settings": {
806
+ "name": "settings",
807
+ "type": "text[]",
808
+ "primaryKey": false,
809
+ "notNull": true,
810
+ "default": "'{}'::text[]"
811
+ },
812
+ "actor": {
813
+ "name": "actor",
814
+ "type": "uuid",
815
+ "primaryKey": false,
816
+ "notNull": false
817
+ },
818
+ "created_at": {
819
+ "name": "created_at",
820
+ "type": "timestamp with time zone",
821
+ "primaryKey": false,
822
+ "notNull": true,
823
+ "default": "now()"
824
+ }
825
+ },
826
+ "indexes": {
827
+ "integration_setting_events_adapter": {
828
+ "name": "integration_setting_events_adapter",
829
+ "columns": [
830
+ {
831
+ "expression": "adapter_id",
832
+ "isExpression": false,
833
+ "asc": true,
834
+ "nulls": "last"
835
+ },
836
+ {
837
+ "expression": "created_at",
838
+ "isExpression": false,
839
+ "asc": true,
840
+ "nulls": "last"
841
+ }
842
+ ],
843
+ "isUnique": false,
844
+ "concurrently": false,
845
+ "method": "btree",
846
+ "with": {}
847
+ }
848
+ },
849
+ "foreignKeys": {
850
+ "integration_setting_events_actor_people_id_fk": {
851
+ "name": "integration_setting_events_actor_people_id_fk",
852
+ "tableFrom": "integration_setting_events",
853
+ "tableTo": "people",
854
+ "columnsFrom": [
855
+ "actor"
856
+ ],
857
+ "columnsTo": [
858
+ "id"
859
+ ],
860
+ "onDelete": "set null",
861
+ "onUpdate": "no action"
862
+ }
863
+ },
864
+ "compositePrimaryKeys": {},
865
+ "uniqueConstraints": {},
866
+ "policies": {},
867
+ "checkConstraints": {
868
+ "integration_setting_events_kind_valid": {
869
+ "name": "integration_setting_events_kind_valid",
870
+ "value": "kind in ('turned_on', 'turned_off', 'setting_changed', 'secret_set', 'secret_removed')"
871
+ }
872
+ },
873
+ "isRLSEnabled": false
874
+ },
875
+ "public.integration_settings": {
876
+ "name": "integration_settings",
877
+ "schema": "",
878
+ "columns": {
879
+ "adapter_id": {
880
+ "name": "adapter_id",
881
+ "type": "text",
882
+ "primaryKey": true,
883
+ "notNull": true
884
+ },
885
+ "enabled": {
886
+ "name": "enabled",
887
+ "type": "boolean",
888
+ "primaryKey": false,
889
+ "notNull": true,
890
+ "default": false
891
+ },
892
+ "config": {
893
+ "name": "config",
894
+ "type": "jsonb",
895
+ "primaryKey": false,
896
+ "notNull": true,
897
+ "default": "'{}'::jsonb"
898
+ },
899
+ "secrets": {
900
+ "name": "secrets",
901
+ "type": "jsonb",
902
+ "primaryKey": false,
903
+ "notNull": true,
904
+ "default": "'{}'::jsonb"
905
+ },
906
+ "updated_by": {
907
+ "name": "updated_by",
908
+ "type": "uuid",
909
+ "primaryKey": false,
910
+ "notNull": false
911
+ },
912
+ "created_at": {
913
+ "name": "created_at",
914
+ "type": "timestamp with time zone",
915
+ "primaryKey": false,
916
+ "notNull": true,
917
+ "default": "now()"
918
+ },
919
+ "updated_at": {
920
+ "name": "updated_at",
921
+ "type": "timestamp with time zone",
922
+ "primaryKey": false,
923
+ "notNull": true,
924
+ "default": "now()"
925
+ }
926
+ },
927
+ "indexes": {},
928
+ "foreignKeys": {
929
+ "integration_settings_updated_by_people_id_fk": {
930
+ "name": "integration_settings_updated_by_people_id_fk",
931
+ "tableFrom": "integration_settings",
932
+ "tableTo": "people",
933
+ "columnsFrom": [
934
+ "updated_by"
935
+ ],
936
+ "columnsTo": [
937
+ "id"
938
+ ],
939
+ "onDelete": "set null",
940
+ "onUpdate": "no action"
941
+ }
942
+ },
943
+ "compositePrimaryKeys": {},
944
+ "uniqueConstraints": {},
945
+ "policies": {},
946
+ "checkConstraints": {},
947
+ "isRLSEnabled": false
948
+ },
949
+ "public.invoice_lines": {
950
+ "name": "invoice_lines",
951
+ "schema": "",
952
+ "columns": {
953
+ "id": {
954
+ "name": "id",
955
+ "type": "uuid",
956
+ "primaryKey": true,
957
+ "notNull": true,
958
+ "default": "gen_random_uuid()"
959
+ },
960
+ "organisation_id": {
961
+ "name": "organisation_id",
962
+ "type": "uuid",
963
+ "primaryKey": false,
964
+ "notNull": true
965
+ },
966
+ "invoice_id": {
967
+ "name": "invoice_id",
968
+ "type": "uuid",
969
+ "primaryKey": false,
970
+ "notNull": true
971
+ },
972
+ "position": {
973
+ "name": "position",
974
+ "type": "integer",
975
+ "primaryKey": false,
976
+ "notNull": true
977
+ },
978
+ "price_item_id": {
979
+ "name": "price_item_id",
980
+ "type": "uuid",
981
+ "primaryKey": false,
982
+ "notNull": false
983
+ },
984
+ "description": {
985
+ "name": "description",
986
+ "type": "text",
987
+ "primaryKey": false,
988
+ "notNull": true
989
+ },
990
+ "quantity": {
991
+ "name": "quantity",
992
+ "type": "integer",
993
+ "primaryKey": false,
994
+ "notNull": true
995
+ },
996
+ "unit_amount_cents": {
997
+ "name": "unit_amount_cents",
998
+ "type": "integer",
999
+ "primaryKey": false,
1000
+ "notNull": true
1001
+ },
1002
+ "tax_code": {
1003
+ "name": "tax_code",
1004
+ "type": "text",
1005
+ "primaryKey": false,
1006
+ "notNull": true
1007
+ },
1008
+ "line_amount_cents": {
1009
+ "name": "line_amount_cents",
1010
+ "type": "integer",
1011
+ "primaryKey": false,
1012
+ "notNull": true
1013
+ },
1014
+ "tax_cents": {
1015
+ "name": "tax_cents",
1016
+ "type": "integer",
1017
+ "primaryKey": false,
1018
+ "notNull": true
1019
+ }
1020
+ },
1021
+ "indexes": {},
1022
+ "foreignKeys": {
1023
+ "invoice_lines_invoice_same_org": {
1024
+ "name": "invoice_lines_invoice_same_org",
1025
+ "tableFrom": "invoice_lines",
1026
+ "tableTo": "invoices",
1027
+ "columnsFrom": [
1028
+ "organisation_id",
1029
+ "invoice_id"
1030
+ ],
1031
+ "columnsTo": [
1032
+ "organisation_id",
1033
+ "id"
1034
+ ],
1035
+ "onDelete": "cascade",
1036
+ "onUpdate": "no action"
1037
+ },
1038
+ "invoice_lines_price_item_same_org": {
1039
+ "name": "invoice_lines_price_item_same_org",
1040
+ "tableFrom": "invoice_lines",
1041
+ "tableTo": "price_items",
1042
+ "columnsFrom": [
1043
+ "organisation_id",
1044
+ "price_item_id"
1045
+ ],
1046
+ "columnsTo": [
1047
+ "organisation_id",
1048
+ "id"
1049
+ ],
1050
+ "onDelete": "no action",
1051
+ "onUpdate": "no action"
1052
+ }
1053
+ },
1054
+ "compositePrimaryKeys": {},
1055
+ "uniqueConstraints": {
1056
+ "invoice_lines_invoice_position": {
1057
+ "name": "invoice_lines_invoice_position",
1058
+ "nullsNotDistinct": false,
1059
+ "columns": [
1060
+ "invoice_id",
1061
+ "position"
1062
+ ]
1063
+ }
1064
+ },
1065
+ "policies": {},
1066
+ "checkConstraints": {
1067
+ "invoice_lines_quantity_positive": {
1068
+ "name": "invoice_lines_quantity_positive",
1069
+ "value": "\"invoice_lines\".\"quantity\" > 0"
1070
+ },
1071
+ "invoice_lines_tax_code_valid": {
1072
+ "name": "invoice_lines_tax_code_valid",
1073
+ "value": "\"invoice_lines\".\"tax_code\" in ('GST', 'GST_FREE')"
1074
+ }
1075
+ },
1076
+ "isRLSEnabled": false
1077
+ },
1078
+ "public.invoice_versions": {
1079
+ "name": "invoice_versions",
1080
+ "schema": "",
1081
+ "columns": {
1082
+ "id": {
1083
+ "name": "id",
1084
+ "type": "uuid",
1085
+ "primaryKey": true,
1086
+ "notNull": true,
1087
+ "default": "gen_random_uuid()"
1088
+ },
1089
+ "organisation_id": {
1090
+ "name": "organisation_id",
1091
+ "type": "uuid",
1092
+ "primaryKey": false,
1093
+ "notNull": true
1094
+ },
1095
+ "invoice_id": {
1096
+ "name": "invoice_id",
1097
+ "type": "uuid",
1098
+ "primaryKey": false,
1099
+ "notNull": true
1100
+ },
1101
+ "version": {
1102
+ "name": "version",
1103
+ "type": "integer",
1104
+ "primaryKey": false,
1105
+ "notNull": true
1106
+ },
1107
+ "issued_at": {
1108
+ "name": "issued_at",
1109
+ "type": "timestamp with time zone",
1110
+ "primaryKey": false,
1111
+ "notNull": true,
1112
+ "default": "now()"
1113
+ },
1114
+ "issued_by": {
1115
+ "name": "issued_by",
1116
+ "type": "text",
1117
+ "primaryKey": false,
1118
+ "notNull": true
1119
+ },
1120
+ "document": {
1121
+ "name": "document",
1122
+ "type": "jsonb",
1123
+ "primaryKey": false,
1124
+ "notNull": true
1125
+ }
1126
+ },
1127
+ "indexes": {},
1128
+ "foreignKeys": {
1129
+ "invoice_versions_invoice_same_org": {
1130
+ "name": "invoice_versions_invoice_same_org",
1131
+ "tableFrom": "invoice_versions",
1132
+ "tableTo": "invoices",
1133
+ "columnsFrom": [
1134
+ "organisation_id",
1135
+ "invoice_id"
1136
+ ],
1137
+ "columnsTo": [
1138
+ "organisation_id",
1139
+ "id"
1140
+ ],
1141
+ "onDelete": "no action",
1142
+ "onUpdate": "no action"
1143
+ }
1144
+ },
1145
+ "compositePrimaryKeys": {},
1146
+ "uniqueConstraints": {
1147
+ "invoice_versions_invoice_version": {
1148
+ "name": "invoice_versions_invoice_version",
1149
+ "nullsNotDistinct": false,
1150
+ "columns": [
1151
+ "invoice_id",
1152
+ "version"
1153
+ ]
1154
+ }
1155
+ },
1156
+ "policies": {},
1157
+ "checkConstraints": {
1158
+ "invoice_versions_version_positive": {
1159
+ "name": "invoice_versions_version_positive",
1160
+ "value": "\"invoice_versions\".\"version\" > 0"
1161
+ }
1162
+ },
1163
+ "isRLSEnabled": false
1164
+ },
1165
+ "public.invoices": {
1166
+ "name": "invoices",
1167
+ "schema": "",
1168
+ "columns": {
1169
+ "id": {
1170
+ "name": "id",
1171
+ "type": "uuid",
1172
+ "primaryKey": true,
1173
+ "notNull": true,
1174
+ "default": "gen_random_uuid()"
1175
+ },
1176
+ "organisation_id": {
1177
+ "name": "organisation_id",
1178
+ "type": "uuid",
1179
+ "primaryKey": false,
1180
+ "notNull": true
1181
+ },
1182
+ "contact_id": {
1183
+ "name": "contact_id",
1184
+ "type": "uuid",
1185
+ "primaryKey": false,
1186
+ "notNull": true
1187
+ },
1188
+ "number": {
1189
+ "name": "number",
1190
+ "type": "text",
1191
+ "primaryKey": false,
1192
+ "notNull": false
1193
+ },
1194
+ "status": {
1195
+ "name": "status",
1196
+ "type": "text",
1197
+ "primaryKey": false,
1198
+ "notNull": true,
1199
+ "default": "'draft'"
1200
+ },
1201
+ "issued_version": {
1202
+ "name": "issued_version",
1203
+ "type": "integer",
1204
+ "primaryKey": false,
1205
+ "notNull": true,
1206
+ "default": 0
1207
+ },
1208
+ "reference": {
1209
+ "name": "reference",
1210
+ "type": "text",
1211
+ "primaryKey": false,
1212
+ "notNull": false
1213
+ },
1214
+ "currency": {
1215
+ "name": "currency",
1216
+ "type": "text",
1217
+ "primaryKey": false,
1218
+ "notNull": true,
1219
+ "default": "'AUD'"
1220
+ },
1221
+ "issue_date": {
1222
+ "name": "issue_date",
1223
+ "type": "date",
1224
+ "primaryKey": false,
1225
+ "notNull": false
1226
+ },
1227
+ "due_date": {
1228
+ "name": "due_date",
1229
+ "type": "date",
1230
+ "primaryKey": false,
1231
+ "notNull": false
1232
+ },
1233
+ "subtotal_cents": {
1234
+ "name": "subtotal_cents",
1235
+ "type": "integer",
1236
+ "primaryKey": false,
1237
+ "notNull": true,
1238
+ "default": 0
1239
+ },
1240
+ "tax_cents": {
1241
+ "name": "tax_cents",
1242
+ "type": "integer",
1243
+ "primaryKey": false,
1244
+ "notNull": true,
1245
+ "default": 0
1246
+ },
1247
+ "total_cents": {
1248
+ "name": "total_cents",
1249
+ "type": "integer",
1250
+ "primaryKey": false,
1251
+ "notNull": true,
1252
+ "default": 0
1253
+ },
1254
+ "created_at": {
1255
+ "name": "created_at",
1256
+ "type": "timestamp with time zone",
1257
+ "primaryKey": false,
1258
+ "notNull": true,
1259
+ "default": "now()"
1260
+ },
1261
+ "updated_at": {
1262
+ "name": "updated_at",
1263
+ "type": "timestamp with time zone",
1264
+ "primaryKey": false,
1265
+ "notNull": true,
1266
+ "default": "now()"
1267
+ }
1268
+ },
1269
+ "indexes": {},
1270
+ "foreignKeys": {
1271
+ "invoices_organisation_id_organisations_id_fk": {
1272
+ "name": "invoices_organisation_id_organisations_id_fk",
1273
+ "tableFrom": "invoices",
1274
+ "tableTo": "organisations",
1275
+ "columnsFrom": [
1276
+ "organisation_id"
1277
+ ],
1278
+ "columnsTo": [
1279
+ "id"
1280
+ ],
1281
+ "onDelete": "no action",
1282
+ "onUpdate": "no action"
1283
+ },
1284
+ "invoices_contact_same_org": {
1285
+ "name": "invoices_contact_same_org",
1286
+ "tableFrom": "invoices",
1287
+ "tableTo": "contacts",
1288
+ "columnsFrom": [
1289
+ "organisation_id",
1290
+ "contact_id"
1291
+ ],
1292
+ "columnsTo": [
1293
+ "organisation_id",
1294
+ "id"
1295
+ ],
1296
+ "onDelete": "no action",
1297
+ "onUpdate": "no action"
1298
+ }
1299
+ },
1300
+ "compositePrimaryKeys": {},
1301
+ "uniqueConstraints": {
1302
+ "invoices_org_id": {
1303
+ "name": "invoices_org_id",
1304
+ "nullsNotDistinct": false,
1305
+ "columns": [
1306
+ "organisation_id",
1307
+ "id"
1308
+ ]
1309
+ },
1310
+ "invoices_org_number": {
1311
+ "name": "invoices_org_number",
1312
+ "nullsNotDistinct": false,
1313
+ "columns": [
1314
+ "organisation_id",
1315
+ "number"
1316
+ ]
1317
+ }
1318
+ },
1319
+ "policies": {},
1320
+ "checkConstraints": {
1321
+ "invoices_status_valid": {
1322
+ "name": "invoices_status_valid",
1323
+ "value": "\"invoices\".\"status\" in ('draft', 'issued', 'void')"
1324
+ },
1325
+ "invoices_issued_has_number": {
1326
+ "name": "invoices_issued_has_number",
1327
+ "value": "\"invoices\".\"status\" = 'draft' or \"invoices\".\"number\" is not null"
1328
+ }
1329
+ },
1330
+ "isRLSEnabled": false
1331
+ },
1332
+ "public.obligation_events": {
1333
+ "name": "obligation_events",
1334
+ "schema": "",
1335
+ "columns": {
1336
+ "id": {
1337
+ "name": "id",
1338
+ "type": "uuid",
1339
+ "primaryKey": true,
1340
+ "notNull": true,
1341
+ "default": "gen_random_uuid()"
1342
+ },
1343
+ "organisation_id": {
1344
+ "name": "organisation_id",
1345
+ "type": "uuid",
1346
+ "primaryKey": false,
1347
+ "notNull": true
1348
+ },
1349
+ "obligation_id": {
1350
+ "name": "obligation_id",
1351
+ "type": "uuid",
1352
+ "primaryKey": false,
1353
+ "notNull": true
1354
+ },
1355
+ "kind": {
1356
+ "name": "kind",
1357
+ "type": "text",
1358
+ "primaryKey": false,
1359
+ "notNull": true
1360
+ },
1361
+ "actor": {
1362
+ "name": "actor",
1363
+ "type": "text",
1364
+ "primaryKey": false,
1365
+ "notNull": true
1366
+ },
1367
+ "evidence": {
1368
+ "name": "evidence",
1369
+ "type": "jsonb",
1370
+ "primaryKey": false,
1371
+ "notNull": true,
1372
+ "default": "'{}'::jsonb"
1373
+ },
1374
+ "created_at": {
1375
+ "name": "created_at",
1376
+ "type": "timestamp with time zone",
1377
+ "primaryKey": false,
1378
+ "notNull": true,
1379
+ "default": "now()"
1380
+ }
1381
+ },
1382
+ "indexes": {},
1383
+ "foreignKeys": {
1384
+ "obligation_events_obligation_same_org": {
1385
+ "name": "obligation_events_obligation_same_org",
1386
+ "tableFrom": "obligation_events",
1387
+ "tableTo": "billing_obligations",
1388
+ "columnsFrom": [
1389
+ "organisation_id",
1390
+ "obligation_id"
1391
+ ],
1392
+ "columnsTo": [
1393
+ "organisation_id",
1394
+ "id"
1395
+ ],
1396
+ "onDelete": "no action",
1397
+ "onUpdate": "no action"
1398
+ }
1399
+ },
1400
+ "compositePrimaryKeys": {},
1401
+ "uniqueConstraints": {},
1402
+ "policies": {},
1403
+ "checkConstraints": {},
1404
+ "isRLSEnabled": false
1405
+ },
1406
+ "public.obligation_payments": {
1407
+ "name": "obligation_payments",
1408
+ "schema": "",
1409
+ "columns": {
1410
+ "id": {
1411
+ "name": "id",
1412
+ "type": "uuid",
1413
+ "primaryKey": true,
1414
+ "notNull": true,
1415
+ "default": "gen_random_uuid()"
1416
+ },
1417
+ "organisation_id": {
1418
+ "name": "organisation_id",
1419
+ "type": "uuid",
1420
+ "primaryKey": false,
1421
+ "notNull": true
1422
+ },
1423
+ "obligation_id": {
1424
+ "name": "obligation_id",
1425
+ "type": "uuid",
1426
+ "primaryKey": false,
1427
+ "notNull": true
1428
+ },
1429
+ "payment_ref": {
1430
+ "name": "payment_ref",
1431
+ "type": "text",
1432
+ "primaryKey": false,
1433
+ "notNull": true
1434
+ },
1435
+ "paid_on": {
1436
+ "name": "paid_on",
1437
+ "type": "date",
1438
+ "primaryKey": false,
1439
+ "notNull": true
1440
+ },
1441
+ "amount_cents": {
1442
+ "name": "amount_cents",
1443
+ "type": "integer",
1444
+ "primaryKey": false,
1445
+ "notNull": true
1446
+ },
1447
+ "reference": {
1448
+ "name": "reference",
1449
+ "type": "text",
1450
+ "primaryKey": false,
1451
+ "notNull": false
1452
+ },
1453
+ "reconciled": {
1454
+ "name": "reconciled",
1455
+ "type": "boolean",
1456
+ "primaryKey": false,
1457
+ "notNull": true
1458
+ },
1459
+ "accounting_url": {
1460
+ "name": "accounting_url",
1461
+ "type": "text",
1462
+ "primaryKey": false,
1463
+ "notNull": false
1464
+ },
1465
+ "observed_at": {
1466
+ "name": "observed_at",
1467
+ "type": "timestamp with time zone",
1468
+ "primaryKey": false,
1469
+ "notNull": true,
1470
+ "default": "now()"
1471
+ }
1472
+ },
1473
+ "indexes": {},
1474
+ "foreignKeys": {
1475
+ "obligation_payments_obligation_same_org": {
1476
+ "name": "obligation_payments_obligation_same_org",
1477
+ "tableFrom": "obligation_payments",
1478
+ "tableTo": "billing_obligations",
1479
+ "columnsFrom": [
1480
+ "organisation_id",
1481
+ "obligation_id"
1482
+ ],
1483
+ "columnsTo": [
1484
+ "organisation_id",
1485
+ "id"
1486
+ ],
1487
+ "onDelete": "no action",
1488
+ "onUpdate": "no action"
1489
+ }
1490
+ },
1491
+ "compositePrimaryKeys": {},
1492
+ "uniqueConstraints": {
1493
+ "obligation_payments_ref": {
1494
+ "name": "obligation_payments_ref",
1495
+ "nullsNotDistinct": false,
1496
+ "columns": [
1497
+ "organisation_id",
1498
+ "obligation_id",
1499
+ "payment_ref"
1500
+ ]
1501
+ }
1502
+ },
1503
+ "policies": {},
1504
+ "checkConstraints": {
1505
+ "obligation_payments_amount_positive": {
1506
+ "name": "obligation_payments_amount_positive",
1507
+ "value": "\"obligation_payments\".\"amount_cents\" > 0"
1508
+ }
1509
+ },
1510
+ "isRLSEnabled": false
1511
+ },
1512
+ "public.obligation_writebacks": {
1513
+ "name": "obligation_writebacks",
1514
+ "schema": "",
1515
+ "columns": {
1516
+ "id": {
1517
+ "name": "id",
1518
+ "type": "uuid",
1519
+ "primaryKey": true,
1520
+ "notNull": true,
1521
+ "default": "gen_random_uuid()"
1522
+ },
1523
+ "organisation_id": {
1524
+ "name": "organisation_id",
1525
+ "type": "uuid",
1526
+ "primaryKey": false,
1527
+ "notNull": true
1528
+ },
1529
+ "obligation_id": {
1530
+ "name": "obligation_id",
1531
+ "type": "uuid",
1532
+ "primaryKey": false,
1533
+ "notNull": true
1534
+ },
1535
+ "target_system": {
1536
+ "name": "target_system",
1537
+ "type": "text",
1538
+ "primaryKey": false,
1539
+ "notNull": true
1540
+ },
1541
+ "status": {
1542
+ "name": "status",
1543
+ "type": "text",
1544
+ "primaryKey": false,
1545
+ "notNull": true
1546
+ },
1547
+ "state": {
1548
+ "name": "state",
1549
+ "type": "text",
1550
+ "primaryKey": false,
1551
+ "notNull": true,
1552
+ "default": "'pending'"
1553
+ },
1554
+ "evidence": {
1555
+ "name": "evidence",
1556
+ "type": "jsonb",
1557
+ "primaryKey": false,
1558
+ "notNull": true
1559
+ },
1560
+ "attempts": {
1561
+ "name": "attempts",
1562
+ "type": "integer",
1563
+ "primaryKey": false,
1564
+ "notNull": true,
1565
+ "default": 0
1566
+ },
1567
+ "last_error": {
1568
+ "name": "last_error",
1569
+ "type": "text",
1570
+ "primaryKey": false,
1571
+ "notNull": false
1572
+ },
1573
+ "sent_at": {
1574
+ "name": "sent_at",
1575
+ "type": "timestamp with time zone",
1576
+ "primaryKey": false,
1577
+ "notNull": false
1578
+ },
1579
+ "created_at": {
1580
+ "name": "created_at",
1581
+ "type": "timestamp with time zone",
1582
+ "primaryKey": false,
1583
+ "notNull": true,
1584
+ "default": "now()"
1585
+ },
1586
+ "updated_at": {
1587
+ "name": "updated_at",
1588
+ "type": "timestamp with time zone",
1589
+ "primaryKey": false,
1590
+ "notNull": true,
1591
+ "default": "now()"
1592
+ }
1593
+ },
1594
+ "indexes": {},
1595
+ "foreignKeys": {
1596
+ "obligation_writebacks_obligation_same_org": {
1597
+ "name": "obligation_writebacks_obligation_same_org",
1598
+ "tableFrom": "obligation_writebacks",
1599
+ "tableTo": "billing_obligations",
1600
+ "columnsFrom": [
1601
+ "organisation_id",
1602
+ "obligation_id"
1603
+ ],
1604
+ "columnsTo": [
1605
+ "organisation_id",
1606
+ "id"
1607
+ ],
1608
+ "onDelete": "no action",
1609
+ "onUpdate": "no action"
1610
+ }
1611
+ },
1612
+ "compositePrimaryKeys": {},
1613
+ "uniqueConstraints": {
1614
+ "obligation_writebacks_status": {
1615
+ "name": "obligation_writebacks_status",
1616
+ "nullsNotDistinct": false,
1617
+ "columns": [
1618
+ "organisation_id",
1619
+ "obligation_id",
1620
+ "status"
1621
+ ]
1622
+ }
1623
+ },
1624
+ "policies": {},
1625
+ "checkConstraints": {
1626
+ "obligation_writebacks_state_valid": {
1627
+ "name": "obligation_writebacks_state_valid",
1628
+ "value": "state in ('pending', 'sent', 'failed', 'not_supported')"
1629
+ }
1630
+ },
1631
+ "isRLSEnabled": false
1632
+ },
1633
+ "public.organisations": {
1634
+ "name": "organisations",
1635
+ "schema": "",
1636
+ "columns": {
1637
+ "id": {
1638
+ "name": "id",
1639
+ "type": "uuid",
1640
+ "primaryKey": true,
1641
+ "notNull": true,
1642
+ "default": "gen_random_uuid()"
1643
+ },
1644
+ "name": {
1645
+ "name": "name",
1646
+ "type": "text",
1647
+ "primaryKey": false,
1648
+ "notNull": true
1649
+ },
1650
+ "invoice_prefix": {
1651
+ "name": "invoice_prefix",
1652
+ "type": "text",
1653
+ "primaryKey": false,
1654
+ "notNull": true,
1655
+ "default": "'INV-'"
1656
+ },
1657
+ "next_invoice_number": {
1658
+ "name": "next_invoice_number",
1659
+ "type": "integer",
1660
+ "primaryKey": false,
1661
+ "notNull": true,
1662
+ "default": 1
1663
+ },
1664
+ "created_at": {
1665
+ "name": "created_at",
1666
+ "type": "timestamp with time zone",
1667
+ "primaryKey": false,
1668
+ "notNull": true,
1669
+ "default": "now()"
1670
+ }
1671
+ },
1672
+ "indexes": {},
1673
+ "foreignKeys": {},
1674
+ "compositePrimaryKeys": {},
1675
+ "uniqueConstraints": {},
1676
+ "policies": {},
1677
+ "checkConstraints": {
1678
+ "organisations_next_invoice_number_positive": {
1679
+ "name": "organisations_next_invoice_number_positive",
1680
+ "value": "\"organisations\".\"next_invoice_number\" > 0"
1681
+ }
1682
+ },
1683
+ "isRLSEnabled": false
1684
+ },
1685
+ "public.outbox": {
1686
+ "name": "outbox",
1687
+ "schema": "",
1688
+ "columns": {
1689
+ "id": {
1690
+ "name": "id",
1691
+ "type": "uuid",
1692
+ "primaryKey": true,
1693
+ "notNull": true,
1694
+ "default": "gen_random_uuid()"
1695
+ },
1696
+ "organisation_id": {
1697
+ "name": "organisation_id",
1698
+ "type": "uuid",
1699
+ "primaryKey": false,
1700
+ "notNull": true
1701
+ },
1702
+ "system": {
1703
+ "name": "system",
1704
+ "type": "text",
1705
+ "primaryKey": false,
1706
+ "notNull": true
1707
+ },
1708
+ "action": {
1709
+ "name": "action",
1710
+ "type": "text",
1711
+ "primaryKey": false,
1712
+ "notNull": true
1713
+ },
1714
+ "entity": {
1715
+ "name": "entity",
1716
+ "type": "text",
1717
+ "primaryKey": false,
1718
+ "notNull": true
1719
+ },
1720
+ "flow_id": {
1721
+ "name": "flow_id",
1722
+ "type": "uuid",
1723
+ "primaryKey": false,
1724
+ "notNull": true
1725
+ },
1726
+ "idempotency_key": {
1727
+ "name": "idempotency_key",
1728
+ "type": "text",
1729
+ "primaryKey": false,
1730
+ "notNull": true
1731
+ },
1732
+ "request": {
1733
+ "name": "request",
1734
+ "type": "jsonb",
1735
+ "primaryKey": false,
1736
+ "notNull": true
1737
+ },
1738
+ "state": {
1739
+ "name": "state",
1740
+ "type": "text",
1741
+ "primaryKey": false,
1742
+ "notNull": true,
1743
+ "default": "'pending'"
1744
+ },
1745
+ "external_id": {
1746
+ "name": "external_id",
1747
+ "type": "text",
1748
+ "primaryKey": false,
1749
+ "notNull": false
1750
+ },
1751
+ "attempts": {
1752
+ "name": "attempts",
1753
+ "type": "integer",
1754
+ "primaryKey": false,
1755
+ "notNull": true,
1756
+ "default": 0
1757
+ },
1758
+ "last_error": {
1759
+ "name": "last_error",
1760
+ "type": "text",
1761
+ "primaryKey": false,
1762
+ "notNull": false
1763
+ },
1764
+ "created_by": {
1765
+ "name": "created_by",
1766
+ "type": "text",
1767
+ "primaryKey": false,
1768
+ "notNull": true
1769
+ },
1770
+ "sent_at": {
1771
+ "name": "sent_at",
1772
+ "type": "timestamp with time zone",
1773
+ "primaryKey": false,
1774
+ "notNull": false
1775
+ },
1776
+ "created_at": {
1777
+ "name": "created_at",
1778
+ "type": "timestamp with time zone",
1779
+ "primaryKey": false,
1780
+ "notNull": true,
1781
+ "default": "now()"
1782
+ },
1783
+ "updated_at": {
1784
+ "name": "updated_at",
1785
+ "type": "timestamp with time zone",
1786
+ "primaryKey": false,
1787
+ "notNull": true,
1788
+ "default": "now()"
1789
+ }
1790
+ },
1791
+ "indexes": {
1792
+ "outbox_pending": {
1793
+ "name": "outbox_pending",
1794
+ "columns": [
1795
+ {
1796
+ "expression": "system",
1797
+ "isExpression": false,
1798
+ "asc": true,
1799
+ "nulls": "last"
1800
+ },
1801
+ {
1802
+ "expression": "state",
1803
+ "isExpression": false,
1804
+ "asc": true,
1805
+ "nulls": "last"
1806
+ },
1807
+ {
1808
+ "expression": "created_at",
1809
+ "isExpression": false,
1810
+ "asc": true,
1811
+ "nulls": "last"
1812
+ }
1813
+ ],
1814
+ "isUnique": false,
1815
+ "concurrently": false,
1816
+ "method": "btree",
1817
+ "with": {}
1818
+ }
1819
+ },
1820
+ "foreignKeys": {
1821
+ "outbox_organisation_id_organisations_id_fk": {
1822
+ "name": "outbox_organisation_id_organisations_id_fk",
1823
+ "tableFrom": "outbox",
1824
+ "tableTo": "organisations",
1825
+ "columnsFrom": [
1826
+ "organisation_id"
1827
+ ],
1828
+ "columnsTo": [
1829
+ "id"
1830
+ ],
1831
+ "onDelete": "no action",
1832
+ "onUpdate": "no action"
1833
+ }
1834
+ },
1835
+ "compositePrimaryKeys": {},
1836
+ "uniqueConstraints": {
1837
+ "outbox_org_id": {
1838
+ "name": "outbox_org_id",
1839
+ "nullsNotDistinct": false,
1840
+ "columns": [
1841
+ "organisation_id",
1842
+ "id"
1843
+ ]
1844
+ },
1845
+ "outbox_idempotency_key": {
1846
+ "name": "outbox_idempotency_key",
1847
+ "nullsNotDistinct": false,
1848
+ "columns": [
1849
+ "idempotency_key"
1850
+ ]
1851
+ }
1852
+ },
1853
+ "policies": {},
1854
+ "checkConstraints": {
1855
+ "outbox_state_valid": {
1856
+ "name": "outbox_state_valid",
1857
+ "value": "state in ('pending', 'sending', 'ambiguous', 'sent', 'failed', 'cancelled')"
1858
+ },
1859
+ "outbox_sent_has_id": {
1860
+ "name": "outbox_sent_has_id",
1861
+ "value": "\"outbox\".\"state\" <> 'sent' or \"outbox\".\"external_id\" is not null"
1862
+ }
1863
+ },
1864
+ "isRLSEnabled": false
1865
+ },
1866
+ "public.people": {
1867
+ "name": "people",
1868
+ "schema": "",
1869
+ "columns": {
1870
+ "id": {
1871
+ "name": "id",
1872
+ "type": "uuid",
1873
+ "primaryKey": true,
1874
+ "notNull": true,
1875
+ "default": "gen_random_uuid()"
1876
+ },
1877
+ "email": {
1878
+ "name": "email",
1879
+ "type": "text",
1880
+ "primaryKey": false,
1881
+ "notNull": true
1882
+ },
1883
+ "name": {
1884
+ "name": "name",
1885
+ "type": "text",
1886
+ "primaryKey": false,
1887
+ "notNull": false
1888
+ },
1889
+ "role": {
1890
+ "name": "role",
1891
+ "type": "text",
1892
+ "primaryKey": false,
1893
+ "notNull": true
1894
+ },
1895
+ "status": {
1896
+ "name": "status",
1897
+ "type": "text",
1898
+ "primaryKey": false,
1899
+ "notNull": true,
1900
+ "default": "'active'"
1901
+ },
1902
+ "clerk_user_id": {
1903
+ "name": "clerk_user_id",
1904
+ "type": "text",
1905
+ "primaryKey": false,
1906
+ "notNull": false
1907
+ },
1908
+ "invited_by": {
1909
+ "name": "invited_by",
1910
+ "type": "uuid",
1911
+ "primaryKey": false,
1912
+ "notNull": false
1913
+ },
1914
+ "linked_at": {
1915
+ "name": "linked_at",
1916
+ "type": "timestamp with time zone",
1917
+ "primaryKey": false,
1918
+ "notNull": false
1919
+ },
1920
+ "created_at": {
1921
+ "name": "created_at",
1922
+ "type": "timestamp with time zone",
1923
+ "primaryKey": false,
1924
+ "notNull": true,
1925
+ "default": "now()"
1926
+ },
1927
+ "updated_at": {
1928
+ "name": "updated_at",
1929
+ "type": "timestamp with time zone",
1930
+ "primaryKey": false,
1931
+ "notNull": true,
1932
+ "default": "now()"
1933
+ }
1934
+ },
1935
+ "indexes": {},
1936
+ "foreignKeys": {
1937
+ "people_invited_by_people_id_fk": {
1938
+ "name": "people_invited_by_people_id_fk",
1939
+ "tableFrom": "people",
1940
+ "tableTo": "people",
1941
+ "columnsFrom": [
1942
+ "invited_by"
1943
+ ],
1944
+ "columnsTo": [
1945
+ "id"
1946
+ ],
1947
+ "onDelete": "set null",
1948
+ "onUpdate": "no action"
1949
+ }
1950
+ },
1951
+ "compositePrimaryKeys": {},
1952
+ "uniqueConstraints": {
1953
+ "people_email": {
1954
+ "name": "people_email",
1955
+ "nullsNotDistinct": false,
1956
+ "columns": [
1957
+ "email"
1958
+ ]
1959
+ },
1960
+ "people_clerk_user_id": {
1961
+ "name": "people_clerk_user_id",
1962
+ "nullsNotDistinct": false,
1963
+ "columns": [
1964
+ "clerk_user_id"
1965
+ ]
1966
+ }
1967
+ },
1968
+ "policies": {},
1969
+ "checkConstraints": {
1970
+ "people_email_lower": {
1971
+ "name": "people_email_lower",
1972
+ "value": "\"people\".\"email\" = lower(\"people\".\"email\")"
1973
+ },
1974
+ "people_role_valid": {
1975
+ "name": "people_role_valid",
1976
+ "value": "\"people\".\"role\" in ('owner', 'admin', 'staff')"
1977
+ },
1978
+ "people_status_valid": {
1979
+ "name": "people_status_valid",
1980
+ "value": "\"people\".\"status\" in ('active', 'pending', 'disabled')"
1981
+ }
1982
+ },
1983
+ "isRLSEnabled": false
1984
+ },
1985
+ "public.price_items": {
1986
+ "name": "price_items",
1987
+ "schema": "",
1988
+ "columns": {
1989
+ "id": {
1990
+ "name": "id",
1991
+ "type": "uuid",
1992
+ "primaryKey": true,
1993
+ "notNull": true,
1994
+ "default": "gen_random_uuid()"
1995
+ },
1996
+ "organisation_id": {
1997
+ "name": "organisation_id",
1998
+ "type": "uuid",
1999
+ "primaryKey": false,
2000
+ "notNull": true
2001
+ },
2002
+ "code": {
2003
+ "name": "code",
2004
+ "type": "text",
2005
+ "primaryKey": false,
2006
+ "notNull": true
2007
+ },
2008
+ "name": {
2009
+ "name": "name",
2010
+ "type": "text",
2011
+ "primaryKey": false,
2012
+ "notNull": true
2013
+ },
2014
+ "unit_amount_cents": {
2015
+ "name": "unit_amount_cents",
2016
+ "type": "integer",
2017
+ "primaryKey": false,
2018
+ "notNull": true
2019
+ },
2020
+ "tax_code": {
2021
+ "name": "tax_code",
2022
+ "type": "text",
2023
+ "primaryKey": false,
2024
+ "notNull": true,
2025
+ "default": "'GST'"
2026
+ },
2027
+ "archived_at": {
2028
+ "name": "archived_at",
2029
+ "type": "timestamp with time zone",
2030
+ "primaryKey": false,
2031
+ "notNull": false
2032
+ },
2033
+ "created_at": {
2034
+ "name": "created_at",
2035
+ "type": "timestamp with time zone",
2036
+ "primaryKey": false,
2037
+ "notNull": true,
2038
+ "default": "now()"
2039
+ }
2040
+ },
2041
+ "indexes": {},
2042
+ "foreignKeys": {
2043
+ "price_items_organisation_id_organisations_id_fk": {
2044
+ "name": "price_items_organisation_id_organisations_id_fk",
2045
+ "tableFrom": "price_items",
2046
+ "tableTo": "organisations",
2047
+ "columnsFrom": [
2048
+ "organisation_id"
2049
+ ],
2050
+ "columnsTo": [
2051
+ "id"
2052
+ ],
2053
+ "onDelete": "no action",
2054
+ "onUpdate": "no action"
2055
+ }
2056
+ },
2057
+ "compositePrimaryKeys": {},
2058
+ "uniqueConstraints": {
2059
+ "price_items_org_id": {
2060
+ "name": "price_items_org_id",
2061
+ "nullsNotDistinct": false,
2062
+ "columns": [
2063
+ "organisation_id",
2064
+ "id"
2065
+ ]
2066
+ },
2067
+ "price_items_org_code": {
2068
+ "name": "price_items_org_code",
2069
+ "nullsNotDistinct": false,
2070
+ "columns": [
2071
+ "organisation_id",
2072
+ "code"
2073
+ ]
2074
+ }
2075
+ },
2076
+ "policies": {},
2077
+ "checkConstraints": {
2078
+ "price_items_tax_code_valid": {
2079
+ "name": "price_items_tax_code_valid",
2080
+ "value": "\"price_items\".\"tax_code\" in ('GST', 'GST_FREE')"
2081
+ }
2082
+ },
2083
+ "isRLSEnabled": false
2084
+ },
2085
+ "public.prior_links": {
2086
+ "name": "prior_links",
2087
+ "schema": "",
2088
+ "columns": {
2089
+ "id": {
2090
+ "name": "id",
2091
+ "type": "uuid",
2092
+ "primaryKey": true,
2093
+ "notNull": true,
2094
+ "default": "gen_random_uuid()"
2095
+ },
2096
+ "organisation_id": {
2097
+ "name": "organisation_id",
2098
+ "type": "uuid",
2099
+ "primaryKey": false,
2100
+ "notNull": true
2101
+ },
2102
+ "source_system": {
2103
+ "name": "source_system",
2104
+ "type": "text",
2105
+ "primaryKey": false,
2106
+ "notNull": true
2107
+ },
2108
+ "source_job_ref": {
2109
+ "name": "source_job_ref",
2110
+ "type": "text",
2111
+ "primaryKey": false,
2112
+ "notNull": true
2113
+ },
2114
+ "system": {
2115
+ "name": "system",
2116
+ "type": "text",
2117
+ "primaryKey": false,
2118
+ "notNull": true
2119
+ },
2120
+ "external_id": {
2121
+ "name": "external_id",
2122
+ "type": "text",
2123
+ "primaryKey": false,
2124
+ "notNull": true
2125
+ },
2126
+ "external_number": {
2127
+ "name": "external_number",
2128
+ "type": "text",
2129
+ "primaryKey": false,
2130
+ "notNull": false
2131
+ },
2132
+ "matched_by": {
2133
+ "name": "matched_by",
2134
+ "type": "text",
2135
+ "primaryKey": false,
2136
+ "notNull": true
2137
+ },
2138
+ "matched_at": {
2139
+ "name": "matched_at",
2140
+ "type": "timestamp with time zone",
2141
+ "primaryKey": false,
2142
+ "notNull": false
2143
+ },
2144
+ "origin": {
2145
+ "name": "origin",
2146
+ "type": "text",
2147
+ "primaryKey": false,
2148
+ "notNull": true
2149
+ },
2150
+ "created_at": {
2151
+ "name": "created_at",
2152
+ "type": "timestamp with time zone",
2153
+ "primaryKey": false,
2154
+ "notNull": true,
2155
+ "default": "now()"
2156
+ }
2157
+ },
2158
+ "indexes": {
2159
+ "prior_links_job": {
2160
+ "name": "prior_links_job",
2161
+ "columns": [
2162
+ {
2163
+ "expression": "organisation_id",
2164
+ "isExpression": false,
2165
+ "asc": true,
2166
+ "nulls": "last"
2167
+ },
2168
+ {
2169
+ "expression": "source_system",
2170
+ "isExpression": false,
2171
+ "asc": true,
2172
+ "nulls": "last"
2173
+ },
2174
+ {
2175
+ "expression": "source_job_ref",
2176
+ "isExpression": false,
2177
+ "asc": true,
2178
+ "nulls": "last"
2179
+ },
2180
+ {
2181
+ "expression": "system",
2182
+ "isExpression": false,
2183
+ "asc": true,
2184
+ "nulls": "last"
2185
+ }
2186
+ ],
2187
+ "isUnique": true,
2188
+ "concurrently": false,
2189
+ "method": "btree",
2190
+ "with": {}
2191
+ },
2192
+ "prior_links_external": {
2193
+ "name": "prior_links_external",
2194
+ "columns": [
2195
+ {
2196
+ "expression": "organisation_id",
2197
+ "isExpression": false,
2198
+ "asc": true,
2199
+ "nulls": "last"
2200
+ },
2201
+ {
2202
+ "expression": "system",
2203
+ "isExpression": false,
2204
+ "asc": true,
2205
+ "nulls": "last"
2206
+ },
2207
+ {
2208
+ "expression": "external_id",
2209
+ "isExpression": false,
2210
+ "asc": true,
2211
+ "nulls": "last"
2212
+ }
2213
+ ],
2214
+ "isUnique": false,
2215
+ "concurrently": false,
2216
+ "method": "btree",
2217
+ "with": {}
2218
+ }
2219
+ },
2220
+ "foreignKeys": {
2221
+ "prior_links_organisation_id_organisations_id_fk": {
2222
+ "name": "prior_links_organisation_id_organisations_id_fk",
2223
+ "tableFrom": "prior_links",
2224
+ "tableTo": "organisations",
2225
+ "columnsFrom": [
2226
+ "organisation_id"
2227
+ ],
2228
+ "columnsTo": [
2229
+ "id"
2230
+ ],
2231
+ "onDelete": "no action",
2232
+ "onUpdate": "no action"
2233
+ }
2234
+ },
2235
+ "compositePrimaryKeys": {},
2236
+ "uniqueConstraints": {},
2237
+ "policies": {},
2238
+ "checkConstraints": {
2239
+ "prior_links_matched_by_valid": {
2240
+ "name": "prior_links_matched_by_valid",
2241
+ "value": "matched_by in ('person', 'imported')"
2242
+ }
2243
+ },
2244
+ "isRLSEnabled": false
2245
+ },
2246
+ "public.review_items": {
2247
+ "name": "review_items",
2248
+ "schema": "",
2249
+ "columns": {
2250
+ "id": {
2251
+ "name": "id",
2252
+ "type": "uuid",
2253
+ "primaryKey": true,
2254
+ "notNull": true,
2255
+ "default": "gen_random_uuid()"
2256
+ },
2257
+ "organisation_id": {
2258
+ "name": "organisation_id",
2259
+ "type": "uuid",
2260
+ "primaryKey": false,
2261
+ "notNull": true
2262
+ },
2263
+ "kind": {
2264
+ "name": "kind",
2265
+ "type": "text",
2266
+ "primaryKey": false,
2267
+ "notNull": true
2268
+ },
2269
+ "entity": {
2270
+ "name": "entity",
2271
+ "type": "text",
2272
+ "primaryKey": false,
2273
+ "notNull": true
2274
+ },
2275
+ "flow_id": {
2276
+ "name": "flow_id",
2277
+ "type": "uuid",
2278
+ "primaryKey": false,
2279
+ "notNull": true
2280
+ },
2281
+ "systems": {
2282
+ "name": "systems",
2283
+ "type": "text[]",
2284
+ "primaryKey": false,
2285
+ "notNull": true,
2286
+ "default": "'{}'::text[]"
2287
+ },
2288
+ "evidence": {
2289
+ "name": "evidence",
2290
+ "type": "jsonb",
2291
+ "primaryKey": false,
2292
+ "notNull": true,
2293
+ "default": "'{}'::jsonb"
2294
+ },
2295
+ "money_at_risk_cents": {
2296
+ "name": "money_at_risk_cents",
2297
+ "type": "bigint",
2298
+ "primaryKey": false,
2299
+ "notNull": true,
2300
+ "default": 0
2301
+ },
2302
+ "state": {
2303
+ "name": "state",
2304
+ "type": "text",
2305
+ "primaryKey": false,
2306
+ "notNull": true,
2307
+ "default": "'open'"
2308
+ },
2309
+ "seen_count": {
2310
+ "name": "seen_count",
2311
+ "type": "integer",
2312
+ "primaryKey": false,
2313
+ "notNull": true,
2314
+ "default": 1
2315
+ },
2316
+ "resolution": {
2317
+ "name": "resolution",
2318
+ "type": "text",
2319
+ "primaryKey": false,
2320
+ "notNull": false
2321
+ },
2322
+ "note": {
2323
+ "name": "note",
2324
+ "type": "text",
2325
+ "primaryKey": false,
2326
+ "notNull": false
2327
+ },
2328
+ "resolved_by": {
2329
+ "name": "resolved_by",
2330
+ "type": "text",
2331
+ "primaryKey": false,
2332
+ "notNull": false
2333
+ },
2334
+ "resolved_at": {
2335
+ "name": "resolved_at",
2336
+ "type": "timestamp with time zone",
2337
+ "primaryKey": false,
2338
+ "notNull": false
2339
+ },
2340
+ "created_at": {
2341
+ "name": "created_at",
2342
+ "type": "timestamp with time zone",
2343
+ "primaryKey": false,
2344
+ "notNull": true,
2345
+ "default": "now()"
2346
+ },
2347
+ "updated_at": {
2348
+ "name": "updated_at",
2349
+ "type": "timestamp with time zone",
2350
+ "primaryKey": false,
2351
+ "notNull": true,
2352
+ "default": "now()"
2353
+ }
2354
+ },
2355
+ "indexes": {
2356
+ "review_items_one_open": {
2357
+ "name": "review_items_one_open",
2358
+ "columns": [
2359
+ {
2360
+ "expression": "organisation_id",
2361
+ "isExpression": false,
2362
+ "asc": true,
2363
+ "nulls": "last"
2364
+ },
2365
+ {
2366
+ "expression": "kind",
2367
+ "isExpression": false,
2368
+ "asc": true,
2369
+ "nulls": "last"
2370
+ },
2371
+ {
2372
+ "expression": "entity",
2373
+ "isExpression": false,
2374
+ "asc": true,
2375
+ "nulls": "last"
2376
+ },
2377
+ {
2378
+ "expression": "flow_id",
2379
+ "isExpression": false,
2380
+ "asc": true,
2381
+ "nulls": "last"
2382
+ }
2383
+ ],
2384
+ "isUnique": true,
2385
+ "where": "state = 'open'",
2386
+ "concurrently": false,
2387
+ "method": "btree",
2388
+ "with": {}
2389
+ },
2390
+ "review_items_queue": {
2391
+ "name": "review_items_queue",
2392
+ "columns": [
2393
+ {
2394
+ "expression": "organisation_id",
2395
+ "isExpression": false,
2396
+ "asc": true,
2397
+ "nulls": "last"
2398
+ },
2399
+ {
2400
+ "expression": "state",
2401
+ "isExpression": false,
2402
+ "asc": true,
2403
+ "nulls": "last"
2404
+ },
2405
+ {
2406
+ "expression": "money_at_risk_cents",
2407
+ "isExpression": false,
2408
+ "asc": true,
2409
+ "nulls": "last"
2410
+ }
2411
+ ],
2412
+ "isUnique": false,
2413
+ "concurrently": false,
2414
+ "method": "btree",
2415
+ "with": {}
2416
+ }
2417
+ },
2418
+ "foreignKeys": {
2419
+ "review_items_organisation_id_organisations_id_fk": {
2420
+ "name": "review_items_organisation_id_organisations_id_fk",
2421
+ "tableFrom": "review_items",
2422
+ "tableTo": "organisations",
2423
+ "columnsFrom": [
2424
+ "organisation_id"
2425
+ ],
2426
+ "columnsTo": [
2427
+ "id"
2428
+ ],
2429
+ "onDelete": "no action",
2430
+ "onUpdate": "no action"
2431
+ }
2432
+ },
2433
+ "compositePrimaryKeys": {},
2434
+ "uniqueConstraints": {
2435
+ "review_items_org_id": {
2436
+ "name": "review_items_org_id",
2437
+ "nullsNotDistinct": false,
2438
+ "columns": [
2439
+ "organisation_id",
2440
+ "id"
2441
+ ]
2442
+ }
2443
+ },
2444
+ "policies": {},
2445
+ "checkConstraints": {
2446
+ "review_items_state_valid": {
2447
+ "name": "review_items_state_valid",
2448
+ "value": "state in ('open', 'resolved', 'dismissed')"
2449
+ },
2450
+ "review_items_money_not_negative": {
2451
+ "name": "review_items_money_not_negative",
2452
+ "value": "\"review_items\".\"money_at_risk_cents\" >= 0"
2453
+ },
2454
+ "review_items_closed_has_resolution": {
2455
+ "name": "review_items_closed_has_resolution",
2456
+ "value": "\"review_items\".\"state\" = 'open' or (\"review_items\".\"resolution\" is not null and \"review_items\".\"resolved_by\" is not null and \"review_items\".\"resolved_at\" is not null)"
2457
+ }
2458
+ },
2459
+ "isRLSEnabled": false
2460
+ }
2461
+ },
2462
+ "enums": {},
2463
+ "schemas": {},
2464
+ "sequences": {},
2465
+ "roles": {},
2466
+ "policies": {},
2467
+ "views": {},
2468
+ "_meta": {
2469
+ "columns": {},
2470
+ "schemas": {},
2471
+ "tables": {}
2472
+ }
2473
+ }