@arcforgelabs/flow 2026.10.53-4 → 2026.11.1

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,4926 @@
1
+ {
2
+ "id": "729d3e29-d0cc-4dcb-a495-d4c7b6e76feb",
3
+ "prevId": "5c1494d6-bc5d-47af-9ba0-7e94ac8f91bb",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.agent_audit": {
8
+ "name": "agent_audit",
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
+ "created_at": {
19
+ "name": "created_at",
20
+ "type": "timestamp with time zone",
21
+ "primaryKey": false,
22
+ "notNull": true,
23
+ "default": "now()"
24
+ },
25
+ "grant_id": {
26
+ "name": "grant_id",
27
+ "type": "uuid",
28
+ "primaryKey": false,
29
+ "notNull": true
30
+ },
31
+ "person_id": {
32
+ "name": "person_id",
33
+ "type": "uuid",
34
+ "primaryKey": false,
35
+ "notNull": true
36
+ },
37
+ "tool": {
38
+ "name": "tool",
39
+ "type": "text",
40
+ "primaryKey": false,
41
+ "notNull": true
42
+ },
43
+ "status": {
44
+ "name": "status",
45
+ "type": "integer",
46
+ "primaryKey": false,
47
+ "notNull": true
48
+ },
49
+ "row_count": {
50
+ "name": "row_count",
51
+ "type": "integer",
52
+ "primaryKey": false,
53
+ "notNull": true,
54
+ "default": 0
55
+ },
56
+ "duration_ms": {
57
+ "name": "duration_ms",
58
+ "type": "integer",
59
+ "primaryKey": false,
60
+ "notNull": true
61
+ }
62
+ },
63
+ "indexes": {
64
+ "agent_audit_created": {
65
+ "name": "agent_audit_created",
66
+ "columns": [
67
+ {
68
+ "expression": "created_at",
69
+ "isExpression": false,
70
+ "asc": true,
71
+ "nulls": "last"
72
+ }
73
+ ],
74
+ "isUnique": false,
75
+ "concurrently": false,
76
+ "method": "btree",
77
+ "with": {}
78
+ }
79
+ },
80
+ "foreignKeys": {},
81
+ "compositePrimaryKeys": {},
82
+ "uniqueConstraints": {},
83
+ "policies": {},
84
+ "checkConstraints": {},
85
+ "isRLSEnabled": false
86
+ },
87
+ "public.agent_grants": {
88
+ "name": "agent_grants",
89
+ "schema": "",
90
+ "columns": {
91
+ "id": {
92
+ "name": "id",
93
+ "type": "uuid",
94
+ "primaryKey": true,
95
+ "notNull": true,
96
+ "default": "gen_random_uuid()"
97
+ },
98
+ "person_id": {
99
+ "name": "person_id",
100
+ "type": "uuid",
101
+ "primaryKey": false,
102
+ "notNull": true
103
+ },
104
+ "client_id": {
105
+ "name": "client_id",
106
+ "type": "text",
107
+ "primaryKey": false,
108
+ "notNull": true
109
+ },
110
+ "app_name": {
111
+ "name": "app_name",
112
+ "type": "text",
113
+ "primaryKey": false,
114
+ "notNull": true
115
+ },
116
+ "resource": {
117
+ "name": "resource",
118
+ "type": "text",
119
+ "primaryKey": false,
120
+ "notNull": true
121
+ },
122
+ "organisation_id": {
123
+ "name": "organisation_id",
124
+ "type": "uuid",
125
+ "primaryKey": false,
126
+ "notNull": true
127
+ },
128
+ "access_level": {
129
+ "name": "access_level",
130
+ "type": "text",
131
+ "primaryKey": false,
132
+ "notNull": true,
133
+ "default": "'read'"
134
+ },
135
+ "created_at": {
136
+ "name": "created_at",
137
+ "type": "timestamp with time zone",
138
+ "primaryKey": false,
139
+ "notNull": true,
140
+ "default": "now()"
141
+ },
142
+ "last_used_at": {
143
+ "name": "last_used_at",
144
+ "type": "timestamp with time zone",
145
+ "primaryKey": false,
146
+ "notNull": false
147
+ },
148
+ "revoked_at": {
149
+ "name": "revoked_at",
150
+ "type": "timestamp with time zone",
151
+ "primaryKey": false,
152
+ "notNull": false
153
+ },
154
+ "failure_day": {
155
+ "name": "failure_day",
156
+ "type": "date",
157
+ "primaryKey": false,
158
+ "notNull": false
159
+ },
160
+ "failure_count": {
161
+ "name": "failure_count",
162
+ "type": "integer",
163
+ "primaryKey": false,
164
+ "notNull": true,
165
+ "default": 0
166
+ },
167
+ "paused_at": {
168
+ "name": "paused_at",
169
+ "type": "timestamp with time zone",
170
+ "primaryKey": false,
171
+ "notNull": false
172
+ }
173
+ },
174
+ "indexes": {},
175
+ "foreignKeys": {
176
+ "agent_grants_person_id_people_id_fk": {
177
+ "name": "agent_grants_person_id_people_id_fk",
178
+ "tableFrom": "agent_grants",
179
+ "tableTo": "people",
180
+ "columnsFrom": [
181
+ "person_id"
182
+ ],
183
+ "columnsTo": [
184
+ "id"
185
+ ],
186
+ "onDelete": "cascade",
187
+ "onUpdate": "no action"
188
+ },
189
+ "agent_grants_organisation_id_organisations_id_fk": {
190
+ "name": "agent_grants_organisation_id_organisations_id_fk",
191
+ "tableFrom": "agent_grants",
192
+ "tableTo": "organisations",
193
+ "columnsFrom": [
194
+ "organisation_id"
195
+ ],
196
+ "columnsTo": [
197
+ "id"
198
+ ],
199
+ "onDelete": "no action",
200
+ "onUpdate": "no action"
201
+ }
202
+ },
203
+ "compositePrimaryKeys": {},
204
+ "uniqueConstraints": {
205
+ "agent_grants_person_client_resource": {
206
+ "name": "agent_grants_person_client_resource",
207
+ "nullsNotDistinct": false,
208
+ "columns": [
209
+ "person_id",
210
+ "client_id",
211
+ "resource"
212
+ ]
213
+ }
214
+ },
215
+ "policies": {},
216
+ "checkConstraints": {
217
+ "agent_grants_read_only": {
218
+ "name": "agent_grants_read_only",
219
+ "value": "access_level = 'read'"
220
+ }
221
+ },
222
+ "isRLSEnabled": false
223
+ },
224
+ "public.alert_dismissals": {
225
+ "name": "alert_dismissals",
226
+ "schema": "",
227
+ "columns": {
228
+ "organisation_id": {
229
+ "name": "organisation_id",
230
+ "type": "uuid",
231
+ "primaryKey": false,
232
+ "notNull": true
233
+ },
234
+ "person_id": {
235
+ "name": "person_id",
236
+ "type": "uuid",
237
+ "primaryKey": false,
238
+ "notNull": true
239
+ },
240
+ "alert_key": {
241
+ "name": "alert_key",
242
+ "type": "text",
243
+ "primaryKey": false,
244
+ "notNull": true
245
+ },
246
+ "members": {
247
+ "name": "members",
248
+ "type": "text[]",
249
+ "primaryKey": false,
250
+ "notNull": true,
251
+ "default": "'{}'::text[]"
252
+ },
253
+ "dismissed_at": {
254
+ "name": "dismissed_at",
255
+ "type": "timestamp with time zone",
256
+ "primaryKey": false,
257
+ "notNull": true,
258
+ "default": "now()"
259
+ }
260
+ },
261
+ "indexes": {},
262
+ "foreignKeys": {
263
+ "alert_dismissals_organisation_id_organisations_id_fk": {
264
+ "name": "alert_dismissals_organisation_id_organisations_id_fk",
265
+ "tableFrom": "alert_dismissals",
266
+ "tableTo": "organisations",
267
+ "columnsFrom": [
268
+ "organisation_id"
269
+ ],
270
+ "columnsTo": [
271
+ "id"
272
+ ],
273
+ "onDelete": "no action",
274
+ "onUpdate": "no action"
275
+ },
276
+ "alert_dismissals_person_id_people_id_fk": {
277
+ "name": "alert_dismissals_person_id_people_id_fk",
278
+ "tableFrom": "alert_dismissals",
279
+ "tableTo": "people",
280
+ "columnsFrom": [
281
+ "person_id"
282
+ ],
283
+ "columnsTo": [
284
+ "id"
285
+ ],
286
+ "onDelete": "cascade",
287
+ "onUpdate": "no action"
288
+ }
289
+ },
290
+ "compositePrimaryKeys": {
291
+ "alert_dismissals_organisation_id_person_id_alert_key_pk": {
292
+ "name": "alert_dismissals_organisation_id_person_id_alert_key_pk",
293
+ "columns": [
294
+ "organisation_id",
295
+ "person_id",
296
+ "alert_key"
297
+ ]
298
+ }
299
+ },
300
+ "uniqueConstraints": {},
301
+ "policies": {},
302
+ "checkConstraints": {},
303
+ "isRLSEnabled": false
304
+ },
305
+ "public.automations": {
306
+ "name": "automations",
307
+ "schema": "",
308
+ "columns": {
309
+ "organisation_id": {
310
+ "name": "organisation_id",
311
+ "type": "uuid",
312
+ "primaryKey": false,
313
+ "notNull": true
314
+ },
315
+ "key": {
316
+ "name": "key",
317
+ "type": "text",
318
+ "primaryKey": false,
319
+ "notNull": true
320
+ },
321
+ "enabled": {
322
+ "name": "enabled",
323
+ "type": "boolean",
324
+ "primaryKey": false,
325
+ "notNull": true
326
+ },
327
+ "config": {
328
+ "name": "config",
329
+ "type": "jsonb",
330
+ "primaryKey": false,
331
+ "notNull": true,
332
+ "default": "'{}'::jsonb"
333
+ },
334
+ "updated_by": {
335
+ "name": "updated_by",
336
+ "type": "uuid",
337
+ "primaryKey": false,
338
+ "notNull": false
339
+ },
340
+ "updated_at": {
341
+ "name": "updated_at",
342
+ "type": "timestamp with time zone",
343
+ "primaryKey": false,
344
+ "notNull": true,
345
+ "default": "now()"
346
+ }
347
+ },
348
+ "indexes": {},
349
+ "foreignKeys": {
350
+ "automations_organisation_id_organisations_id_fk": {
351
+ "name": "automations_organisation_id_organisations_id_fk",
352
+ "tableFrom": "automations",
353
+ "tableTo": "organisations",
354
+ "columnsFrom": [
355
+ "organisation_id"
356
+ ],
357
+ "columnsTo": [
358
+ "id"
359
+ ],
360
+ "onDelete": "no action",
361
+ "onUpdate": "no action"
362
+ },
363
+ "automations_updated_by_people_id_fk": {
364
+ "name": "automations_updated_by_people_id_fk",
365
+ "tableFrom": "automations",
366
+ "tableTo": "people",
367
+ "columnsFrom": [
368
+ "updated_by"
369
+ ],
370
+ "columnsTo": [
371
+ "id"
372
+ ],
373
+ "onDelete": "set null",
374
+ "onUpdate": "no action"
375
+ }
376
+ },
377
+ "compositePrimaryKeys": {
378
+ "automations_pk": {
379
+ "name": "automations_pk",
380
+ "columns": [
381
+ "organisation_id",
382
+ "key"
383
+ ]
384
+ }
385
+ },
386
+ "uniqueConstraints": {},
387
+ "policies": {},
388
+ "checkConstraints": {},
389
+ "isRLSEnabled": false
390
+ },
391
+ "public.background_jobs": {
392
+ "name": "background_jobs",
393
+ "schema": "",
394
+ "columns": {
395
+ "id": {
396
+ "name": "id",
397
+ "type": "uuid",
398
+ "primaryKey": true,
399
+ "notNull": true,
400
+ "default": "gen_random_uuid()"
401
+ },
402
+ "organisation_id": {
403
+ "name": "organisation_id",
404
+ "type": "uuid",
405
+ "primaryKey": false,
406
+ "notNull": true
407
+ },
408
+ "kind": {
409
+ "name": "kind",
410
+ "type": "text",
411
+ "primaryKey": false,
412
+ "notNull": true
413
+ },
414
+ "dedupe_key": {
415
+ "name": "dedupe_key",
416
+ "type": "text",
417
+ "primaryKey": false,
418
+ "notNull": true,
419
+ "default": "''"
420
+ },
421
+ "payload": {
422
+ "name": "payload",
423
+ "type": "jsonb",
424
+ "primaryKey": false,
425
+ "notNull": true,
426
+ "default": "'{}'::jsonb"
427
+ },
428
+ "state": {
429
+ "name": "state",
430
+ "type": "text",
431
+ "primaryKey": false,
432
+ "notNull": true,
433
+ "default": "'queued'"
434
+ },
435
+ "run_after": {
436
+ "name": "run_after",
437
+ "type": "timestamp with time zone",
438
+ "primaryKey": false,
439
+ "notNull": true,
440
+ "default": "now()"
441
+ },
442
+ "attempts": {
443
+ "name": "attempts",
444
+ "type": "integer",
445
+ "primaryKey": false,
446
+ "notNull": true,
447
+ "default": 0
448
+ },
449
+ "max_attempts": {
450
+ "name": "max_attempts",
451
+ "type": "integer",
452
+ "primaryKey": false,
453
+ "notNull": true,
454
+ "default": 8
455
+ },
456
+ "locked_by": {
457
+ "name": "locked_by",
458
+ "type": "text",
459
+ "primaryKey": false,
460
+ "notNull": false
461
+ },
462
+ "locked_until": {
463
+ "name": "locked_until",
464
+ "type": "timestamp with time zone",
465
+ "primaryKey": false,
466
+ "notNull": false
467
+ },
468
+ "result": {
469
+ "name": "result",
470
+ "type": "jsonb",
471
+ "primaryKey": false,
472
+ "notNull": false
473
+ },
474
+ "last_error": {
475
+ "name": "last_error",
476
+ "type": "text",
477
+ "primaryKey": false,
478
+ "notNull": false
479
+ },
480
+ "created_at": {
481
+ "name": "created_at",
482
+ "type": "timestamp with time zone",
483
+ "primaryKey": false,
484
+ "notNull": true,
485
+ "default": "now()"
486
+ },
487
+ "updated_at": {
488
+ "name": "updated_at",
489
+ "type": "timestamp with time zone",
490
+ "primaryKey": false,
491
+ "notNull": true,
492
+ "default": "now()"
493
+ }
494
+ },
495
+ "indexes": {
496
+ "background_jobs_one_open": {
497
+ "name": "background_jobs_one_open",
498
+ "columns": [
499
+ {
500
+ "expression": "organisation_id",
501
+ "isExpression": false,
502
+ "asc": true,
503
+ "nulls": "last"
504
+ },
505
+ {
506
+ "expression": "kind",
507
+ "isExpression": false,
508
+ "asc": true,
509
+ "nulls": "last"
510
+ },
511
+ {
512
+ "expression": "dedupe_key",
513
+ "isExpression": false,
514
+ "asc": true,
515
+ "nulls": "last"
516
+ }
517
+ ],
518
+ "isUnique": true,
519
+ "where": "state in ('queued', 'running')",
520
+ "concurrently": false,
521
+ "method": "btree",
522
+ "with": {}
523
+ },
524
+ "background_jobs_due": {
525
+ "name": "background_jobs_due",
526
+ "columns": [
527
+ {
528
+ "expression": "state",
529
+ "isExpression": false,
530
+ "asc": true,
531
+ "nulls": "last"
532
+ },
533
+ {
534
+ "expression": "run_after",
535
+ "isExpression": false,
536
+ "asc": true,
537
+ "nulls": "last"
538
+ }
539
+ ],
540
+ "isUnique": false,
541
+ "concurrently": false,
542
+ "method": "btree",
543
+ "with": {}
544
+ }
545
+ },
546
+ "foreignKeys": {
547
+ "background_jobs_organisation_id_organisations_id_fk": {
548
+ "name": "background_jobs_organisation_id_organisations_id_fk",
549
+ "tableFrom": "background_jobs",
550
+ "tableTo": "organisations",
551
+ "columnsFrom": [
552
+ "organisation_id"
553
+ ],
554
+ "columnsTo": [
555
+ "id"
556
+ ],
557
+ "onDelete": "no action",
558
+ "onUpdate": "no action"
559
+ }
560
+ },
561
+ "compositePrimaryKeys": {},
562
+ "uniqueConstraints": {},
563
+ "policies": {},
564
+ "checkConstraints": {
565
+ "background_jobs_state_valid": {
566
+ "name": "background_jobs_state_valid",
567
+ "value": "state in ('queued', 'running', 'succeeded', 'failed', 'dead')"
568
+ },
569
+ "background_jobs_attempts_valid": {
570
+ "name": "background_jobs_attempts_valid",
571
+ "value": "\"background_jobs\".\"attempts\" >= 0 and \"background_jobs\".\"max_attempts\" > 0"
572
+ }
573
+ },
574
+ "isRLSEnabled": false
575
+ },
576
+ "public.billing_obligations": {
577
+ "name": "billing_obligations",
578
+ "schema": "",
579
+ "columns": {
580
+ "id": {
581
+ "name": "id",
582
+ "type": "uuid",
583
+ "primaryKey": true,
584
+ "notNull": true,
585
+ "default": "gen_random_uuid()"
586
+ },
587
+ "organisation_id": {
588
+ "name": "organisation_id",
589
+ "type": "uuid",
590
+ "primaryKey": false,
591
+ "notNull": true
592
+ },
593
+ "source_system": {
594
+ "name": "source_system",
595
+ "type": "text",
596
+ "primaryKey": false,
597
+ "notNull": true
598
+ },
599
+ "source_job_ref": {
600
+ "name": "source_job_ref",
601
+ "type": "text",
602
+ "primaryKey": false,
603
+ "notNull": true
604
+ },
605
+ "source_invoice_ref": {
606
+ "name": "source_invoice_ref",
607
+ "type": "text",
608
+ "primaryKey": false,
609
+ "notNull": false
610
+ },
611
+ "case_ref": {
612
+ "name": "case_ref",
613
+ "type": "text",
614
+ "primaryKey": false,
615
+ "notNull": false
616
+ },
617
+ "contact_id": {
618
+ "name": "contact_id",
619
+ "type": "uuid",
620
+ "primaryKey": false,
621
+ "notNull": false
622
+ },
623
+ "practitioner": {
624
+ "name": "practitioner",
625
+ "type": "text",
626
+ "primaryKey": false,
627
+ "notNull": false
628
+ },
629
+ "shipped_on": {
630
+ "name": "shipped_on",
631
+ "type": "date",
632
+ "primaryKey": false,
633
+ "notNull": false
634
+ },
635
+ "job_date": {
636
+ "name": "job_date",
637
+ "type": "date",
638
+ "primaryKey": false,
639
+ "notNull": false
640
+ },
641
+ "source_status": {
642
+ "name": "source_status",
643
+ "type": "text",
644
+ "primaryKey": false,
645
+ "notNull": false
646
+ },
647
+ "ready_at": {
648
+ "name": "ready_at",
649
+ "type": "timestamp with time zone",
650
+ "primaryKey": false,
651
+ "notNull": false
652
+ },
653
+ "ready_by": {
654
+ "name": "ready_by",
655
+ "type": "text",
656
+ "primaryKey": false,
657
+ "notNull": false
658
+ },
659
+ "lines": {
660
+ "name": "lines",
661
+ "type": "jsonb",
662
+ "primaryKey": false,
663
+ "notNull": true,
664
+ "default": "'[]'::jsonb"
665
+ },
666
+ "line_fingerprint": {
667
+ "name": "line_fingerprint",
668
+ "type": "text",
669
+ "primaryKey": false,
670
+ "notNull": true
671
+ },
672
+ "source_totals": {
673
+ "name": "source_totals",
674
+ "type": "jsonb",
675
+ "primaryKey": false,
676
+ "notNull": false
677
+ },
678
+ "subtotal_cents": {
679
+ "name": "subtotal_cents",
680
+ "type": "integer",
681
+ "primaryKey": false,
682
+ "notNull": true
683
+ },
684
+ "tax_cents": {
685
+ "name": "tax_cents",
686
+ "type": "integer",
687
+ "primaryKey": false,
688
+ "notNull": true
689
+ },
690
+ "total_cents": {
691
+ "name": "total_cents",
692
+ "type": "integer",
693
+ "primaryKey": false,
694
+ "notNull": true
695
+ },
696
+ "mapping_complete": {
697
+ "name": "mapping_complete",
698
+ "type": "boolean",
699
+ "primaryKey": false,
700
+ "notNull": true
701
+ },
702
+ "source_seen_at": {
703
+ "name": "source_seen_at",
704
+ "type": "timestamp with time zone",
705
+ "primaryKey": false,
706
+ "notNull": true
707
+ },
708
+ "hold_state": {
709
+ "name": "hold_state",
710
+ "type": "text",
711
+ "primaryKey": false,
712
+ "notNull": true,
713
+ "default": "'none'"
714
+ },
715
+ "hold_reason": {
716
+ "name": "hold_reason",
717
+ "type": "text",
718
+ "primaryKey": false,
719
+ "notNull": false
720
+ },
721
+ "invoice_id": {
722
+ "name": "invoice_id",
723
+ "type": "uuid",
724
+ "primaryKey": false,
725
+ "notNull": false
726
+ },
727
+ "draft_basis": {
728
+ "name": "draft_basis",
729
+ "type": "jsonb",
730
+ "primaryKey": false,
731
+ "notNull": false
732
+ },
733
+ "accounting_state": {
734
+ "name": "accounting_state",
735
+ "type": "text",
736
+ "primaryKey": false,
737
+ "notNull": true,
738
+ "default": "'unknown'"
739
+ },
740
+ "accounting_ref": {
741
+ "name": "accounting_ref",
742
+ "type": "text",
743
+ "primaryKey": false,
744
+ "notNull": false
745
+ },
746
+ "accounting_url": {
747
+ "name": "accounting_url",
748
+ "type": "text",
749
+ "primaryKey": false,
750
+ "notNull": false
751
+ },
752
+ "accounting_matched_by": {
753
+ "name": "accounting_matched_by",
754
+ "type": "text",
755
+ "primaryKey": false,
756
+ "notNull": false
757
+ },
758
+ "accounting_checked_at": {
759
+ "name": "accounting_checked_at",
760
+ "type": "timestamp with time zone",
761
+ "primaryKey": false,
762
+ "notNull": false
763
+ },
764
+ "paid_cents": {
765
+ "name": "paid_cents",
766
+ "type": "integer",
767
+ "primaryKey": false,
768
+ "notNull": true,
769
+ "default": 0
770
+ },
771
+ "created_at": {
772
+ "name": "created_at",
773
+ "type": "timestamp with time zone",
774
+ "primaryKey": false,
775
+ "notNull": true,
776
+ "default": "now()"
777
+ },
778
+ "updated_at": {
779
+ "name": "updated_at",
780
+ "type": "timestamp with time zone",
781
+ "primaryKey": false,
782
+ "notNull": true,
783
+ "default": "now()"
784
+ }
785
+ },
786
+ "indexes": {},
787
+ "foreignKeys": {
788
+ "billing_obligations_organisation_id_organisations_id_fk": {
789
+ "name": "billing_obligations_organisation_id_organisations_id_fk",
790
+ "tableFrom": "billing_obligations",
791
+ "tableTo": "organisations",
792
+ "columnsFrom": [
793
+ "organisation_id"
794
+ ],
795
+ "columnsTo": [
796
+ "id"
797
+ ],
798
+ "onDelete": "no action",
799
+ "onUpdate": "no action"
800
+ },
801
+ "billing_obligations_contact_same_org": {
802
+ "name": "billing_obligations_contact_same_org",
803
+ "tableFrom": "billing_obligations",
804
+ "tableTo": "contacts",
805
+ "columnsFrom": [
806
+ "organisation_id",
807
+ "contact_id"
808
+ ],
809
+ "columnsTo": [
810
+ "organisation_id",
811
+ "id"
812
+ ],
813
+ "onDelete": "no action",
814
+ "onUpdate": "no action"
815
+ },
816
+ "billing_obligations_invoice_same_org": {
817
+ "name": "billing_obligations_invoice_same_org",
818
+ "tableFrom": "billing_obligations",
819
+ "tableTo": "invoices",
820
+ "columnsFrom": [
821
+ "organisation_id",
822
+ "invoice_id"
823
+ ],
824
+ "columnsTo": [
825
+ "organisation_id",
826
+ "id"
827
+ ],
828
+ "onDelete": "no action",
829
+ "onUpdate": "no action"
830
+ }
831
+ },
832
+ "compositePrimaryKeys": {},
833
+ "uniqueConstraints": {
834
+ "billing_obligations_org_id": {
835
+ "name": "billing_obligations_org_id",
836
+ "nullsNotDistinct": false,
837
+ "columns": [
838
+ "organisation_id",
839
+ "id"
840
+ ]
841
+ },
842
+ "billing_obligations_source_job": {
843
+ "name": "billing_obligations_source_job",
844
+ "nullsNotDistinct": false,
845
+ "columns": [
846
+ "organisation_id",
847
+ "source_system",
848
+ "source_job_ref"
849
+ ]
850
+ },
851
+ "billing_obligations_invoice": {
852
+ "name": "billing_obligations_invoice",
853
+ "nullsNotDistinct": false,
854
+ "columns": [
855
+ "organisation_id",
856
+ "invoice_id"
857
+ ]
858
+ }
859
+ },
860
+ "policies": {},
861
+ "checkConstraints": {
862
+ "billing_obligations_hold_state_valid": {
863
+ "name": "billing_obligations_hold_state_valid",
864
+ "value": "hold_state in ('none', 'held', 'review')"
865
+ },
866
+ "billing_obligations_accounting_state_valid": {
867
+ "name": "billing_obligations_accounting_state_valid",
868
+ "value": "accounting_state in ('unknown', 'not_found', 'drafted', 'authorised', 'part_paid', 'paid', 'voided', 'deleted', 'ambiguous', 'conflict')"
869
+ },
870
+ "billing_obligations_paid_not_negative": {
871
+ "name": "billing_obligations_paid_not_negative",
872
+ "value": "\"billing_obligations\".\"paid_cents\" >= 0"
873
+ }
874
+ },
875
+ "isRLSEnabled": false
876
+ },
877
+ "public.captures": {
878
+ "name": "captures",
879
+ "schema": "",
880
+ "columns": {
881
+ "id": {
882
+ "name": "id",
883
+ "type": "uuid",
884
+ "primaryKey": true,
885
+ "notNull": true,
886
+ "default": "gen_random_uuid()"
887
+ },
888
+ "organisation_id": {
889
+ "name": "organisation_id",
890
+ "type": "uuid",
891
+ "primaryKey": false,
892
+ "notNull": true
893
+ },
894
+ "state": {
895
+ "name": "state",
896
+ "type": "text",
897
+ "primaryKey": false,
898
+ "notNull": true
899
+ },
900
+ "source": {
901
+ "name": "source",
902
+ "type": "text",
903
+ "primaryKey": false,
904
+ "notNull": true
905
+ },
906
+ "file_key": {
907
+ "name": "file_key",
908
+ "type": "text",
909
+ "primaryKey": false,
910
+ "notNull": true
911
+ },
912
+ "file_type": {
913
+ "name": "file_type",
914
+ "type": "text",
915
+ "primaryKey": false,
916
+ "notNull": true
917
+ },
918
+ "file_size": {
919
+ "name": "file_size",
920
+ "type": "integer",
921
+ "primaryKey": false,
922
+ "notNull": true
923
+ },
924
+ "file_sha256": {
925
+ "name": "file_sha256",
926
+ "type": "text",
927
+ "primaryKey": false,
928
+ "notNull": true
929
+ },
930
+ "idempotency_key": {
931
+ "name": "idempotency_key",
932
+ "type": "text",
933
+ "primaryKey": false,
934
+ "notNull": true
935
+ },
936
+ "read": {
937
+ "name": "read",
938
+ "type": "jsonb",
939
+ "primaryKey": false,
940
+ "notNull": false
941
+ },
942
+ "match": {
943
+ "name": "match",
944
+ "type": "jsonb",
945
+ "primaryKey": false,
946
+ "notNull": false
947
+ },
948
+ "proposal": {
949
+ "name": "proposal",
950
+ "type": "jsonb",
951
+ "primaryKey": false,
952
+ "notNull": true,
953
+ "default": "'{\"action\":null,\"jobId\":null,\"changes\":[]}'::jsonb"
954
+ },
955
+ "problem": {
956
+ "name": "problem",
957
+ "type": "text",
958
+ "primaryKey": false,
959
+ "notNull": false
960
+ },
961
+ "decision": {
962
+ "name": "decision",
963
+ "type": "text",
964
+ "primaryKey": false,
965
+ "notNull": false
966
+ },
967
+ "decided_by": {
968
+ "name": "decided_by",
969
+ "type": "uuid",
970
+ "primaryKey": false,
971
+ "notNull": false
972
+ },
973
+ "decided_at": {
974
+ "name": "decided_at",
975
+ "type": "timestamp with time zone",
976
+ "primaryKey": false,
977
+ "notNull": false
978
+ },
979
+ "photo_deleted_at": {
980
+ "name": "photo_deleted_at",
981
+ "type": "timestamp with time zone",
982
+ "primaryKey": false,
983
+ "notNull": false
984
+ },
985
+ "created_by": {
986
+ "name": "created_by",
987
+ "type": "uuid",
988
+ "primaryKey": false,
989
+ "notNull": false
990
+ },
991
+ "created_at": {
992
+ "name": "created_at",
993
+ "type": "timestamp with time zone",
994
+ "primaryKey": false,
995
+ "notNull": true,
996
+ "default": "now()"
997
+ },
998
+ "updated_at": {
999
+ "name": "updated_at",
1000
+ "type": "timestamp with time zone",
1001
+ "primaryKey": false,
1002
+ "notNull": true,
1003
+ "default": "now()"
1004
+ }
1005
+ },
1006
+ "indexes": {
1007
+ "captures_photo_open": {
1008
+ "name": "captures_photo_open",
1009
+ "columns": [
1010
+ {
1011
+ "expression": "created_at",
1012
+ "isExpression": false,
1013
+ "asc": true,
1014
+ "nulls": "last"
1015
+ }
1016
+ ],
1017
+ "isUnique": false,
1018
+ "where": "photo_deleted_at is null",
1019
+ "concurrently": false,
1020
+ "method": "btree",
1021
+ "with": {}
1022
+ }
1023
+ },
1024
+ "foreignKeys": {
1025
+ "captures_organisation_id_organisations_id_fk": {
1026
+ "name": "captures_organisation_id_organisations_id_fk",
1027
+ "tableFrom": "captures",
1028
+ "tableTo": "organisations",
1029
+ "columnsFrom": [
1030
+ "organisation_id"
1031
+ ],
1032
+ "columnsTo": [
1033
+ "id"
1034
+ ],
1035
+ "onDelete": "no action",
1036
+ "onUpdate": "no action"
1037
+ },
1038
+ "captures_decided_by_people_id_fk": {
1039
+ "name": "captures_decided_by_people_id_fk",
1040
+ "tableFrom": "captures",
1041
+ "tableTo": "people",
1042
+ "columnsFrom": [
1043
+ "decided_by"
1044
+ ],
1045
+ "columnsTo": [
1046
+ "id"
1047
+ ],
1048
+ "onDelete": "set null",
1049
+ "onUpdate": "no action"
1050
+ },
1051
+ "captures_created_by_people_id_fk": {
1052
+ "name": "captures_created_by_people_id_fk",
1053
+ "tableFrom": "captures",
1054
+ "tableTo": "people",
1055
+ "columnsFrom": [
1056
+ "created_by"
1057
+ ],
1058
+ "columnsTo": [
1059
+ "id"
1060
+ ],
1061
+ "onDelete": "set null",
1062
+ "onUpdate": "no action"
1063
+ }
1064
+ },
1065
+ "compositePrimaryKeys": {},
1066
+ "uniqueConstraints": {
1067
+ "captures_org_id": {
1068
+ "name": "captures_org_id",
1069
+ "nullsNotDistinct": false,
1070
+ "columns": [
1071
+ "organisation_id",
1072
+ "id"
1073
+ ]
1074
+ },
1075
+ "captures_org_idempotency": {
1076
+ "name": "captures_org_idempotency",
1077
+ "nullsNotDistinct": false,
1078
+ "columns": [
1079
+ "organisation_id",
1080
+ "idempotency_key"
1081
+ ]
1082
+ },
1083
+ "captures_file_key": {
1084
+ "name": "captures_file_key",
1085
+ "nullsNotDistinct": false,
1086
+ "columns": [
1087
+ "file_key"
1088
+ ]
1089
+ }
1090
+ },
1091
+ "policies": {},
1092
+ "checkConstraints": {
1093
+ "captures_state_valid": {
1094
+ "name": "captures_state_valid",
1095
+ "value": "state in ('reading', 'ready', 'done', 'problem')"
1096
+ },
1097
+ "captures_source_valid": {
1098
+ "name": "captures_source_valid",
1099
+ "value": "source in ('phone', 'desk', 'api')"
1100
+ },
1101
+ "captures_decision_valid": {
1102
+ "name": "captures_decision_valid",
1103
+ "value": "\"captures\".\"decision\" is null or \"captures\".\"decision\" in ('applied', 'discarded')"
1104
+ },
1105
+ "captures_done_has_decision": {
1106
+ "name": "captures_done_has_decision",
1107
+ "value": "(\"captures\".\"state\" = 'done') = (\"captures\".\"decision\" is not null)"
1108
+ },
1109
+ "captures_file_size_valid": {
1110
+ "name": "captures_file_size_valid",
1111
+ "value": "\"captures\".\"file_size\" >= 0"
1112
+ },
1113
+ "captures_sha256_valid": {
1114
+ "name": "captures_sha256_valid",
1115
+ "value": "\"captures\".\"file_sha256\" ~ '^[0-9a-f]{64}$'"
1116
+ },
1117
+ "captures_problem_valid": {
1118
+ "name": "captures_problem_valid",
1119
+ "value": "\"captures\".\"problem\" is null or length(\"captures\".\"problem\") between 1 and 200"
1120
+ }
1121
+ },
1122
+ "isRLSEnabled": false
1123
+ },
1124
+ "public.contacts": {
1125
+ "name": "contacts",
1126
+ "schema": "",
1127
+ "columns": {
1128
+ "id": {
1129
+ "name": "id",
1130
+ "type": "uuid",
1131
+ "primaryKey": true,
1132
+ "notNull": true,
1133
+ "default": "gen_random_uuid()"
1134
+ },
1135
+ "organisation_id": {
1136
+ "name": "organisation_id",
1137
+ "type": "uuid",
1138
+ "primaryKey": false,
1139
+ "notNull": true
1140
+ },
1141
+ "kind": {
1142
+ "name": "kind",
1143
+ "type": "text",
1144
+ "primaryKey": false,
1145
+ "notNull": true
1146
+ },
1147
+ "name": {
1148
+ "name": "name",
1149
+ "type": "text",
1150
+ "primaryKey": false,
1151
+ "notNull": true
1152
+ },
1153
+ "first_name": {
1154
+ "name": "first_name",
1155
+ "type": "text",
1156
+ "primaryKey": false,
1157
+ "notNull": false
1158
+ },
1159
+ "last_name": {
1160
+ "name": "last_name",
1161
+ "type": "text",
1162
+ "primaryKey": false,
1163
+ "notNull": false
1164
+ },
1165
+ "email": {
1166
+ "name": "email",
1167
+ "type": "text",
1168
+ "primaryKey": false,
1169
+ "notNull": false
1170
+ },
1171
+ "phone": {
1172
+ "name": "phone",
1173
+ "type": "text",
1174
+ "primaryKey": false,
1175
+ "notNull": false
1176
+ },
1177
+ "mobile": {
1178
+ "name": "mobile",
1179
+ "type": "text",
1180
+ "primaryKey": false,
1181
+ "notNull": false
1182
+ },
1183
+ "account_number": {
1184
+ "name": "account_number",
1185
+ "type": "text",
1186
+ "primaryKey": false,
1187
+ "notNull": false
1188
+ },
1189
+ "tax_number": {
1190
+ "name": "tax_number",
1191
+ "type": "text",
1192
+ "primaryKey": false,
1193
+ "notNull": false
1194
+ },
1195
+ "tax_rate": {
1196
+ "name": "tax_rate",
1197
+ "type": "text",
1198
+ "primaryKey": false,
1199
+ "notNull": false
1200
+ },
1201
+ "address": {
1202
+ "name": "address",
1203
+ "type": "jsonb",
1204
+ "primaryKey": false,
1205
+ "notNull": false
1206
+ },
1207
+ "practitioners": {
1208
+ "name": "practitioners",
1209
+ "type": "jsonb",
1210
+ "primaryKey": false,
1211
+ "notNull": true,
1212
+ "default": "'[]'::jsonb"
1213
+ },
1214
+ "active": {
1215
+ "name": "active",
1216
+ "type": "boolean",
1217
+ "primaryKey": false,
1218
+ "notNull": true,
1219
+ "default": true
1220
+ },
1221
+ "created_at": {
1222
+ "name": "created_at",
1223
+ "type": "timestamp with time zone",
1224
+ "primaryKey": false,
1225
+ "notNull": true,
1226
+ "default": "now()"
1227
+ },
1228
+ "updated_at": {
1229
+ "name": "updated_at",
1230
+ "type": "timestamp with time zone",
1231
+ "primaryKey": false,
1232
+ "notNull": true,
1233
+ "default": "now()"
1234
+ }
1235
+ },
1236
+ "indexes": {},
1237
+ "foreignKeys": {
1238
+ "contacts_organisation_id_organisations_id_fk": {
1239
+ "name": "contacts_organisation_id_organisations_id_fk",
1240
+ "tableFrom": "contacts",
1241
+ "tableTo": "organisations",
1242
+ "columnsFrom": [
1243
+ "organisation_id"
1244
+ ],
1245
+ "columnsTo": [
1246
+ "id"
1247
+ ],
1248
+ "onDelete": "no action",
1249
+ "onUpdate": "no action"
1250
+ }
1251
+ },
1252
+ "compositePrimaryKeys": {},
1253
+ "uniqueConstraints": {
1254
+ "contacts_org_id": {
1255
+ "name": "contacts_org_id",
1256
+ "nullsNotDistinct": false,
1257
+ "columns": [
1258
+ "organisation_id",
1259
+ "id"
1260
+ ]
1261
+ },
1262
+ "contacts_org_kind_name": {
1263
+ "name": "contacts_org_kind_name",
1264
+ "nullsNotDistinct": false,
1265
+ "columns": [
1266
+ "organisation_id",
1267
+ "kind",
1268
+ "name"
1269
+ ]
1270
+ }
1271
+ },
1272
+ "policies": {},
1273
+ "checkConstraints": {
1274
+ "contacts_kind_valid": {
1275
+ "name": "contacts_kind_valid",
1276
+ "value": "\"contacts\".\"kind\" in ('customer', 'supplier')"
1277
+ }
1278
+ },
1279
+ "isRLSEnabled": false
1280
+ },
1281
+ "public.customer_billing_settings": {
1282
+ "name": "customer_billing_settings",
1283
+ "schema": "",
1284
+ "columns": {
1285
+ "organisation_id": {
1286
+ "name": "organisation_id",
1287
+ "type": "uuid",
1288
+ "primaryKey": false,
1289
+ "notNull": true
1290
+ },
1291
+ "contact_id": {
1292
+ "name": "contact_id",
1293
+ "type": "uuid",
1294
+ "primaryKey": false,
1295
+ "notNull": true
1296
+ },
1297
+ "billable": {
1298
+ "name": "billable",
1299
+ "type": "boolean",
1300
+ "primaryKey": false,
1301
+ "notNull": true,
1302
+ "default": true
1303
+ },
1304
+ "default_practitioner": {
1305
+ "name": "default_practitioner",
1306
+ "type": "text",
1307
+ "primaryKey": false,
1308
+ "notNull": false
1309
+ },
1310
+ "auto_draft": {
1311
+ "name": "auto_draft",
1312
+ "type": "boolean",
1313
+ "primaryKey": false,
1314
+ "notNull": false
1315
+ },
1316
+ "send_mode": {
1317
+ "name": "send_mode",
1318
+ "type": "text",
1319
+ "primaryKey": false,
1320
+ "notNull": false
1321
+ },
1322
+ "payment_terms_days": {
1323
+ "name": "payment_terms_days",
1324
+ "type": "integer",
1325
+ "primaryKey": false,
1326
+ "notNull": false
1327
+ },
1328
+ "updated_by": {
1329
+ "name": "updated_by",
1330
+ "type": "uuid",
1331
+ "primaryKey": false,
1332
+ "notNull": false
1333
+ },
1334
+ "updated_at": {
1335
+ "name": "updated_at",
1336
+ "type": "timestamp with time zone",
1337
+ "primaryKey": false,
1338
+ "notNull": true,
1339
+ "default": "now()"
1340
+ }
1341
+ },
1342
+ "indexes": {},
1343
+ "foreignKeys": {
1344
+ "customer_billing_settings_organisation_id_organisations_id_fk": {
1345
+ "name": "customer_billing_settings_organisation_id_organisations_id_fk",
1346
+ "tableFrom": "customer_billing_settings",
1347
+ "tableTo": "organisations",
1348
+ "columnsFrom": [
1349
+ "organisation_id"
1350
+ ],
1351
+ "columnsTo": [
1352
+ "id"
1353
+ ],
1354
+ "onDelete": "no action",
1355
+ "onUpdate": "no action"
1356
+ },
1357
+ "customer_billing_settings_updated_by_people_id_fk": {
1358
+ "name": "customer_billing_settings_updated_by_people_id_fk",
1359
+ "tableFrom": "customer_billing_settings",
1360
+ "tableTo": "people",
1361
+ "columnsFrom": [
1362
+ "updated_by"
1363
+ ],
1364
+ "columnsTo": [
1365
+ "id"
1366
+ ],
1367
+ "onDelete": "set null",
1368
+ "onUpdate": "no action"
1369
+ },
1370
+ "customer_billing_settings_contact_same_org": {
1371
+ "name": "customer_billing_settings_contact_same_org",
1372
+ "tableFrom": "customer_billing_settings",
1373
+ "tableTo": "contacts",
1374
+ "columnsFrom": [
1375
+ "organisation_id",
1376
+ "contact_id"
1377
+ ],
1378
+ "columnsTo": [
1379
+ "organisation_id",
1380
+ "id"
1381
+ ],
1382
+ "onDelete": "no action",
1383
+ "onUpdate": "no action"
1384
+ }
1385
+ },
1386
+ "compositePrimaryKeys": {
1387
+ "customer_billing_settings_pk": {
1388
+ "name": "customer_billing_settings_pk",
1389
+ "columns": [
1390
+ "organisation_id",
1391
+ "contact_id"
1392
+ ]
1393
+ }
1394
+ },
1395
+ "uniqueConstraints": {},
1396
+ "policies": {},
1397
+ "checkConstraints": {
1398
+ "customer_billing_settings_send_mode_valid": {
1399
+ "name": "customer_billing_settings_send_mode_valid",
1400
+ "value": "\"customer_billing_settings\".\"send_mode\" is null or \"customer_billing_settings\".\"send_mode\" in ('accounting_draft', 'approve_and_email')"
1401
+ },
1402
+ "customer_billing_settings_terms_valid": {
1403
+ "name": "customer_billing_settings_terms_valid",
1404
+ "value": "\"customer_billing_settings\".\"payment_terms_days\" is null or \"customer_billing_settings\".\"payment_terms_days\" between 0 and 365"
1405
+ }
1406
+ },
1407
+ "isRLSEnabled": false
1408
+ },
1409
+ "public.external_links": {
1410
+ "name": "external_links",
1411
+ "schema": "",
1412
+ "columns": {
1413
+ "id": {
1414
+ "name": "id",
1415
+ "type": "uuid",
1416
+ "primaryKey": true,
1417
+ "notNull": true,
1418
+ "default": "gen_random_uuid()"
1419
+ },
1420
+ "organisation_id": {
1421
+ "name": "organisation_id",
1422
+ "type": "uuid",
1423
+ "primaryKey": false,
1424
+ "notNull": true
1425
+ },
1426
+ "entity": {
1427
+ "name": "entity",
1428
+ "type": "text",
1429
+ "primaryKey": false,
1430
+ "notNull": true
1431
+ },
1432
+ "flow_id": {
1433
+ "name": "flow_id",
1434
+ "type": "uuid",
1435
+ "primaryKey": false,
1436
+ "notNull": true
1437
+ },
1438
+ "system": {
1439
+ "name": "system",
1440
+ "type": "text",
1441
+ "primaryKey": false,
1442
+ "notNull": true
1443
+ },
1444
+ "external_id": {
1445
+ "name": "external_id",
1446
+ "type": "text",
1447
+ "primaryKey": false,
1448
+ "notNull": true
1449
+ },
1450
+ "matched_by": {
1451
+ "name": "matched_by",
1452
+ "type": "text",
1453
+ "primaryKey": false,
1454
+ "notNull": true
1455
+ },
1456
+ "state": {
1457
+ "name": "state",
1458
+ "type": "text",
1459
+ "primaryKey": false,
1460
+ "notNull": true
1461
+ },
1462
+ "confirmed_by": {
1463
+ "name": "confirmed_by",
1464
+ "type": "uuid",
1465
+ "primaryKey": false,
1466
+ "notNull": false
1467
+ },
1468
+ "confirmed_at": {
1469
+ "name": "confirmed_at",
1470
+ "type": "timestamp with time zone",
1471
+ "primaryKey": false,
1472
+ "notNull": false
1473
+ },
1474
+ "created_at": {
1475
+ "name": "created_at",
1476
+ "type": "timestamp with time zone",
1477
+ "primaryKey": false,
1478
+ "notNull": true,
1479
+ "default": "now()"
1480
+ },
1481
+ "updated_at": {
1482
+ "name": "updated_at",
1483
+ "type": "timestamp with time zone",
1484
+ "primaryKey": false,
1485
+ "notNull": true,
1486
+ "default": "now()"
1487
+ }
1488
+ },
1489
+ "indexes": {
1490
+ "external_links_active_external": {
1491
+ "name": "external_links_active_external",
1492
+ "columns": [
1493
+ {
1494
+ "expression": "organisation_id",
1495
+ "isExpression": false,
1496
+ "asc": true,
1497
+ "nulls": "last"
1498
+ },
1499
+ {
1500
+ "expression": "system",
1501
+ "isExpression": false,
1502
+ "asc": true,
1503
+ "nulls": "last"
1504
+ },
1505
+ {
1506
+ "expression": "entity",
1507
+ "isExpression": false,
1508
+ "asc": true,
1509
+ "nulls": "last"
1510
+ },
1511
+ {
1512
+ "expression": "external_id",
1513
+ "isExpression": false,
1514
+ "asc": true,
1515
+ "nulls": "last"
1516
+ }
1517
+ ],
1518
+ "isUnique": true,
1519
+ "where": "state = 'active'",
1520
+ "concurrently": false,
1521
+ "method": "btree",
1522
+ "with": {}
1523
+ },
1524
+ "external_links_active_flow": {
1525
+ "name": "external_links_active_flow",
1526
+ "columns": [
1527
+ {
1528
+ "expression": "organisation_id",
1529
+ "isExpression": false,
1530
+ "asc": true,
1531
+ "nulls": "last"
1532
+ },
1533
+ {
1534
+ "expression": "system",
1535
+ "isExpression": false,
1536
+ "asc": true,
1537
+ "nulls": "last"
1538
+ },
1539
+ {
1540
+ "expression": "entity",
1541
+ "isExpression": false,
1542
+ "asc": true,
1543
+ "nulls": "last"
1544
+ },
1545
+ {
1546
+ "expression": "flow_id",
1547
+ "isExpression": false,
1548
+ "asc": true,
1549
+ "nulls": "last"
1550
+ }
1551
+ ],
1552
+ "isUnique": true,
1553
+ "where": "state = 'active'",
1554
+ "concurrently": false,
1555
+ "method": "btree",
1556
+ "with": {}
1557
+ },
1558
+ "external_links_flow": {
1559
+ "name": "external_links_flow",
1560
+ "columns": [
1561
+ {
1562
+ "expression": "organisation_id",
1563
+ "isExpression": false,
1564
+ "asc": true,
1565
+ "nulls": "last"
1566
+ },
1567
+ {
1568
+ "expression": "entity",
1569
+ "isExpression": false,
1570
+ "asc": true,
1571
+ "nulls": "last"
1572
+ },
1573
+ {
1574
+ "expression": "flow_id",
1575
+ "isExpression": false,
1576
+ "asc": true,
1577
+ "nulls": "last"
1578
+ }
1579
+ ],
1580
+ "isUnique": false,
1581
+ "concurrently": false,
1582
+ "method": "btree",
1583
+ "with": {}
1584
+ }
1585
+ },
1586
+ "foreignKeys": {
1587
+ "external_links_organisation_id_organisations_id_fk": {
1588
+ "name": "external_links_organisation_id_organisations_id_fk",
1589
+ "tableFrom": "external_links",
1590
+ "tableTo": "organisations",
1591
+ "columnsFrom": [
1592
+ "organisation_id"
1593
+ ],
1594
+ "columnsTo": [
1595
+ "id"
1596
+ ],
1597
+ "onDelete": "no action",
1598
+ "onUpdate": "no action"
1599
+ },
1600
+ "external_links_confirmed_by_people_id_fk": {
1601
+ "name": "external_links_confirmed_by_people_id_fk",
1602
+ "tableFrom": "external_links",
1603
+ "tableTo": "people",
1604
+ "columnsFrom": [
1605
+ "confirmed_by"
1606
+ ],
1607
+ "columnsTo": [
1608
+ "id"
1609
+ ],
1610
+ "onDelete": "set null",
1611
+ "onUpdate": "no action"
1612
+ }
1613
+ },
1614
+ "compositePrimaryKeys": {},
1615
+ "uniqueConstraints": {
1616
+ "external_links_org_id": {
1617
+ "name": "external_links_org_id",
1618
+ "nullsNotDistinct": false,
1619
+ "columns": [
1620
+ "organisation_id",
1621
+ "id"
1622
+ ]
1623
+ }
1624
+ },
1625
+ "policies": {},
1626
+ "checkConstraints": {
1627
+ "external_links_entity_valid": {
1628
+ "name": "external_links_entity_valid",
1629
+ "value": "entity in ('contact', 'price_item', 'obligation', 'invoice', 'payment', 'credit_note')"
1630
+ },
1631
+ "external_links_matched_by_valid": {
1632
+ "name": "external_links_matched_by_valid",
1633
+ "value": "matched_by in ('created_by_flow', 'exact_id', 'exact_name', 'imported', 'name', 'person')"
1634
+ },
1635
+ "external_links_state_valid": {
1636
+ "name": "external_links_state_valid",
1637
+ "value": "state in ('active', 'proposed', 'superseded')"
1638
+ },
1639
+ "external_links_name_needs_person": {
1640
+ "name": "external_links_name_needs_person",
1641
+ "value": "\"external_links\".\"matched_by\" <> 'name' or \"external_links\".\"state\" <> 'active' or \"external_links\".\"confirmed_at\" is not null"
1642
+ }
1643
+ },
1644
+ "isRLSEnabled": false
1645
+ },
1646
+ "public.integration_setting_events": {
1647
+ "name": "integration_setting_events",
1648
+ "schema": "",
1649
+ "columns": {
1650
+ "id": {
1651
+ "name": "id",
1652
+ "type": "uuid",
1653
+ "primaryKey": true,
1654
+ "notNull": true,
1655
+ "default": "gen_random_uuid()"
1656
+ },
1657
+ "adapter_id": {
1658
+ "name": "adapter_id",
1659
+ "type": "text",
1660
+ "primaryKey": false,
1661
+ "notNull": true
1662
+ },
1663
+ "kind": {
1664
+ "name": "kind",
1665
+ "type": "text",
1666
+ "primaryKey": false,
1667
+ "notNull": true
1668
+ },
1669
+ "settings": {
1670
+ "name": "settings",
1671
+ "type": "text[]",
1672
+ "primaryKey": false,
1673
+ "notNull": true,
1674
+ "default": "'{}'::text[]"
1675
+ },
1676
+ "actor": {
1677
+ "name": "actor",
1678
+ "type": "uuid",
1679
+ "primaryKey": false,
1680
+ "notNull": false
1681
+ },
1682
+ "created_at": {
1683
+ "name": "created_at",
1684
+ "type": "timestamp with time zone",
1685
+ "primaryKey": false,
1686
+ "notNull": true,
1687
+ "default": "now()"
1688
+ }
1689
+ },
1690
+ "indexes": {
1691
+ "integration_setting_events_adapter": {
1692
+ "name": "integration_setting_events_adapter",
1693
+ "columns": [
1694
+ {
1695
+ "expression": "adapter_id",
1696
+ "isExpression": false,
1697
+ "asc": true,
1698
+ "nulls": "last"
1699
+ },
1700
+ {
1701
+ "expression": "created_at",
1702
+ "isExpression": false,
1703
+ "asc": true,
1704
+ "nulls": "last"
1705
+ }
1706
+ ],
1707
+ "isUnique": false,
1708
+ "concurrently": false,
1709
+ "method": "btree",
1710
+ "with": {}
1711
+ }
1712
+ },
1713
+ "foreignKeys": {
1714
+ "integration_setting_events_actor_people_id_fk": {
1715
+ "name": "integration_setting_events_actor_people_id_fk",
1716
+ "tableFrom": "integration_setting_events",
1717
+ "tableTo": "people",
1718
+ "columnsFrom": [
1719
+ "actor"
1720
+ ],
1721
+ "columnsTo": [
1722
+ "id"
1723
+ ],
1724
+ "onDelete": "set null",
1725
+ "onUpdate": "no action"
1726
+ }
1727
+ },
1728
+ "compositePrimaryKeys": {},
1729
+ "uniqueConstraints": {},
1730
+ "policies": {},
1731
+ "checkConstraints": {
1732
+ "integration_setting_events_kind_valid": {
1733
+ "name": "integration_setting_events_kind_valid",
1734
+ "value": "kind in ('turned_on', 'turned_off', 'setting_changed', 'secret_set', 'secret_removed')"
1735
+ }
1736
+ },
1737
+ "isRLSEnabled": false
1738
+ },
1739
+ "public.integration_settings": {
1740
+ "name": "integration_settings",
1741
+ "schema": "",
1742
+ "columns": {
1743
+ "adapter_id": {
1744
+ "name": "adapter_id",
1745
+ "type": "text",
1746
+ "primaryKey": true,
1747
+ "notNull": true
1748
+ },
1749
+ "enabled": {
1750
+ "name": "enabled",
1751
+ "type": "boolean",
1752
+ "primaryKey": false,
1753
+ "notNull": true,
1754
+ "default": false
1755
+ },
1756
+ "config": {
1757
+ "name": "config",
1758
+ "type": "jsonb",
1759
+ "primaryKey": false,
1760
+ "notNull": true,
1761
+ "default": "'{}'::jsonb"
1762
+ },
1763
+ "secrets": {
1764
+ "name": "secrets",
1765
+ "type": "jsonb",
1766
+ "primaryKey": false,
1767
+ "notNull": true,
1768
+ "default": "'{}'::jsonb"
1769
+ },
1770
+ "updated_by": {
1771
+ "name": "updated_by",
1772
+ "type": "uuid",
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
+ "foreignKeys": {
1793
+ "integration_settings_updated_by_people_id_fk": {
1794
+ "name": "integration_settings_updated_by_people_id_fk",
1795
+ "tableFrom": "integration_settings",
1796
+ "tableTo": "people",
1797
+ "columnsFrom": [
1798
+ "updated_by"
1799
+ ],
1800
+ "columnsTo": [
1801
+ "id"
1802
+ ],
1803
+ "onDelete": "set null",
1804
+ "onUpdate": "no action"
1805
+ }
1806
+ },
1807
+ "compositePrimaryKeys": {},
1808
+ "uniqueConstraints": {},
1809
+ "policies": {},
1810
+ "checkConstraints": {},
1811
+ "isRLSEnabled": false
1812
+ },
1813
+ "public.invoice_lines": {
1814
+ "name": "invoice_lines",
1815
+ "schema": "",
1816
+ "columns": {
1817
+ "id": {
1818
+ "name": "id",
1819
+ "type": "uuid",
1820
+ "primaryKey": true,
1821
+ "notNull": true,
1822
+ "default": "gen_random_uuid()"
1823
+ },
1824
+ "organisation_id": {
1825
+ "name": "organisation_id",
1826
+ "type": "uuid",
1827
+ "primaryKey": false,
1828
+ "notNull": true
1829
+ },
1830
+ "invoice_id": {
1831
+ "name": "invoice_id",
1832
+ "type": "uuid",
1833
+ "primaryKey": false,
1834
+ "notNull": true
1835
+ },
1836
+ "position": {
1837
+ "name": "position",
1838
+ "type": "integer",
1839
+ "primaryKey": false,
1840
+ "notNull": true
1841
+ },
1842
+ "price_item_id": {
1843
+ "name": "price_item_id",
1844
+ "type": "uuid",
1845
+ "primaryKey": false,
1846
+ "notNull": false
1847
+ },
1848
+ "description": {
1849
+ "name": "description",
1850
+ "type": "text",
1851
+ "primaryKey": false,
1852
+ "notNull": true
1853
+ },
1854
+ "quantity": {
1855
+ "name": "quantity",
1856
+ "type": "integer",
1857
+ "primaryKey": false,
1858
+ "notNull": true
1859
+ },
1860
+ "unit_amount_cents": {
1861
+ "name": "unit_amount_cents",
1862
+ "type": "integer",
1863
+ "primaryKey": false,
1864
+ "notNull": true
1865
+ },
1866
+ "tax_code": {
1867
+ "name": "tax_code",
1868
+ "type": "text",
1869
+ "primaryKey": false,
1870
+ "notNull": true
1871
+ },
1872
+ "account_code": {
1873
+ "name": "account_code",
1874
+ "type": "text",
1875
+ "primaryKey": false,
1876
+ "notNull": false
1877
+ },
1878
+ "line_amount_cents": {
1879
+ "name": "line_amount_cents",
1880
+ "type": "integer",
1881
+ "primaryKey": false,
1882
+ "notNull": true
1883
+ },
1884
+ "tax_cents": {
1885
+ "name": "tax_cents",
1886
+ "type": "integer",
1887
+ "primaryKey": false,
1888
+ "notNull": true
1889
+ }
1890
+ },
1891
+ "indexes": {},
1892
+ "foreignKeys": {
1893
+ "invoice_lines_invoice_same_org": {
1894
+ "name": "invoice_lines_invoice_same_org",
1895
+ "tableFrom": "invoice_lines",
1896
+ "tableTo": "invoices",
1897
+ "columnsFrom": [
1898
+ "organisation_id",
1899
+ "invoice_id"
1900
+ ],
1901
+ "columnsTo": [
1902
+ "organisation_id",
1903
+ "id"
1904
+ ],
1905
+ "onDelete": "cascade",
1906
+ "onUpdate": "no action"
1907
+ },
1908
+ "invoice_lines_price_item_same_org": {
1909
+ "name": "invoice_lines_price_item_same_org",
1910
+ "tableFrom": "invoice_lines",
1911
+ "tableTo": "price_items",
1912
+ "columnsFrom": [
1913
+ "organisation_id",
1914
+ "price_item_id"
1915
+ ],
1916
+ "columnsTo": [
1917
+ "organisation_id",
1918
+ "id"
1919
+ ],
1920
+ "onDelete": "no action",
1921
+ "onUpdate": "no action"
1922
+ }
1923
+ },
1924
+ "compositePrimaryKeys": {},
1925
+ "uniqueConstraints": {
1926
+ "invoice_lines_invoice_position": {
1927
+ "name": "invoice_lines_invoice_position",
1928
+ "nullsNotDistinct": false,
1929
+ "columns": [
1930
+ "invoice_id",
1931
+ "position"
1932
+ ]
1933
+ }
1934
+ },
1935
+ "policies": {},
1936
+ "checkConstraints": {
1937
+ "invoice_lines_quantity_positive": {
1938
+ "name": "invoice_lines_quantity_positive",
1939
+ "value": "\"invoice_lines\".\"quantity\" > 0"
1940
+ },
1941
+ "invoice_lines_tax_code_valid": {
1942
+ "name": "invoice_lines_tax_code_valid",
1943
+ "value": "\"invoice_lines\".\"tax_code\" in ('GST', 'GST_FREE')"
1944
+ }
1945
+ },
1946
+ "isRLSEnabled": false
1947
+ },
1948
+ "public.invoice_rules": {
1949
+ "name": "invoice_rules",
1950
+ "schema": "",
1951
+ "columns": {
1952
+ "id": {
1953
+ "name": "id",
1954
+ "type": "uuid",
1955
+ "primaryKey": true,
1956
+ "notNull": true,
1957
+ "default": "gen_random_uuid()"
1958
+ },
1959
+ "organisation_id": {
1960
+ "name": "organisation_id",
1961
+ "type": "uuid",
1962
+ "primaryKey": false,
1963
+ "notNull": true
1964
+ },
1965
+ "name": {
1966
+ "name": "name",
1967
+ "type": "text",
1968
+ "primaryKey": false,
1969
+ "notNull": true
1970
+ },
1971
+ "icon": {
1972
+ "name": "icon",
1973
+ "type": "text",
1974
+ "primaryKey": false,
1975
+ "notNull": false
1976
+ },
1977
+ "position": {
1978
+ "name": "position",
1979
+ "type": "integer",
1980
+ "primaryKey": false,
1981
+ "notNull": true
1982
+ },
1983
+ "enabled": {
1984
+ "name": "enabled",
1985
+ "type": "boolean",
1986
+ "primaryKey": false,
1987
+ "notNull": true,
1988
+ "default": true
1989
+ },
1990
+ "trigger": {
1991
+ "name": "trigger",
1992
+ "type": "text",
1993
+ "primaryKey": false,
1994
+ "notNull": true,
1995
+ "default": "'job_ready'"
1996
+ },
1997
+ "conditions": {
1998
+ "name": "conditions",
1999
+ "type": "jsonb",
2000
+ "primaryKey": false,
2001
+ "notNull": true,
2002
+ "default": "'[]'::jsonb"
2003
+ },
2004
+ "action": {
2005
+ "name": "action",
2006
+ "type": "jsonb",
2007
+ "primaryKey": false,
2008
+ "notNull": true
2009
+ },
2010
+ "starter_key": {
2011
+ "name": "starter_key",
2012
+ "type": "text",
2013
+ "primaryKey": false,
2014
+ "notNull": false
2015
+ },
2016
+ "updated_by": {
2017
+ "name": "updated_by",
2018
+ "type": "uuid",
2019
+ "primaryKey": false,
2020
+ "notNull": false
2021
+ },
2022
+ "created_at": {
2023
+ "name": "created_at",
2024
+ "type": "timestamp with time zone",
2025
+ "primaryKey": false,
2026
+ "notNull": true,
2027
+ "default": "now()"
2028
+ },
2029
+ "updated_at": {
2030
+ "name": "updated_at",
2031
+ "type": "timestamp with time zone",
2032
+ "primaryKey": false,
2033
+ "notNull": true,
2034
+ "default": "now()"
2035
+ }
2036
+ },
2037
+ "indexes": {
2038
+ "invoice_rules_starter_key": {
2039
+ "name": "invoice_rules_starter_key",
2040
+ "columns": [
2041
+ {
2042
+ "expression": "organisation_id",
2043
+ "isExpression": false,
2044
+ "asc": true,
2045
+ "nulls": "last"
2046
+ },
2047
+ {
2048
+ "expression": "starter_key",
2049
+ "isExpression": false,
2050
+ "asc": true,
2051
+ "nulls": "last"
2052
+ }
2053
+ ],
2054
+ "isUnique": true,
2055
+ "concurrently": false,
2056
+ "method": "btree",
2057
+ "with": {}
2058
+ }
2059
+ },
2060
+ "foreignKeys": {
2061
+ "invoice_rules_organisation_id_organisations_id_fk": {
2062
+ "name": "invoice_rules_organisation_id_organisations_id_fk",
2063
+ "tableFrom": "invoice_rules",
2064
+ "tableTo": "organisations",
2065
+ "columnsFrom": [
2066
+ "organisation_id"
2067
+ ],
2068
+ "columnsTo": [
2069
+ "id"
2070
+ ],
2071
+ "onDelete": "no action",
2072
+ "onUpdate": "no action"
2073
+ },
2074
+ "invoice_rules_updated_by_people_id_fk": {
2075
+ "name": "invoice_rules_updated_by_people_id_fk",
2076
+ "tableFrom": "invoice_rules",
2077
+ "tableTo": "people",
2078
+ "columnsFrom": [
2079
+ "updated_by"
2080
+ ],
2081
+ "columnsTo": [
2082
+ "id"
2083
+ ],
2084
+ "onDelete": "set null",
2085
+ "onUpdate": "no action"
2086
+ }
2087
+ },
2088
+ "compositePrimaryKeys": {},
2089
+ "uniqueConstraints": {},
2090
+ "policies": {},
2091
+ "checkConstraints": {
2092
+ "invoice_rules_trigger_valid": {
2093
+ "name": "invoice_rules_trigger_valid",
2094
+ "value": "\"invoice_rules\".\"trigger\" in ('job_ready')"
2095
+ },
2096
+ "invoice_rules_name_valid": {
2097
+ "name": "invoice_rules_name_valid",
2098
+ "value": "length(\"invoice_rules\".\"name\") between 1 and 120"
2099
+ },
2100
+ "invoice_rules_icon_valid": {
2101
+ "name": "invoice_rules_icon_valid",
2102
+ "value": "\"invoice_rules\".\"icon\" is null or (length(\"invoice_rules\".\"icon\") between 1 and 64 and \"invoice_rules\".\"icon\" !~ '[^a-z0-9-]')"
2103
+ }
2104
+ },
2105
+ "isRLSEnabled": false
2106
+ },
2107
+ "public.invoice_versions": {
2108
+ "name": "invoice_versions",
2109
+ "schema": "",
2110
+ "columns": {
2111
+ "id": {
2112
+ "name": "id",
2113
+ "type": "uuid",
2114
+ "primaryKey": true,
2115
+ "notNull": true,
2116
+ "default": "gen_random_uuid()"
2117
+ },
2118
+ "organisation_id": {
2119
+ "name": "organisation_id",
2120
+ "type": "uuid",
2121
+ "primaryKey": false,
2122
+ "notNull": true
2123
+ },
2124
+ "invoice_id": {
2125
+ "name": "invoice_id",
2126
+ "type": "uuid",
2127
+ "primaryKey": false,
2128
+ "notNull": true
2129
+ },
2130
+ "version": {
2131
+ "name": "version",
2132
+ "type": "integer",
2133
+ "primaryKey": false,
2134
+ "notNull": true
2135
+ },
2136
+ "issued_at": {
2137
+ "name": "issued_at",
2138
+ "type": "timestamp with time zone",
2139
+ "primaryKey": false,
2140
+ "notNull": true,
2141
+ "default": "now()"
2142
+ },
2143
+ "issued_by": {
2144
+ "name": "issued_by",
2145
+ "type": "text",
2146
+ "primaryKey": false,
2147
+ "notNull": true
2148
+ },
2149
+ "document": {
2150
+ "name": "document",
2151
+ "type": "jsonb",
2152
+ "primaryKey": false,
2153
+ "notNull": true
2154
+ }
2155
+ },
2156
+ "indexes": {},
2157
+ "foreignKeys": {
2158
+ "invoice_versions_invoice_same_org": {
2159
+ "name": "invoice_versions_invoice_same_org",
2160
+ "tableFrom": "invoice_versions",
2161
+ "tableTo": "invoices",
2162
+ "columnsFrom": [
2163
+ "organisation_id",
2164
+ "invoice_id"
2165
+ ],
2166
+ "columnsTo": [
2167
+ "organisation_id",
2168
+ "id"
2169
+ ],
2170
+ "onDelete": "no action",
2171
+ "onUpdate": "no action"
2172
+ }
2173
+ },
2174
+ "compositePrimaryKeys": {},
2175
+ "uniqueConstraints": {
2176
+ "invoice_versions_invoice_version": {
2177
+ "name": "invoice_versions_invoice_version",
2178
+ "nullsNotDistinct": false,
2179
+ "columns": [
2180
+ "invoice_id",
2181
+ "version"
2182
+ ]
2183
+ }
2184
+ },
2185
+ "policies": {},
2186
+ "checkConstraints": {
2187
+ "invoice_versions_version_positive": {
2188
+ "name": "invoice_versions_version_positive",
2189
+ "value": "\"invoice_versions\".\"version\" > 0"
2190
+ }
2191
+ },
2192
+ "isRLSEnabled": false
2193
+ },
2194
+ "public.invoices": {
2195
+ "name": "invoices",
2196
+ "schema": "",
2197
+ "columns": {
2198
+ "id": {
2199
+ "name": "id",
2200
+ "type": "uuid",
2201
+ "primaryKey": true,
2202
+ "notNull": true,
2203
+ "default": "gen_random_uuid()"
2204
+ },
2205
+ "organisation_id": {
2206
+ "name": "organisation_id",
2207
+ "type": "uuid",
2208
+ "primaryKey": false,
2209
+ "notNull": true
2210
+ },
2211
+ "contact_id": {
2212
+ "name": "contact_id",
2213
+ "type": "uuid",
2214
+ "primaryKey": false,
2215
+ "notNull": true
2216
+ },
2217
+ "number": {
2218
+ "name": "number",
2219
+ "type": "text",
2220
+ "primaryKey": false,
2221
+ "notNull": false
2222
+ },
2223
+ "status": {
2224
+ "name": "status",
2225
+ "type": "text",
2226
+ "primaryKey": false,
2227
+ "notNull": true,
2228
+ "default": "'draft'"
2229
+ },
2230
+ "issued_version": {
2231
+ "name": "issued_version",
2232
+ "type": "integer",
2233
+ "primaryKey": false,
2234
+ "notNull": true,
2235
+ "default": 0
2236
+ },
2237
+ "reference": {
2238
+ "name": "reference",
2239
+ "type": "text",
2240
+ "primaryKey": false,
2241
+ "notNull": false
2242
+ },
2243
+ "currency": {
2244
+ "name": "currency",
2245
+ "type": "text",
2246
+ "primaryKey": false,
2247
+ "notNull": true,
2248
+ "default": "'AUD'"
2249
+ },
2250
+ "issue_date": {
2251
+ "name": "issue_date",
2252
+ "type": "date",
2253
+ "primaryKey": false,
2254
+ "notNull": false
2255
+ },
2256
+ "due_date": {
2257
+ "name": "due_date",
2258
+ "type": "date",
2259
+ "primaryKey": false,
2260
+ "notNull": false
2261
+ },
2262
+ "subtotal_cents": {
2263
+ "name": "subtotal_cents",
2264
+ "type": "integer",
2265
+ "primaryKey": false,
2266
+ "notNull": true,
2267
+ "default": 0
2268
+ },
2269
+ "tax_cents": {
2270
+ "name": "tax_cents",
2271
+ "type": "integer",
2272
+ "primaryKey": false,
2273
+ "notNull": true,
2274
+ "default": 0
2275
+ },
2276
+ "total_cents": {
2277
+ "name": "total_cents",
2278
+ "type": "integer",
2279
+ "primaryKey": false,
2280
+ "notNull": true,
2281
+ "default": 0
2282
+ },
2283
+ "ready_at": {
2284
+ "name": "ready_at",
2285
+ "type": "timestamp with time zone",
2286
+ "primaryKey": false,
2287
+ "notNull": false
2288
+ },
2289
+ "ready_by": {
2290
+ "name": "ready_by",
2291
+ "type": "uuid",
2292
+ "primaryKey": false,
2293
+ "notNull": false
2294
+ },
2295
+ "send_state": {
2296
+ "name": "send_state",
2297
+ "type": "text",
2298
+ "primaryKey": false,
2299
+ "notNull": false
2300
+ },
2301
+ "send_error": {
2302
+ "name": "send_error",
2303
+ "type": "jsonb",
2304
+ "primaryKey": false,
2305
+ "notNull": false
2306
+ },
2307
+ "send_requested_by": {
2308
+ "name": "send_requested_by",
2309
+ "type": "uuid",
2310
+ "primaryKey": false,
2311
+ "notNull": false
2312
+ },
2313
+ "send_updated_at": {
2314
+ "name": "send_updated_at",
2315
+ "type": "timestamp with time zone",
2316
+ "primaryKey": false,
2317
+ "notNull": false
2318
+ },
2319
+ "created_at": {
2320
+ "name": "created_at",
2321
+ "type": "timestamp with time zone",
2322
+ "primaryKey": false,
2323
+ "notNull": true,
2324
+ "default": "now()"
2325
+ },
2326
+ "updated_at": {
2327
+ "name": "updated_at",
2328
+ "type": "timestamp with time zone",
2329
+ "primaryKey": false,
2330
+ "notNull": true,
2331
+ "default": "now()"
2332
+ }
2333
+ },
2334
+ "indexes": {},
2335
+ "foreignKeys": {
2336
+ "invoices_organisation_id_organisations_id_fk": {
2337
+ "name": "invoices_organisation_id_organisations_id_fk",
2338
+ "tableFrom": "invoices",
2339
+ "tableTo": "organisations",
2340
+ "columnsFrom": [
2341
+ "organisation_id"
2342
+ ],
2343
+ "columnsTo": [
2344
+ "id"
2345
+ ],
2346
+ "onDelete": "no action",
2347
+ "onUpdate": "no action"
2348
+ },
2349
+ "invoices_ready_by_people_id_fk": {
2350
+ "name": "invoices_ready_by_people_id_fk",
2351
+ "tableFrom": "invoices",
2352
+ "tableTo": "people",
2353
+ "columnsFrom": [
2354
+ "ready_by"
2355
+ ],
2356
+ "columnsTo": [
2357
+ "id"
2358
+ ],
2359
+ "onDelete": "set null",
2360
+ "onUpdate": "no action"
2361
+ },
2362
+ "invoices_send_requested_by_people_id_fk": {
2363
+ "name": "invoices_send_requested_by_people_id_fk",
2364
+ "tableFrom": "invoices",
2365
+ "tableTo": "people",
2366
+ "columnsFrom": [
2367
+ "send_requested_by"
2368
+ ],
2369
+ "columnsTo": [
2370
+ "id"
2371
+ ],
2372
+ "onDelete": "set null",
2373
+ "onUpdate": "no action"
2374
+ },
2375
+ "invoices_contact_same_org": {
2376
+ "name": "invoices_contact_same_org",
2377
+ "tableFrom": "invoices",
2378
+ "tableTo": "contacts",
2379
+ "columnsFrom": [
2380
+ "organisation_id",
2381
+ "contact_id"
2382
+ ],
2383
+ "columnsTo": [
2384
+ "organisation_id",
2385
+ "id"
2386
+ ],
2387
+ "onDelete": "no action",
2388
+ "onUpdate": "no action"
2389
+ }
2390
+ },
2391
+ "compositePrimaryKeys": {},
2392
+ "uniqueConstraints": {
2393
+ "invoices_org_id": {
2394
+ "name": "invoices_org_id",
2395
+ "nullsNotDistinct": false,
2396
+ "columns": [
2397
+ "organisation_id",
2398
+ "id"
2399
+ ]
2400
+ },
2401
+ "invoices_org_number": {
2402
+ "name": "invoices_org_number",
2403
+ "nullsNotDistinct": false,
2404
+ "columns": [
2405
+ "organisation_id",
2406
+ "number"
2407
+ ]
2408
+ }
2409
+ },
2410
+ "policies": {},
2411
+ "checkConstraints": {
2412
+ "invoices_status_valid": {
2413
+ "name": "invoices_status_valid",
2414
+ "value": "\"invoices\".\"status\" in ('draft', 'issued', 'void')"
2415
+ },
2416
+ "invoices_issued_has_number": {
2417
+ "name": "invoices_issued_has_number",
2418
+ "value": "\"invoices\".\"status\" = 'draft' or \"invoices\".\"number\" is not null"
2419
+ },
2420
+ "invoices_send_state_valid": {
2421
+ "name": "invoices_send_state_valid",
2422
+ "value": "\"invoices\".\"send_state\" is null or \"invoices\".\"send_state\" in ('queued', 'sent', 'failed')"
2423
+ }
2424
+ },
2425
+ "isRLSEnabled": false
2426
+ },
2427
+ "public.invoicing_settings": {
2428
+ "name": "invoicing_settings",
2429
+ "schema": "",
2430
+ "columns": {
2431
+ "organisation_id": {
2432
+ "name": "organisation_id",
2433
+ "type": "uuid",
2434
+ "primaryKey": true,
2435
+ "notNull": true
2436
+ },
2437
+ "send_mode": {
2438
+ "name": "send_mode",
2439
+ "type": "text",
2440
+ "primaryKey": false,
2441
+ "notNull": true,
2442
+ "default": "'accounting_draft'"
2443
+ },
2444
+ "stale_days": {
2445
+ "name": "stale_days",
2446
+ "type": "integer",
2447
+ "primaryKey": false,
2448
+ "notNull": true,
2449
+ "default": 90
2450
+ },
2451
+ "payment_terms_days": {
2452
+ "name": "payment_terms_days",
2453
+ "type": "integer",
2454
+ "primaryKey": false,
2455
+ "notNull": true,
2456
+ "default": 30
2457
+ },
2458
+ "require_practitioner": {
2459
+ "name": "require_practitioner",
2460
+ "type": "boolean",
2461
+ "primaryKey": false,
2462
+ "notNull": true,
2463
+ "default": false
2464
+ },
2465
+ "rush_item_code": {
2466
+ "name": "rush_item_code",
2467
+ "type": "text",
2468
+ "primaryKey": false,
2469
+ "notNull": false
2470
+ },
2471
+ "rush_percent": {
2472
+ "name": "rush_percent",
2473
+ "type": "integer",
2474
+ "primaryKey": false,
2475
+ "notNull": true,
2476
+ "default": 20
2477
+ },
2478
+ "reference_template": {
2479
+ "name": "reference_template",
2480
+ "type": "text",
2481
+ "primaryKey": false,
2482
+ "notNull": true,
2483
+ "default": "'{practitioner} - {patient}'"
2484
+ },
2485
+ "rules_seeded": {
2486
+ "name": "rules_seeded",
2487
+ "type": "boolean",
2488
+ "primaryKey": false,
2489
+ "notNull": true,
2490
+ "default": false
2491
+ },
2492
+ "updated_by": {
2493
+ "name": "updated_by",
2494
+ "type": "uuid",
2495
+ "primaryKey": false,
2496
+ "notNull": false
2497
+ },
2498
+ "updated_at": {
2499
+ "name": "updated_at",
2500
+ "type": "timestamp with time zone",
2501
+ "primaryKey": false,
2502
+ "notNull": true,
2503
+ "default": "now()"
2504
+ }
2505
+ },
2506
+ "indexes": {},
2507
+ "foreignKeys": {
2508
+ "invoicing_settings_organisation_id_organisations_id_fk": {
2509
+ "name": "invoicing_settings_organisation_id_organisations_id_fk",
2510
+ "tableFrom": "invoicing_settings",
2511
+ "tableTo": "organisations",
2512
+ "columnsFrom": [
2513
+ "organisation_id"
2514
+ ],
2515
+ "columnsTo": [
2516
+ "id"
2517
+ ],
2518
+ "onDelete": "no action",
2519
+ "onUpdate": "no action"
2520
+ },
2521
+ "invoicing_settings_updated_by_people_id_fk": {
2522
+ "name": "invoicing_settings_updated_by_people_id_fk",
2523
+ "tableFrom": "invoicing_settings",
2524
+ "tableTo": "people",
2525
+ "columnsFrom": [
2526
+ "updated_by"
2527
+ ],
2528
+ "columnsTo": [
2529
+ "id"
2530
+ ],
2531
+ "onDelete": "set null",
2532
+ "onUpdate": "no action"
2533
+ }
2534
+ },
2535
+ "compositePrimaryKeys": {},
2536
+ "uniqueConstraints": {},
2537
+ "policies": {},
2538
+ "checkConstraints": {
2539
+ "invoicing_settings_send_mode_valid": {
2540
+ "name": "invoicing_settings_send_mode_valid",
2541
+ "value": "send_mode in ('accounting_draft', 'approve_and_email')"
2542
+ },
2543
+ "invoicing_settings_stale_days_valid": {
2544
+ "name": "invoicing_settings_stale_days_valid",
2545
+ "value": "\"invoicing_settings\".\"stale_days\" between 1 and 3650"
2546
+ },
2547
+ "invoicing_settings_terms_valid": {
2548
+ "name": "invoicing_settings_terms_valid",
2549
+ "value": "\"invoicing_settings\".\"payment_terms_days\" between 0 and 365"
2550
+ },
2551
+ "invoicing_settings_rush_valid": {
2552
+ "name": "invoicing_settings_rush_valid",
2553
+ "value": "\"invoicing_settings\".\"rush_percent\" between 0 and 100"
2554
+ }
2555
+ },
2556
+ "isRLSEnabled": false
2557
+ },
2558
+ "public.job_field_events": {
2559
+ "name": "job_field_events",
2560
+ "schema": "",
2561
+ "columns": {
2562
+ "id": {
2563
+ "name": "id",
2564
+ "type": "uuid",
2565
+ "primaryKey": true,
2566
+ "notNull": true,
2567
+ "default": "gen_random_uuid()"
2568
+ },
2569
+ "organisation_id": {
2570
+ "name": "organisation_id",
2571
+ "type": "uuid",
2572
+ "primaryKey": false,
2573
+ "notNull": true
2574
+ },
2575
+ "field_id": {
2576
+ "name": "field_id",
2577
+ "type": "uuid",
2578
+ "primaryKey": false,
2579
+ "notNull": true
2580
+ },
2581
+ "source_system": {
2582
+ "name": "source_system",
2583
+ "type": "text",
2584
+ "primaryKey": false,
2585
+ "notNull": true
2586
+ },
2587
+ "source_job_ref": {
2588
+ "name": "source_job_ref",
2589
+ "type": "text",
2590
+ "primaryKey": false,
2591
+ "notNull": true
2592
+ },
2593
+ "from_value": {
2594
+ "name": "from_value",
2595
+ "type": "jsonb",
2596
+ "primaryKey": false,
2597
+ "notNull": false
2598
+ },
2599
+ "to_value": {
2600
+ "name": "to_value",
2601
+ "type": "jsonb",
2602
+ "primaryKey": false,
2603
+ "notNull": false
2604
+ },
2605
+ "actor": {
2606
+ "name": "actor",
2607
+ "type": "uuid",
2608
+ "primaryKey": false,
2609
+ "notNull": false
2610
+ },
2611
+ "created_at": {
2612
+ "name": "created_at",
2613
+ "type": "timestamp with time zone",
2614
+ "primaryKey": false,
2615
+ "notNull": true,
2616
+ "default": "now()"
2617
+ }
2618
+ },
2619
+ "indexes": {
2620
+ "job_field_events_job": {
2621
+ "name": "job_field_events_job",
2622
+ "columns": [
2623
+ {
2624
+ "expression": "organisation_id",
2625
+ "isExpression": false,
2626
+ "asc": true,
2627
+ "nulls": "last"
2628
+ },
2629
+ {
2630
+ "expression": "source_system",
2631
+ "isExpression": false,
2632
+ "asc": true,
2633
+ "nulls": "last"
2634
+ },
2635
+ {
2636
+ "expression": "source_job_ref",
2637
+ "isExpression": false,
2638
+ "asc": true,
2639
+ "nulls": "last"
2640
+ },
2641
+ {
2642
+ "expression": "created_at",
2643
+ "isExpression": false,
2644
+ "asc": true,
2645
+ "nulls": "last"
2646
+ }
2647
+ ],
2648
+ "isUnique": false,
2649
+ "concurrently": false,
2650
+ "method": "btree",
2651
+ "with": {}
2652
+ }
2653
+ },
2654
+ "foreignKeys": {
2655
+ "job_field_events_organisation_id_organisations_id_fk": {
2656
+ "name": "job_field_events_organisation_id_organisations_id_fk",
2657
+ "tableFrom": "job_field_events",
2658
+ "tableTo": "organisations",
2659
+ "columnsFrom": [
2660
+ "organisation_id"
2661
+ ],
2662
+ "columnsTo": [
2663
+ "id"
2664
+ ],
2665
+ "onDelete": "no action",
2666
+ "onUpdate": "no action"
2667
+ },
2668
+ "job_field_events_actor_people_id_fk": {
2669
+ "name": "job_field_events_actor_people_id_fk",
2670
+ "tableFrom": "job_field_events",
2671
+ "tableTo": "people",
2672
+ "columnsFrom": [
2673
+ "actor"
2674
+ ],
2675
+ "columnsTo": [
2676
+ "id"
2677
+ ],
2678
+ "onDelete": "set null",
2679
+ "onUpdate": "no action"
2680
+ },
2681
+ "job_field_events_field_same_org": {
2682
+ "name": "job_field_events_field_same_org",
2683
+ "tableFrom": "job_field_events",
2684
+ "tableTo": "job_fields",
2685
+ "columnsFrom": [
2686
+ "organisation_id",
2687
+ "field_id"
2688
+ ],
2689
+ "columnsTo": [
2690
+ "organisation_id",
2691
+ "id"
2692
+ ],
2693
+ "onDelete": "cascade",
2694
+ "onUpdate": "no action"
2695
+ }
2696
+ },
2697
+ "compositePrimaryKeys": {},
2698
+ "uniqueConstraints": {},
2699
+ "policies": {},
2700
+ "checkConstraints": {},
2701
+ "isRLSEnabled": false
2702
+ },
2703
+ "public.job_field_settings": {
2704
+ "name": "job_field_settings",
2705
+ "schema": "",
2706
+ "columns": {
2707
+ "organisation_id": {
2708
+ "name": "organisation_id",
2709
+ "type": "uuid",
2710
+ "primaryKey": true,
2711
+ "notNull": true
2712
+ },
2713
+ "group_colors": {
2714
+ "name": "group_colors",
2715
+ "type": "jsonb",
2716
+ "primaryKey": false,
2717
+ "notNull": true,
2718
+ "default": "'{}'::jsonb"
2719
+ },
2720
+ "assignee_made_at": {
2721
+ "name": "assignee_made_at",
2722
+ "type": "timestamp with time zone",
2723
+ "primaryKey": false,
2724
+ "notNull": false
2725
+ },
2726
+ "updated_by": {
2727
+ "name": "updated_by",
2728
+ "type": "uuid",
2729
+ "primaryKey": false,
2730
+ "notNull": false
2731
+ },
2732
+ "updated_at": {
2733
+ "name": "updated_at",
2734
+ "type": "timestamp with time zone",
2735
+ "primaryKey": false,
2736
+ "notNull": true,
2737
+ "default": "now()"
2738
+ }
2739
+ },
2740
+ "indexes": {},
2741
+ "foreignKeys": {
2742
+ "job_field_settings_organisation_id_organisations_id_fk": {
2743
+ "name": "job_field_settings_organisation_id_organisations_id_fk",
2744
+ "tableFrom": "job_field_settings",
2745
+ "tableTo": "organisations",
2746
+ "columnsFrom": [
2747
+ "organisation_id"
2748
+ ],
2749
+ "columnsTo": [
2750
+ "id"
2751
+ ],
2752
+ "onDelete": "no action",
2753
+ "onUpdate": "no action"
2754
+ },
2755
+ "job_field_settings_updated_by_people_id_fk": {
2756
+ "name": "job_field_settings_updated_by_people_id_fk",
2757
+ "tableFrom": "job_field_settings",
2758
+ "tableTo": "people",
2759
+ "columnsFrom": [
2760
+ "updated_by"
2761
+ ],
2762
+ "columnsTo": [
2763
+ "id"
2764
+ ],
2765
+ "onDelete": "set null",
2766
+ "onUpdate": "no action"
2767
+ }
2768
+ },
2769
+ "compositePrimaryKeys": {},
2770
+ "uniqueConstraints": {},
2771
+ "policies": {},
2772
+ "checkConstraints": {},
2773
+ "isRLSEnabled": false
2774
+ },
2775
+ "public.job_field_values": {
2776
+ "name": "job_field_values",
2777
+ "schema": "",
2778
+ "columns": {
2779
+ "organisation_id": {
2780
+ "name": "organisation_id",
2781
+ "type": "uuid",
2782
+ "primaryKey": false,
2783
+ "notNull": true
2784
+ },
2785
+ "field_id": {
2786
+ "name": "field_id",
2787
+ "type": "uuid",
2788
+ "primaryKey": false,
2789
+ "notNull": true
2790
+ },
2791
+ "source_system": {
2792
+ "name": "source_system",
2793
+ "type": "text",
2794
+ "primaryKey": false,
2795
+ "notNull": true
2796
+ },
2797
+ "source_job_ref": {
2798
+ "name": "source_job_ref",
2799
+ "type": "text",
2800
+ "primaryKey": false,
2801
+ "notNull": true
2802
+ },
2803
+ "value": {
2804
+ "name": "value",
2805
+ "type": "jsonb",
2806
+ "primaryKey": false,
2807
+ "notNull": true
2808
+ },
2809
+ "updated_by": {
2810
+ "name": "updated_by",
2811
+ "type": "uuid",
2812
+ "primaryKey": false,
2813
+ "notNull": false
2814
+ },
2815
+ "updated_at": {
2816
+ "name": "updated_at",
2817
+ "type": "timestamp with time zone",
2818
+ "primaryKey": false,
2819
+ "notNull": true,
2820
+ "default": "now()"
2821
+ }
2822
+ },
2823
+ "indexes": {
2824
+ "job_field_values_job": {
2825
+ "name": "job_field_values_job",
2826
+ "columns": [
2827
+ {
2828
+ "expression": "organisation_id",
2829
+ "isExpression": false,
2830
+ "asc": true,
2831
+ "nulls": "last"
2832
+ },
2833
+ {
2834
+ "expression": "source_system",
2835
+ "isExpression": false,
2836
+ "asc": true,
2837
+ "nulls": "last"
2838
+ },
2839
+ {
2840
+ "expression": "source_job_ref",
2841
+ "isExpression": false,
2842
+ "asc": true,
2843
+ "nulls": "last"
2844
+ }
2845
+ ],
2846
+ "isUnique": false,
2847
+ "concurrently": false,
2848
+ "method": "btree",
2849
+ "with": {}
2850
+ }
2851
+ },
2852
+ "foreignKeys": {
2853
+ "job_field_values_organisation_id_organisations_id_fk": {
2854
+ "name": "job_field_values_organisation_id_organisations_id_fk",
2855
+ "tableFrom": "job_field_values",
2856
+ "tableTo": "organisations",
2857
+ "columnsFrom": [
2858
+ "organisation_id"
2859
+ ],
2860
+ "columnsTo": [
2861
+ "id"
2862
+ ],
2863
+ "onDelete": "no action",
2864
+ "onUpdate": "no action"
2865
+ },
2866
+ "job_field_values_updated_by_people_id_fk": {
2867
+ "name": "job_field_values_updated_by_people_id_fk",
2868
+ "tableFrom": "job_field_values",
2869
+ "tableTo": "people",
2870
+ "columnsFrom": [
2871
+ "updated_by"
2872
+ ],
2873
+ "columnsTo": [
2874
+ "id"
2875
+ ],
2876
+ "onDelete": "set null",
2877
+ "onUpdate": "no action"
2878
+ },
2879
+ "job_field_values_field_same_org": {
2880
+ "name": "job_field_values_field_same_org",
2881
+ "tableFrom": "job_field_values",
2882
+ "tableTo": "job_fields",
2883
+ "columnsFrom": [
2884
+ "organisation_id",
2885
+ "field_id"
2886
+ ],
2887
+ "columnsTo": [
2888
+ "organisation_id",
2889
+ "id"
2890
+ ],
2891
+ "onDelete": "cascade",
2892
+ "onUpdate": "no action"
2893
+ }
2894
+ },
2895
+ "compositePrimaryKeys": {
2896
+ "job_field_values_organisation_id_field_id_source_system_source_job_ref_pk": {
2897
+ "name": "job_field_values_organisation_id_field_id_source_system_source_job_ref_pk",
2898
+ "columns": [
2899
+ "organisation_id",
2900
+ "field_id",
2901
+ "source_system",
2902
+ "source_job_ref"
2903
+ ]
2904
+ }
2905
+ },
2906
+ "uniqueConstraints": {},
2907
+ "policies": {},
2908
+ "checkConstraints": {},
2909
+ "isRLSEnabled": false
2910
+ },
2911
+ "public.job_fields": {
2912
+ "name": "job_fields",
2913
+ "schema": "",
2914
+ "columns": {
2915
+ "id": {
2916
+ "name": "id",
2917
+ "type": "uuid",
2918
+ "primaryKey": true,
2919
+ "notNull": true,
2920
+ "default": "gen_random_uuid()"
2921
+ },
2922
+ "organisation_id": {
2923
+ "name": "organisation_id",
2924
+ "type": "uuid",
2925
+ "primaryKey": false,
2926
+ "notNull": true
2927
+ },
2928
+ "name": {
2929
+ "name": "name",
2930
+ "type": "text",
2931
+ "primaryKey": false,
2932
+ "notNull": true
2933
+ },
2934
+ "type": {
2935
+ "name": "type",
2936
+ "type": "text",
2937
+ "primaryKey": false,
2938
+ "notNull": true
2939
+ },
2940
+ "options": {
2941
+ "name": "options",
2942
+ "type": "jsonb",
2943
+ "primaryKey": false,
2944
+ "notNull": true,
2945
+ "default": "'[]'::jsonb"
2946
+ },
2947
+ "color": {
2948
+ "name": "color",
2949
+ "type": "text",
2950
+ "primaryKey": false,
2951
+ "notNull": false
2952
+ },
2953
+ "position": {
2954
+ "name": "position",
2955
+ "type": "integer",
2956
+ "primaryKey": false,
2957
+ "notNull": true
2958
+ },
2959
+ "archived_at": {
2960
+ "name": "archived_at",
2961
+ "type": "timestamp with time zone",
2962
+ "primaryKey": false,
2963
+ "notNull": false
2964
+ },
2965
+ "created_by": {
2966
+ "name": "created_by",
2967
+ "type": "uuid",
2968
+ "primaryKey": false,
2969
+ "notNull": false
2970
+ },
2971
+ "updated_by": {
2972
+ "name": "updated_by",
2973
+ "type": "uuid",
2974
+ "primaryKey": false,
2975
+ "notNull": false
2976
+ },
2977
+ "created_at": {
2978
+ "name": "created_at",
2979
+ "type": "timestamp with time zone",
2980
+ "primaryKey": false,
2981
+ "notNull": true,
2982
+ "default": "now()"
2983
+ },
2984
+ "updated_at": {
2985
+ "name": "updated_at",
2986
+ "type": "timestamp with time zone",
2987
+ "primaryKey": false,
2988
+ "notNull": true,
2989
+ "default": "now()"
2990
+ }
2991
+ },
2992
+ "indexes": {},
2993
+ "foreignKeys": {
2994
+ "job_fields_organisation_id_organisations_id_fk": {
2995
+ "name": "job_fields_organisation_id_organisations_id_fk",
2996
+ "tableFrom": "job_fields",
2997
+ "tableTo": "organisations",
2998
+ "columnsFrom": [
2999
+ "organisation_id"
3000
+ ],
3001
+ "columnsTo": [
3002
+ "id"
3003
+ ],
3004
+ "onDelete": "no action",
3005
+ "onUpdate": "no action"
3006
+ },
3007
+ "job_fields_created_by_people_id_fk": {
3008
+ "name": "job_fields_created_by_people_id_fk",
3009
+ "tableFrom": "job_fields",
3010
+ "tableTo": "people",
3011
+ "columnsFrom": [
3012
+ "created_by"
3013
+ ],
3014
+ "columnsTo": [
3015
+ "id"
3016
+ ],
3017
+ "onDelete": "set null",
3018
+ "onUpdate": "no action"
3019
+ },
3020
+ "job_fields_updated_by_people_id_fk": {
3021
+ "name": "job_fields_updated_by_people_id_fk",
3022
+ "tableFrom": "job_fields",
3023
+ "tableTo": "people",
3024
+ "columnsFrom": [
3025
+ "updated_by"
3026
+ ],
3027
+ "columnsTo": [
3028
+ "id"
3029
+ ],
3030
+ "onDelete": "set null",
3031
+ "onUpdate": "no action"
3032
+ }
3033
+ },
3034
+ "compositePrimaryKeys": {},
3035
+ "uniqueConstraints": {
3036
+ "job_fields_org_id": {
3037
+ "name": "job_fields_org_id",
3038
+ "nullsNotDistinct": false,
3039
+ "columns": [
3040
+ "organisation_id",
3041
+ "id"
3042
+ ]
3043
+ }
3044
+ },
3045
+ "policies": {},
3046
+ "checkConstraints": {
3047
+ "job_fields_type_valid": {
3048
+ "name": "job_fields_type_valid",
3049
+ "value": "\"job_fields\".\"type\" in ('dropdown', 'person', 'checkbox', 'date', 'number', 'text')"
3050
+ },
3051
+ "job_fields_name_valid": {
3052
+ "name": "job_fields_name_valid",
3053
+ "value": "length(\"job_fields\".\"name\") between 1 and 60"
3054
+ },
3055
+ "job_fields_color_valid": {
3056
+ "name": "job_fields_color_valid",
3057
+ "value": "\"job_fields\".\"color\" is null or \"job_fields\".\"color\" in ('gray', 'blue', 'teal', 'green', 'amber', 'red', 'purple', 'pink')"
3058
+ }
3059
+ },
3060
+ "isRLSEnabled": false
3061
+ },
3062
+ "public.line_mappings": {
3063
+ "name": "line_mappings",
3064
+ "schema": "",
3065
+ "columns": {
3066
+ "id": {
3067
+ "name": "id",
3068
+ "type": "uuid",
3069
+ "primaryKey": true,
3070
+ "notNull": true,
3071
+ "default": "gen_random_uuid()"
3072
+ },
3073
+ "organisation_id": {
3074
+ "name": "organisation_id",
3075
+ "type": "uuid",
3076
+ "primaryKey": false,
3077
+ "notNull": true
3078
+ },
3079
+ "kind": {
3080
+ "name": "kind",
3081
+ "type": "text",
3082
+ "primaryKey": false,
3083
+ "notNull": true
3084
+ },
3085
+ "match": {
3086
+ "name": "match",
3087
+ "type": "text",
3088
+ "primaryKey": false,
3089
+ "notNull": true,
3090
+ "default": "'exact'"
3091
+ },
3092
+ "label": {
3093
+ "name": "label",
3094
+ "type": "text",
3095
+ "primaryKey": false,
3096
+ "notNull": true
3097
+ },
3098
+ "unit_amount_cents": {
3099
+ "name": "unit_amount_cents",
3100
+ "type": "integer",
3101
+ "primaryKey": false,
3102
+ "notNull": false
3103
+ },
3104
+ "item_code": {
3105
+ "name": "item_code",
3106
+ "type": "text",
3107
+ "primaryKey": false,
3108
+ "notNull": false
3109
+ },
3110
+ "account_code": {
3111
+ "name": "account_code",
3112
+ "type": "text",
3113
+ "primaryKey": false,
3114
+ "notNull": false
3115
+ },
3116
+ "tax_code": {
3117
+ "name": "tax_code",
3118
+ "type": "text",
3119
+ "primaryKey": false,
3120
+ "notNull": false
3121
+ },
3122
+ "description": {
3123
+ "name": "description",
3124
+ "type": "text",
3125
+ "primaryKey": false,
3126
+ "notNull": false
3127
+ },
3128
+ "enabled": {
3129
+ "name": "enabled",
3130
+ "type": "boolean",
3131
+ "primaryKey": false,
3132
+ "notNull": true,
3133
+ "default": true
3134
+ },
3135
+ "origin": {
3136
+ "name": "origin",
3137
+ "type": "text",
3138
+ "primaryKey": false,
3139
+ "notNull": true,
3140
+ "default": "'person'"
3141
+ },
3142
+ "updated_by": {
3143
+ "name": "updated_by",
3144
+ "type": "uuid",
3145
+ "primaryKey": false,
3146
+ "notNull": false
3147
+ },
3148
+ "created_at": {
3149
+ "name": "created_at",
3150
+ "type": "timestamp with time zone",
3151
+ "primaryKey": false,
3152
+ "notNull": true,
3153
+ "default": "now()"
3154
+ },
3155
+ "updated_at": {
3156
+ "name": "updated_at",
3157
+ "type": "timestamp with time zone",
3158
+ "primaryKey": false,
3159
+ "notNull": true,
3160
+ "default": "now()"
3161
+ }
3162
+ },
3163
+ "indexes": {
3164
+ "line_mappings_unique": {
3165
+ "name": "line_mappings_unique",
3166
+ "columns": [
3167
+ {
3168
+ "expression": "organisation_id",
3169
+ "isExpression": false,
3170
+ "asc": true,
3171
+ "nulls": "last"
3172
+ },
3173
+ {
3174
+ "expression": "kind",
3175
+ "isExpression": false,
3176
+ "asc": true,
3177
+ "nulls": "last"
3178
+ },
3179
+ {
3180
+ "expression": "match",
3181
+ "isExpression": false,
3182
+ "asc": true,
3183
+ "nulls": "last"
3184
+ },
3185
+ {
3186
+ "expression": "label",
3187
+ "isExpression": false,
3188
+ "asc": true,
3189
+ "nulls": "last"
3190
+ },
3191
+ {
3192
+ "expression": "coalesce(\"unit_amount_cents\", -1)",
3193
+ "asc": true,
3194
+ "isExpression": true,
3195
+ "nulls": "last"
3196
+ }
3197
+ ],
3198
+ "isUnique": true,
3199
+ "concurrently": false,
3200
+ "method": "btree",
3201
+ "with": {}
3202
+ }
3203
+ },
3204
+ "foreignKeys": {
3205
+ "line_mappings_organisation_id_organisations_id_fk": {
3206
+ "name": "line_mappings_organisation_id_organisations_id_fk",
3207
+ "tableFrom": "line_mappings",
3208
+ "tableTo": "organisations",
3209
+ "columnsFrom": [
3210
+ "organisation_id"
3211
+ ],
3212
+ "columnsTo": [
3213
+ "id"
3214
+ ],
3215
+ "onDelete": "no action",
3216
+ "onUpdate": "no action"
3217
+ },
3218
+ "line_mappings_updated_by_people_id_fk": {
3219
+ "name": "line_mappings_updated_by_people_id_fk",
3220
+ "tableFrom": "line_mappings",
3221
+ "tableTo": "people",
3222
+ "columnsFrom": [
3223
+ "updated_by"
3224
+ ],
3225
+ "columnsTo": [
3226
+ "id"
3227
+ ],
3228
+ "onDelete": "set null",
3229
+ "onUpdate": "no action"
3230
+ }
3231
+ },
3232
+ "compositePrimaryKeys": {},
3233
+ "uniqueConstraints": {},
3234
+ "policies": {},
3235
+ "checkConstraints": {
3236
+ "line_mappings_kind_valid": {
3237
+ "name": "line_mappings_kind_valid",
3238
+ "value": "\"line_mappings\".\"kind\" in ('alias', 'price_alias', 'saved', 'account')"
3239
+ },
3240
+ "line_mappings_match_valid": {
3241
+ "name": "line_mappings_match_valid",
3242
+ "value": "\"line_mappings\".\"match\" in ('exact', 'starts_with')"
3243
+ },
3244
+ "line_mappings_tax_code_valid": {
3245
+ "name": "line_mappings_tax_code_valid",
3246
+ "value": "\"line_mappings\".\"tax_code\" is null or \"line_mappings\".\"tax_code\" in ('GST', 'GST_FREE')"
3247
+ },
3248
+ "line_mappings_target": {
3249
+ "name": "line_mappings_target",
3250
+ "value": "(\"line_mappings\".\"kind\" = 'account' and \"line_mappings\".\"account_code\" is not null) or (\"line_mappings\".\"kind\" <> 'account' and \"line_mappings\".\"item_code\" is not null)"
3251
+ },
3252
+ "line_mappings_price": {
3253
+ "name": "line_mappings_price",
3254
+ "value": "\"line_mappings\".\"kind\" not in ('price_alias', 'saved') or \"line_mappings\".\"unit_amount_cents\" is not null"
3255
+ },
3256
+ "line_mappings_label_valid": {
3257
+ "name": "line_mappings_label_valid",
3258
+ "value": "length(\"line_mappings\".\"label\") between 1 and 200"
3259
+ }
3260
+ },
3261
+ "isRLSEnabled": false
3262
+ },
3263
+ "public.link_rejections": {
3264
+ "name": "link_rejections",
3265
+ "schema": "",
3266
+ "columns": {
3267
+ "organisation_id": {
3268
+ "name": "organisation_id",
3269
+ "type": "uuid",
3270
+ "primaryKey": false,
3271
+ "notNull": true
3272
+ },
3273
+ "obligation_id": {
3274
+ "name": "obligation_id",
3275
+ "type": "uuid",
3276
+ "primaryKey": false,
3277
+ "notNull": true
3278
+ },
3279
+ "system": {
3280
+ "name": "system",
3281
+ "type": "text",
3282
+ "primaryKey": false,
3283
+ "notNull": true
3284
+ },
3285
+ "external_id": {
3286
+ "name": "external_id",
3287
+ "type": "text",
3288
+ "primaryKey": false,
3289
+ "notNull": true
3290
+ },
3291
+ "actor": {
3292
+ "name": "actor",
3293
+ "type": "text",
3294
+ "primaryKey": false,
3295
+ "notNull": true
3296
+ },
3297
+ "created_at": {
3298
+ "name": "created_at",
3299
+ "type": "timestamp with time zone",
3300
+ "primaryKey": false,
3301
+ "notNull": true,
3302
+ "default": "now()"
3303
+ }
3304
+ },
3305
+ "indexes": {},
3306
+ "foreignKeys": {
3307
+ "link_rejections_organisation_id_organisations_id_fk": {
3308
+ "name": "link_rejections_organisation_id_organisations_id_fk",
3309
+ "tableFrom": "link_rejections",
3310
+ "tableTo": "organisations",
3311
+ "columnsFrom": [
3312
+ "organisation_id"
3313
+ ],
3314
+ "columnsTo": [
3315
+ "id"
3316
+ ],
3317
+ "onDelete": "no action",
3318
+ "onUpdate": "no action"
3319
+ },
3320
+ "link_rejections_obligation_same_org": {
3321
+ "name": "link_rejections_obligation_same_org",
3322
+ "tableFrom": "link_rejections",
3323
+ "tableTo": "billing_obligations",
3324
+ "columnsFrom": [
3325
+ "organisation_id",
3326
+ "obligation_id"
3327
+ ],
3328
+ "columnsTo": [
3329
+ "organisation_id",
3330
+ "id"
3331
+ ],
3332
+ "onDelete": "no action",
3333
+ "onUpdate": "no action"
3334
+ }
3335
+ },
3336
+ "compositePrimaryKeys": {
3337
+ "link_rejections_pk": {
3338
+ "name": "link_rejections_pk",
3339
+ "columns": [
3340
+ "organisation_id",
3341
+ "obligation_id",
3342
+ "system",
3343
+ "external_id"
3344
+ ]
3345
+ }
3346
+ },
3347
+ "uniqueConstraints": {},
3348
+ "policies": {},
3349
+ "checkConstraints": {},
3350
+ "isRLSEnabled": false
3351
+ },
3352
+ "public.link_suggestions": {
3353
+ "name": "link_suggestions",
3354
+ "schema": "",
3355
+ "columns": {
3356
+ "id": {
3357
+ "name": "id",
3358
+ "type": "uuid",
3359
+ "primaryKey": true,
3360
+ "notNull": true,
3361
+ "default": "gen_random_uuid()"
3362
+ },
3363
+ "organisation_id": {
3364
+ "name": "organisation_id",
3365
+ "type": "uuid",
3366
+ "primaryKey": false,
3367
+ "notNull": true
3368
+ },
3369
+ "obligation_id": {
3370
+ "name": "obligation_id",
3371
+ "type": "uuid",
3372
+ "primaryKey": false,
3373
+ "notNull": true
3374
+ },
3375
+ "system": {
3376
+ "name": "system",
3377
+ "type": "text",
3378
+ "primaryKey": false,
3379
+ "notNull": true
3380
+ },
3381
+ "external_id": {
3382
+ "name": "external_id",
3383
+ "type": "text",
3384
+ "primaryKey": false,
3385
+ "notNull": true
3386
+ },
3387
+ "external_number": {
3388
+ "name": "external_number",
3389
+ "type": "text",
3390
+ "primaryKey": false,
3391
+ "notNull": false
3392
+ },
3393
+ "score": {
3394
+ "name": "score",
3395
+ "type": "integer",
3396
+ "primaryKey": false,
3397
+ "notNull": true
3398
+ },
3399
+ "rank": {
3400
+ "name": "rank",
3401
+ "type": "integer",
3402
+ "primaryKey": false,
3403
+ "notNull": true
3404
+ },
3405
+ "signals": {
3406
+ "name": "signals",
3407
+ "type": "jsonb",
3408
+ "primaryKey": false,
3409
+ "notNull": true,
3410
+ "default": "'[]'::jsonb"
3411
+ },
3412
+ "state": {
3413
+ "name": "state",
3414
+ "type": "text",
3415
+ "primaryKey": false,
3416
+ "notNull": true,
3417
+ "default": "'open'"
3418
+ },
3419
+ "decided_by": {
3420
+ "name": "decided_by",
3421
+ "type": "text",
3422
+ "primaryKey": false,
3423
+ "notNull": false
3424
+ },
3425
+ "decided_at": {
3426
+ "name": "decided_at",
3427
+ "type": "timestamp with time zone",
3428
+ "primaryKey": false,
3429
+ "notNull": false
3430
+ },
3431
+ "created_at": {
3432
+ "name": "created_at",
3433
+ "type": "timestamp with time zone",
3434
+ "primaryKey": false,
3435
+ "notNull": true,
3436
+ "default": "now()"
3437
+ },
3438
+ "updated_at": {
3439
+ "name": "updated_at",
3440
+ "type": "timestamp with time zone",
3441
+ "primaryKey": false,
3442
+ "notNull": true,
3443
+ "default": "now()"
3444
+ }
3445
+ },
3446
+ "indexes": {
3447
+ "link_suggestions_open": {
3448
+ "name": "link_suggestions_open",
3449
+ "columns": [
3450
+ {
3451
+ "expression": "organisation_id",
3452
+ "isExpression": false,
3453
+ "asc": true,
3454
+ "nulls": "last"
3455
+ },
3456
+ {
3457
+ "expression": "state",
3458
+ "isExpression": false,
3459
+ "asc": true,
3460
+ "nulls": "last"
3461
+ },
3462
+ {
3463
+ "expression": "obligation_id",
3464
+ "isExpression": false,
3465
+ "asc": true,
3466
+ "nulls": "last"
3467
+ }
3468
+ ],
3469
+ "isUnique": false,
3470
+ "concurrently": false,
3471
+ "method": "btree",
3472
+ "with": {}
3473
+ }
3474
+ },
3475
+ "foreignKeys": {
3476
+ "link_suggestions_organisation_id_organisations_id_fk": {
3477
+ "name": "link_suggestions_organisation_id_organisations_id_fk",
3478
+ "tableFrom": "link_suggestions",
3479
+ "tableTo": "organisations",
3480
+ "columnsFrom": [
3481
+ "organisation_id"
3482
+ ],
3483
+ "columnsTo": [
3484
+ "id"
3485
+ ],
3486
+ "onDelete": "no action",
3487
+ "onUpdate": "no action"
3488
+ },
3489
+ "link_suggestions_obligation_same_org": {
3490
+ "name": "link_suggestions_obligation_same_org",
3491
+ "tableFrom": "link_suggestions",
3492
+ "tableTo": "billing_obligations",
3493
+ "columnsFrom": [
3494
+ "organisation_id",
3495
+ "obligation_id"
3496
+ ],
3497
+ "columnsTo": [
3498
+ "organisation_id",
3499
+ "id"
3500
+ ],
3501
+ "onDelete": "no action",
3502
+ "onUpdate": "no action"
3503
+ }
3504
+ },
3505
+ "compositePrimaryKeys": {},
3506
+ "uniqueConstraints": {
3507
+ "link_suggestions_pair": {
3508
+ "name": "link_suggestions_pair",
3509
+ "nullsNotDistinct": false,
3510
+ "columns": [
3511
+ "organisation_id",
3512
+ "obligation_id",
3513
+ "system",
3514
+ "external_id"
3515
+ ]
3516
+ }
3517
+ },
3518
+ "policies": {},
3519
+ "checkConstraints": {
3520
+ "link_suggestions_state_valid": {
3521
+ "name": "link_suggestions_state_valid",
3522
+ "value": "state in ('open', 'accepted', 'rejected', 'stale')"
3523
+ }
3524
+ },
3525
+ "isRLSEnabled": false
3526
+ },
3527
+ "public.obligation_events": {
3528
+ "name": "obligation_events",
3529
+ "schema": "",
3530
+ "columns": {
3531
+ "id": {
3532
+ "name": "id",
3533
+ "type": "uuid",
3534
+ "primaryKey": true,
3535
+ "notNull": true,
3536
+ "default": "gen_random_uuid()"
3537
+ },
3538
+ "organisation_id": {
3539
+ "name": "organisation_id",
3540
+ "type": "uuid",
3541
+ "primaryKey": false,
3542
+ "notNull": true
3543
+ },
3544
+ "obligation_id": {
3545
+ "name": "obligation_id",
3546
+ "type": "uuid",
3547
+ "primaryKey": false,
3548
+ "notNull": true
3549
+ },
3550
+ "kind": {
3551
+ "name": "kind",
3552
+ "type": "text",
3553
+ "primaryKey": false,
3554
+ "notNull": true
3555
+ },
3556
+ "actor": {
3557
+ "name": "actor",
3558
+ "type": "text",
3559
+ "primaryKey": false,
3560
+ "notNull": true
3561
+ },
3562
+ "evidence": {
3563
+ "name": "evidence",
3564
+ "type": "jsonb",
3565
+ "primaryKey": false,
3566
+ "notNull": true,
3567
+ "default": "'{}'::jsonb"
3568
+ },
3569
+ "created_at": {
3570
+ "name": "created_at",
3571
+ "type": "timestamp with time zone",
3572
+ "primaryKey": false,
3573
+ "notNull": true,
3574
+ "default": "now()"
3575
+ }
3576
+ },
3577
+ "indexes": {},
3578
+ "foreignKeys": {
3579
+ "obligation_events_obligation_same_org": {
3580
+ "name": "obligation_events_obligation_same_org",
3581
+ "tableFrom": "obligation_events",
3582
+ "tableTo": "billing_obligations",
3583
+ "columnsFrom": [
3584
+ "organisation_id",
3585
+ "obligation_id"
3586
+ ],
3587
+ "columnsTo": [
3588
+ "organisation_id",
3589
+ "id"
3590
+ ],
3591
+ "onDelete": "no action",
3592
+ "onUpdate": "no action"
3593
+ }
3594
+ },
3595
+ "compositePrimaryKeys": {},
3596
+ "uniqueConstraints": {},
3597
+ "policies": {},
3598
+ "checkConstraints": {},
3599
+ "isRLSEnabled": false
3600
+ },
3601
+ "public.obligation_payments": {
3602
+ "name": "obligation_payments",
3603
+ "schema": "",
3604
+ "columns": {
3605
+ "id": {
3606
+ "name": "id",
3607
+ "type": "uuid",
3608
+ "primaryKey": true,
3609
+ "notNull": true,
3610
+ "default": "gen_random_uuid()"
3611
+ },
3612
+ "organisation_id": {
3613
+ "name": "organisation_id",
3614
+ "type": "uuid",
3615
+ "primaryKey": false,
3616
+ "notNull": true
3617
+ },
3618
+ "obligation_id": {
3619
+ "name": "obligation_id",
3620
+ "type": "uuid",
3621
+ "primaryKey": false,
3622
+ "notNull": true
3623
+ },
3624
+ "payment_ref": {
3625
+ "name": "payment_ref",
3626
+ "type": "text",
3627
+ "primaryKey": false,
3628
+ "notNull": true
3629
+ },
3630
+ "paid_on": {
3631
+ "name": "paid_on",
3632
+ "type": "date",
3633
+ "primaryKey": false,
3634
+ "notNull": true
3635
+ },
3636
+ "amount_cents": {
3637
+ "name": "amount_cents",
3638
+ "type": "integer",
3639
+ "primaryKey": false,
3640
+ "notNull": true
3641
+ },
3642
+ "reference": {
3643
+ "name": "reference",
3644
+ "type": "text",
3645
+ "primaryKey": false,
3646
+ "notNull": false
3647
+ },
3648
+ "reconciled": {
3649
+ "name": "reconciled",
3650
+ "type": "boolean",
3651
+ "primaryKey": false,
3652
+ "notNull": true
3653
+ },
3654
+ "accounting_url": {
3655
+ "name": "accounting_url",
3656
+ "type": "text",
3657
+ "primaryKey": false,
3658
+ "notNull": false
3659
+ },
3660
+ "observed_at": {
3661
+ "name": "observed_at",
3662
+ "type": "timestamp with time zone",
3663
+ "primaryKey": false,
3664
+ "notNull": true,
3665
+ "default": "now()"
3666
+ }
3667
+ },
3668
+ "indexes": {},
3669
+ "foreignKeys": {
3670
+ "obligation_payments_obligation_same_org": {
3671
+ "name": "obligation_payments_obligation_same_org",
3672
+ "tableFrom": "obligation_payments",
3673
+ "tableTo": "billing_obligations",
3674
+ "columnsFrom": [
3675
+ "organisation_id",
3676
+ "obligation_id"
3677
+ ],
3678
+ "columnsTo": [
3679
+ "organisation_id",
3680
+ "id"
3681
+ ],
3682
+ "onDelete": "no action",
3683
+ "onUpdate": "no action"
3684
+ }
3685
+ },
3686
+ "compositePrimaryKeys": {},
3687
+ "uniqueConstraints": {
3688
+ "obligation_payments_ref": {
3689
+ "name": "obligation_payments_ref",
3690
+ "nullsNotDistinct": false,
3691
+ "columns": [
3692
+ "organisation_id",
3693
+ "obligation_id",
3694
+ "payment_ref"
3695
+ ]
3696
+ }
3697
+ },
3698
+ "policies": {},
3699
+ "checkConstraints": {
3700
+ "obligation_payments_amount_positive": {
3701
+ "name": "obligation_payments_amount_positive",
3702
+ "value": "\"obligation_payments\".\"amount_cents\" > 0"
3703
+ }
3704
+ },
3705
+ "isRLSEnabled": false
3706
+ },
3707
+ "public.obligation_writebacks": {
3708
+ "name": "obligation_writebacks",
3709
+ "schema": "",
3710
+ "columns": {
3711
+ "id": {
3712
+ "name": "id",
3713
+ "type": "uuid",
3714
+ "primaryKey": true,
3715
+ "notNull": true,
3716
+ "default": "gen_random_uuid()"
3717
+ },
3718
+ "organisation_id": {
3719
+ "name": "organisation_id",
3720
+ "type": "uuid",
3721
+ "primaryKey": false,
3722
+ "notNull": true
3723
+ },
3724
+ "obligation_id": {
3725
+ "name": "obligation_id",
3726
+ "type": "uuid",
3727
+ "primaryKey": false,
3728
+ "notNull": true
3729
+ },
3730
+ "target_system": {
3731
+ "name": "target_system",
3732
+ "type": "text",
3733
+ "primaryKey": false,
3734
+ "notNull": true
3735
+ },
3736
+ "status": {
3737
+ "name": "status",
3738
+ "type": "text",
3739
+ "primaryKey": false,
3740
+ "notNull": true
3741
+ },
3742
+ "state": {
3743
+ "name": "state",
3744
+ "type": "text",
3745
+ "primaryKey": false,
3746
+ "notNull": true,
3747
+ "default": "'pending'"
3748
+ },
3749
+ "evidence": {
3750
+ "name": "evidence",
3751
+ "type": "jsonb",
3752
+ "primaryKey": false,
3753
+ "notNull": true
3754
+ },
3755
+ "attempts": {
3756
+ "name": "attempts",
3757
+ "type": "integer",
3758
+ "primaryKey": false,
3759
+ "notNull": true,
3760
+ "default": 0
3761
+ },
3762
+ "last_error": {
3763
+ "name": "last_error",
3764
+ "type": "text",
3765
+ "primaryKey": false,
3766
+ "notNull": false
3767
+ },
3768
+ "sent_at": {
3769
+ "name": "sent_at",
3770
+ "type": "timestamp with time zone",
3771
+ "primaryKey": false,
3772
+ "notNull": false
3773
+ },
3774
+ "created_at": {
3775
+ "name": "created_at",
3776
+ "type": "timestamp with time zone",
3777
+ "primaryKey": false,
3778
+ "notNull": true,
3779
+ "default": "now()"
3780
+ },
3781
+ "updated_at": {
3782
+ "name": "updated_at",
3783
+ "type": "timestamp with time zone",
3784
+ "primaryKey": false,
3785
+ "notNull": true,
3786
+ "default": "now()"
3787
+ }
3788
+ },
3789
+ "indexes": {},
3790
+ "foreignKeys": {
3791
+ "obligation_writebacks_obligation_same_org": {
3792
+ "name": "obligation_writebacks_obligation_same_org",
3793
+ "tableFrom": "obligation_writebacks",
3794
+ "tableTo": "billing_obligations",
3795
+ "columnsFrom": [
3796
+ "organisation_id",
3797
+ "obligation_id"
3798
+ ],
3799
+ "columnsTo": [
3800
+ "organisation_id",
3801
+ "id"
3802
+ ],
3803
+ "onDelete": "no action",
3804
+ "onUpdate": "no action"
3805
+ }
3806
+ },
3807
+ "compositePrimaryKeys": {},
3808
+ "uniqueConstraints": {
3809
+ "obligation_writebacks_status": {
3810
+ "name": "obligation_writebacks_status",
3811
+ "nullsNotDistinct": false,
3812
+ "columns": [
3813
+ "organisation_id",
3814
+ "obligation_id",
3815
+ "status"
3816
+ ]
3817
+ }
3818
+ },
3819
+ "policies": {},
3820
+ "checkConstraints": {
3821
+ "obligation_writebacks_state_valid": {
3822
+ "name": "obligation_writebacks_state_valid",
3823
+ "value": "state in ('pending', 'sent', 'failed', 'not_supported')"
3824
+ }
3825
+ },
3826
+ "isRLSEnabled": false
3827
+ },
3828
+ "public.organisations": {
3829
+ "name": "organisations",
3830
+ "schema": "",
3831
+ "columns": {
3832
+ "id": {
3833
+ "name": "id",
3834
+ "type": "uuid",
3835
+ "primaryKey": true,
3836
+ "notNull": true,
3837
+ "default": "gen_random_uuid()"
3838
+ },
3839
+ "name": {
3840
+ "name": "name",
3841
+ "type": "text",
3842
+ "primaryKey": false,
3843
+ "notNull": true
3844
+ },
3845
+ "invoice_prefix": {
3846
+ "name": "invoice_prefix",
3847
+ "type": "text",
3848
+ "primaryKey": false,
3849
+ "notNull": true,
3850
+ "default": "'INV-'"
3851
+ },
3852
+ "next_invoice_number": {
3853
+ "name": "next_invoice_number",
3854
+ "type": "integer",
3855
+ "primaryKey": false,
3856
+ "notNull": true,
3857
+ "default": 1
3858
+ },
3859
+ "created_at": {
3860
+ "name": "created_at",
3861
+ "type": "timestamp with time zone",
3862
+ "primaryKey": false,
3863
+ "notNull": true,
3864
+ "default": "now()"
3865
+ }
3866
+ },
3867
+ "indexes": {},
3868
+ "foreignKeys": {},
3869
+ "compositePrimaryKeys": {},
3870
+ "uniqueConstraints": {},
3871
+ "policies": {},
3872
+ "checkConstraints": {
3873
+ "organisations_next_invoice_number_positive": {
3874
+ "name": "organisations_next_invoice_number_positive",
3875
+ "value": "\"organisations\".\"next_invoice_number\" > 0"
3876
+ }
3877
+ },
3878
+ "isRLSEnabled": false
3879
+ },
3880
+ "public.outbox": {
3881
+ "name": "outbox",
3882
+ "schema": "",
3883
+ "columns": {
3884
+ "id": {
3885
+ "name": "id",
3886
+ "type": "uuid",
3887
+ "primaryKey": true,
3888
+ "notNull": true,
3889
+ "default": "gen_random_uuid()"
3890
+ },
3891
+ "organisation_id": {
3892
+ "name": "organisation_id",
3893
+ "type": "uuid",
3894
+ "primaryKey": false,
3895
+ "notNull": true
3896
+ },
3897
+ "system": {
3898
+ "name": "system",
3899
+ "type": "text",
3900
+ "primaryKey": false,
3901
+ "notNull": true
3902
+ },
3903
+ "action": {
3904
+ "name": "action",
3905
+ "type": "text",
3906
+ "primaryKey": false,
3907
+ "notNull": true
3908
+ },
3909
+ "entity": {
3910
+ "name": "entity",
3911
+ "type": "text",
3912
+ "primaryKey": false,
3913
+ "notNull": true
3914
+ },
3915
+ "flow_id": {
3916
+ "name": "flow_id",
3917
+ "type": "uuid",
3918
+ "primaryKey": false,
3919
+ "notNull": true
3920
+ },
3921
+ "idempotency_key": {
3922
+ "name": "idempotency_key",
3923
+ "type": "text",
3924
+ "primaryKey": false,
3925
+ "notNull": true
3926
+ },
3927
+ "request": {
3928
+ "name": "request",
3929
+ "type": "jsonb",
3930
+ "primaryKey": false,
3931
+ "notNull": true
3932
+ },
3933
+ "state": {
3934
+ "name": "state",
3935
+ "type": "text",
3936
+ "primaryKey": false,
3937
+ "notNull": true,
3938
+ "default": "'pending'"
3939
+ },
3940
+ "external_id": {
3941
+ "name": "external_id",
3942
+ "type": "text",
3943
+ "primaryKey": false,
3944
+ "notNull": false
3945
+ },
3946
+ "attempts": {
3947
+ "name": "attempts",
3948
+ "type": "integer",
3949
+ "primaryKey": false,
3950
+ "notNull": true,
3951
+ "default": 0
3952
+ },
3953
+ "last_error": {
3954
+ "name": "last_error",
3955
+ "type": "text",
3956
+ "primaryKey": false,
3957
+ "notNull": false
3958
+ },
3959
+ "created_by": {
3960
+ "name": "created_by",
3961
+ "type": "text",
3962
+ "primaryKey": false,
3963
+ "notNull": true
3964
+ },
3965
+ "sent_at": {
3966
+ "name": "sent_at",
3967
+ "type": "timestamp with time zone",
3968
+ "primaryKey": false,
3969
+ "notNull": false
3970
+ },
3971
+ "created_at": {
3972
+ "name": "created_at",
3973
+ "type": "timestamp with time zone",
3974
+ "primaryKey": false,
3975
+ "notNull": true,
3976
+ "default": "now()"
3977
+ },
3978
+ "updated_at": {
3979
+ "name": "updated_at",
3980
+ "type": "timestamp with time zone",
3981
+ "primaryKey": false,
3982
+ "notNull": true,
3983
+ "default": "now()"
3984
+ }
3985
+ },
3986
+ "indexes": {
3987
+ "outbox_pending": {
3988
+ "name": "outbox_pending",
3989
+ "columns": [
3990
+ {
3991
+ "expression": "system",
3992
+ "isExpression": false,
3993
+ "asc": true,
3994
+ "nulls": "last"
3995
+ },
3996
+ {
3997
+ "expression": "state",
3998
+ "isExpression": false,
3999
+ "asc": true,
4000
+ "nulls": "last"
4001
+ },
4002
+ {
4003
+ "expression": "created_at",
4004
+ "isExpression": false,
4005
+ "asc": true,
4006
+ "nulls": "last"
4007
+ }
4008
+ ],
4009
+ "isUnique": false,
4010
+ "concurrently": false,
4011
+ "method": "btree",
4012
+ "with": {}
4013
+ }
4014
+ },
4015
+ "foreignKeys": {
4016
+ "outbox_organisation_id_organisations_id_fk": {
4017
+ "name": "outbox_organisation_id_organisations_id_fk",
4018
+ "tableFrom": "outbox",
4019
+ "tableTo": "organisations",
4020
+ "columnsFrom": [
4021
+ "organisation_id"
4022
+ ],
4023
+ "columnsTo": [
4024
+ "id"
4025
+ ],
4026
+ "onDelete": "no action",
4027
+ "onUpdate": "no action"
4028
+ }
4029
+ },
4030
+ "compositePrimaryKeys": {},
4031
+ "uniqueConstraints": {
4032
+ "outbox_org_id": {
4033
+ "name": "outbox_org_id",
4034
+ "nullsNotDistinct": false,
4035
+ "columns": [
4036
+ "organisation_id",
4037
+ "id"
4038
+ ]
4039
+ },
4040
+ "outbox_idempotency_key": {
4041
+ "name": "outbox_idempotency_key",
4042
+ "nullsNotDistinct": false,
4043
+ "columns": [
4044
+ "idempotency_key"
4045
+ ]
4046
+ }
4047
+ },
4048
+ "policies": {},
4049
+ "checkConstraints": {
4050
+ "outbox_state_valid": {
4051
+ "name": "outbox_state_valid",
4052
+ "value": "state in ('pending', 'sending', 'ambiguous', 'sent', 'failed', 'cancelled')"
4053
+ },
4054
+ "outbox_sent_has_id": {
4055
+ "name": "outbox_sent_has_id",
4056
+ "value": "\"outbox\".\"state\" <> 'sent' or \"outbox\".\"external_id\" is not null"
4057
+ }
4058
+ },
4059
+ "isRLSEnabled": false
4060
+ },
4061
+ "public.people": {
4062
+ "name": "people",
4063
+ "schema": "",
4064
+ "columns": {
4065
+ "id": {
4066
+ "name": "id",
4067
+ "type": "uuid",
4068
+ "primaryKey": true,
4069
+ "notNull": true,
4070
+ "default": "gen_random_uuid()"
4071
+ },
4072
+ "email": {
4073
+ "name": "email",
4074
+ "type": "text",
4075
+ "primaryKey": false,
4076
+ "notNull": true
4077
+ },
4078
+ "name": {
4079
+ "name": "name",
4080
+ "type": "text",
4081
+ "primaryKey": false,
4082
+ "notNull": false
4083
+ },
4084
+ "role": {
4085
+ "name": "role",
4086
+ "type": "text",
4087
+ "primaryKey": false,
4088
+ "notNull": true
4089
+ },
4090
+ "status": {
4091
+ "name": "status",
4092
+ "type": "text",
4093
+ "primaryKey": false,
4094
+ "notNull": true,
4095
+ "default": "'active'"
4096
+ },
4097
+ "clerk_user_id": {
4098
+ "name": "clerk_user_id",
4099
+ "type": "text",
4100
+ "primaryKey": false,
4101
+ "notNull": false
4102
+ },
4103
+ "invited_by": {
4104
+ "name": "invited_by",
4105
+ "type": "uuid",
4106
+ "primaryKey": false,
4107
+ "notNull": false
4108
+ },
4109
+ "linked_at": {
4110
+ "name": "linked_at",
4111
+ "type": "timestamp with time zone",
4112
+ "primaryKey": false,
4113
+ "notNull": false
4114
+ },
4115
+ "appearance": {
4116
+ "name": "appearance",
4117
+ "type": "jsonb",
4118
+ "primaryKey": false,
4119
+ "notNull": false
4120
+ },
4121
+ "views": {
4122
+ "name": "views",
4123
+ "type": "jsonb",
4124
+ "primaryKey": false,
4125
+ "notNull": false
4126
+ },
4127
+ "created_at": {
4128
+ "name": "created_at",
4129
+ "type": "timestamp with time zone",
4130
+ "primaryKey": false,
4131
+ "notNull": true,
4132
+ "default": "now()"
4133
+ },
4134
+ "updated_at": {
4135
+ "name": "updated_at",
4136
+ "type": "timestamp with time zone",
4137
+ "primaryKey": false,
4138
+ "notNull": true,
4139
+ "default": "now()"
4140
+ }
4141
+ },
4142
+ "indexes": {},
4143
+ "foreignKeys": {
4144
+ "people_invited_by_people_id_fk": {
4145
+ "name": "people_invited_by_people_id_fk",
4146
+ "tableFrom": "people",
4147
+ "tableTo": "people",
4148
+ "columnsFrom": [
4149
+ "invited_by"
4150
+ ],
4151
+ "columnsTo": [
4152
+ "id"
4153
+ ],
4154
+ "onDelete": "set null",
4155
+ "onUpdate": "no action"
4156
+ }
4157
+ },
4158
+ "compositePrimaryKeys": {},
4159
+ "uniqueConstraints": {
4160
+ "people_email": {
4161
+ "name": "people_email",
4162
+ "nullsNotDistinct": false,
4163
+ "columns": [
4164
+ "email"
4165
+ ]
4166
+ },
4167
+ "people_clerk_user_id": {
4168
+ "name": "people_clerk_user_id",
4169
+ "nullsNotDistinct": false,
4170
+ "columns": [
4171
+ "clerk_user_id"
4172
+ ]
4173
+ }
4174
+ },
4175
+ "policies": {},
4176
+ "checkConstraints": {
4177
+ "people_email_lower": {
4178
+ "name": "people_email_lower",
4179
+ "value": "\"people\".\"email\" = lower(\"people\".\"email\")"
4180
+ },
4181
+ "people_role_valid": {
4182
+ "name": "people_role_valid",
4183
+ "value": "\"people\".\"role\" in ('owner', 'admin', 'staff')"
4184
+ },
4185
+ "people_status_valid": {
4186
+ "name": "people_status_valid",
4187
+ "value": "\"people\".\"status\" in ('active', 'pending', 'disabled')"
4188
+ }
4189
+ },
4190
+ "isRLSEnabled": false
4191
+ },
4192
+ "public.pipeline_cursors": {
4193
+ "name": "pipeline_cursors",
4194
+ "schema": "",
4195
+ "columns": {
4196
+ "organisation_id": {
4197
+ "name": "organisation_id",
4198
+ "type": "uuid",
4199
+ "primaryKey": false,
4200
+ "notNull": true
4201
+ },
4202
+ "name": {
4203
+ "name": "name",
4204
+ "type": "text",
4205
+ "primaryKey": false,
4206
+ "notNull": true
4207
+ },
4208
+ "cursor": {
4209
+ "name": "cursor",
4210
+ "type": "text",
4211
+ "primaryKey": false,
4212
+ "notNull": false
4213
+ },
4214
+ "updated_at": {
4215
+ "name": "updated_at",
4216
+ "type": "timestamp with time zone",
4217
+ "primaryKey": false,
4218
+ "notNull": true,
4219
+ "default": "now()"
4220
+ }
4221
+ },
4222
+ "indexes": {},
4223
+ "foreignKeys": {
4224
+ "pipeline_cursors_organisation_id_organisations_id_fk": {
4225
+ "name": "pipeline_cursors_organisation_id_organisations_id_fk",
4226
+ "tableFrom": "pipeline_cursors",
4227
+ "tableTo": "organisations",
4228
+ "columnsFrom": [
4229
+ "organisation_id"
4230
+ ],
4231
+ "columnsTo": [
4232
+ "id"
4233
+ ],
4234
+ "onDelete": "no action",
4235
+ "onUpdate": "no action"
4236
+ }
4237
+ },
4238
+ "compositePrimaryKeys": {
4239
+ "pipeline_cursors_pk": {
4240
+ "name": "pipeline_cursors_pk",
4241
+ "columns": [
4242
+ "organisation_id",
4243
+ "name"
4244
+ ]
4245
+ }
4246
+ },
4247
+ "uniqueConstraints": {},
4248
+ "policies": {},
4249
+ "checkConstraints": {},
4250
+ "isRLSEnabled": false
4251
+ },
4252
+ "public.price_item_links": {
4253
+ "name": "price_item_links",
4254
+ "schema": "",
4255
+ "columns": {
4256
+ "id": {
4257
+ "name": "id",
4258
+ "type": "uuid",
4259
+ "primaryKey": true,
4260
+ "notNull": true,
4261
+ "default": "gen_random_uuid()"
4262
+ },
4263
+ "organisation_id": {
4264
+ "name": "organisation_id",
4265
+ "type": "uuid",
4266
+ "primaryKey": false,
4267
+ "notNull": true
4268
+ },
4269
+ "price_item_id": {
4270
+ "name": "price_item_id",
4271
+ "type": "uuid",
4272
+ "primaryKey": false,
4273
+ "notNull": true
4274
+ },
4275
+ "system": {
4276
+ "name": "system",
4277
+ "type": "text",
4278
+ "primaryKey": false,
4279
+ "notNull": true
4280
+ },
4281
+ "external_id": {
4282
+ "name": "external_id",
4283
+ "type": "text",
4284
+ "primaryKey": false,
4285
+ "notNull": true
4286
+ },
4287
+ "external_code": {
4288
+ "name": "external_code",
4289
+ "type": "text",
4290
+ "primaryKey": false,
4291
+ "notNull": false
4292
+ },
4293
+ "matched_by": {
4294
+ "name": "matched_by",
4295
+ "type": "text",
4296
+ "primaryKey": false,
4297
+ "notNull": true
4298
+ },
4299
+ "created_by": {
4300
+ "name": "created_by",
4301
+ "type": "uuid",
4302
+ "primaryKey": false,
4303
+ "notNull": false
4304
+ },
4305
+ "created_at": {
4306
+ "name": "created_at",
4307
+ "type": "timestamp with time zone",
4308
+ "primaryKey": false,
4309
+ "notNull": true,
4310
+ "default": "now()"
4311
+ }
4312
+ },
4313
+ "indexes": {
4314
+ "price_item_links_external": {
4315
+ "name": "price_item_links_external",
4316
+ "columns": [
4317
+ {
4318
+ "expression": "organisation_id",
4319
+ "isExpression": false,
4320
+ "asc": true,
4321
+ "nulls": "last"
4322
+ },
4323
+ {
4324
+ "expression": "system",
4325
+ "isExpression": false,
4326
+ "asc": true,
4327
+ "nulls": "last"
4328
+ },
4329
+ {
4330
+ "expression": "external_id",
4331
+ "isExpression": false,
4332
+ "asc": true,
4333
+ "nulls": "last"
4334
+ }
4335
+ ],
4336
+ "isUnique": true,
4337
+ "concurrently": false,
4338
+ "method": "btree",
4339
+ "with": {}
4340
+ }
4341
+ },
4342
+ "foreignKeys": {
4343
+ "price_item_links_organisation_id_organisations_id_fk": {
4344
+ "name": "price_item_links_organisation_id_organisations_id_fk",
4345
+ "tableFrom": "price_item_links",
4346
+ "tableTo": "organisations",
4347
+ "columnsFrom": [
4348
+ "organisation_id"
4349
+ ],
4350
+ "columnsTo": [
4351
+ "id"
4352
+ ],
4353
+ "onDelete": "no action",
4354
+ "onUpdate": "no action"
4355
+ },
4356
+ "price_item_links_created_by_people_id_fk": {
4357
+ "name": "price_item_links_created_by_people_id_fk",
4358
+ "tableFrom": "price_item_links",
4359
+ "tableTo": "people",
4360
+ "columnsFrom": [
4361
+ "created_by"
4362
+ ],
4363
+ "columnsTo": [
4364
+ "id"
4365
+ ],
4366
+ "onDelete": "set null",
4367
+ "onUpdate": "no action"
4368
+ },
4369
+ "price_item_links_item_same_org": {
4370
+ "name": "price_item_links_item_same_org",
4371
+ "tableFrom": "price_item_links",
4372
+ "tableTo": "price_items",
4373
+ "columnsFrom": [
4374
+ "organisation_id",
4375
+ "price_item_id"
4376
+ ],
4377
+ "columnsTo": [
4378
+ "organisation_id",
4379
+ "id"
4380
+ ],
4381
+ "onDelete": "cascade",
4382
+ "onUpdate": "no action"
4383
+ }
4384
+ },
4385
+ "compositePrimaryKeys": {},
4386
+ "uniqueConstraints": {},
4387
+ "policies": {},
4388
+ "checkConstraints": {
4389
+ "price_item_links_matched_by_valid": {
4390
+ "name": "price_item_links_matched_by_valid",
4391
+ "value": "\"price_item_links\".\"matched_by\" in ('code', 'person')"
4392
+ },
4393
+ "price_item_links_system_valid": {
4394
+ "name": "price_item_links_system_valid",
4395
+ "value": "\"price_item_links\".\"system\" ~ '^[a-z][a-z0-9-]{1,31}$'"
4396
+ }
4397
+ },
4398
+ "isRLSEnabled": false
4399
+ },
4400
+ "public.price_items": {
4401
+ "name": "price_items",
4402
+ "schema": "",
4403
+ "columns": {
4404
+ "id": {
4405
+ "name": "id",
4406
+ "type": "uuid",
4407
+ "primaryKey": true,
4408
+ "notNull": true,
4409
+ "default": "gen_random_uuid()"
4410
+ },
4411
+ "organisation_id": {
4412
+ "name": "organisation_id",
4413
+ "type": "uuid",
4414
+ "primaryKey": false,
4415
+ "notNull": true
4416
+ },
4417
+ "code": {
4418
+ "name": "code",
4419
+ "type": "text",
4420
+ "primaryKey": false,
4421
+ "notNull": true
4422
+ },
4423
+ "name": {
4424
+ "name": "name",
4425
+ "type": "text",
4426
+ "primaryKey": false,
4427
+ "notNull": true
4428
+ },
4429
+ "description": {
4430
+ "name": "description",
4431
+ "type": "text",
4432
+ "primaryKey": false,
4433
+ "notNull": false
4434
+ },
4435
+ "unit_amount_cents": {
4436
+ "name": "unit_amount_cents",
4437
+ "type": "integer",
4438
+ "primaryKey": false,
4439
+ "notNull": true
4440
+ },
4441
+ "tax_code": {
4442
+ "name": "tax_code",
4443
+ "type": "text",
4444
+ "primaryKey": false,
4445
+ "notNull": true,
4446
+ "default": "'GST'"
4447
+ },
4448
+ "account_code": {
4449
+ "name": "account_code",
4450
+ "type": "text",
4451
+ "primaryKey": false,
4452
+ "notNull": false
4453
+ },
4454
+ "archived_at": {
4455
+ "name": "archived_at",
4456
+ "type": "timestamp with time zone",
4457
+ "primaryKey": false,
4458
+ "notNull": false
4459
+ },
4460
+ "updated_by": {
4461
+ "name": "updated_by",
4462
+ "type": "uuid",
4463
+ "primaryKey": false,
4464
+ "notNull": false
4465
+ },
4466
+ "created_at": {
4467
+ "name": "created_at",
4468
+ "type": "timestamp with time zone",
4469
+ "primaryKey": false,
4470
+ "notNull": true,
4471
+ "default": "now()"
4472
+ },
4473
+ "updated_at": {
4474
+ "name": "updated_at",
4475
+ "type": "timestamp with time zone",
4476
+ "primaryKey": false,
4477
+ "notNull": true,
4478
+ "default": "now()"
4479
+ }
4480
+ },
4481
+ "indexes": {},
4482
+ "foreignKeys": {
4483
+ "price_items_organisation_id_organisations_id_fk": {
4484
+ "name": "price_items_organisation_id_organisations_id_fk",
4485
+ "tableFrom": "price_items",
4486
+ "tableTo": "organisations",
4487
+ "columnsFrom": [
4488
+ "organisation_id"
4489
+ ],
4490
+ "columnsTo": [
4491
+ "id"
4492
+ ],
4493
+ "onDelete": "no action",
4494
+ "onUpdate": "no action"
4495
+ },
4496
+ "price_items_updated_by_people_id_fk": {
4497
+ "name": "price_items_updated_by_people_id_fk",
4498
+ "tableFrom": "price_items",
4499
+ "tableTo": "people",
4500
+ "columnsFrom": [
4501
+ "updated_by"
4502
+ ],
4503
+ "columnsTo": [
4504
+ "id"
4505
+ ],
4506
+ "onDelete": "set null",
4507
+ "onUpdate": "no action"
4508
+ }
4509
+ },
4510
+ "compositePrimaryKeys": {},
4511
+ "uniqueConstraints": {
4512
+ "price_items_org_id": {
4513
+ "name": "price_items_org_id",
4514
+ "nullsNotDistinct": false,
4515
+ "columns": [
4516
+ "organisation_id",
4517
+ "id"
4518
+ ]
4519
+ },
4520
+ "price_items_org_code": {
4521
+ "name": "price_items_org_code",
4522
+ "nullsNotDistinct": false,
4523
+ "columns": [
4524
+ "organisation_id",
4525
+ "code"
4526
+ ]
4527
+ }
4528
+ },
4529
+ "policies": {},
4530
+ "checkConstraints": {
4531
+ "price_items_tax_code_valid": {
4532
+ "name": "price_items_tax_code_valid",
4533
+ "value": "\"price_items\".\"tax_code\" in ('GST', 'GST_FREE')"
4534
+ }
4535
+ },
4536
+ "isRLSEnabled": false
4537
+ },
4538
+ "public.prior_links": {
4539
+ "name": "prior_links",
4540
+ "schema": "",
4541
+ "columns": {
4542
+ "id": {
4543
+ "name": "id",
4544
+ "type": "uuid",
4545
+ "primaryKey": true,
4546
+ "notNull": true,
4547
+ "default": "gen_random_uuid()"
4548
+ },
4549
+ "organisation_id": {
4550
+ "name": "organisation_id",
4551
+ "type": "uuid",
4552
+ "primaryKey": false,
4553
+ "notNull": true
4554
+ },
4555
+ "source_system": {
4556
+ "name": "source_system",
4557
+ "type": "text",
4558
+ "primaryKey": false,
4559
+ "notNull": true
4560
+ },
4561
+ "source_job_ref": {
4562
+ "name": "source_job_ref",
4563
+ "type": "text",
4564
+ "primaryKey": false,
4565
+ "notNull": true
4566
+ },
4567
+ "system": {
4568
+ "name": "system",
4569
+ "type": "text",
4570
+ "primaryKey": false,
4571
+ "notNull": true
4572
+ },
4573
+ "external_id": {
4574
+ "name": "external_id",
4575
+ "type": "text",
4576
+ "primaryKey": false,
4577
+ "notNull": true
4578
+ },
4579
+ "external_number": {
4580
+ "name": "external_number",
4581
+ "type": "text",
4582
+ "primaryKey": false,
4583
+ "notNull": false
4584
+ },
4585
+ "matched_by": {
4586
+ "name": "matched_by",
4587
+ "type": "text",
4588
+ "primaryKey": false,
4589
+ "notNull": true
4590
+ },
4591
+ "matched_at": {
4592
+ "name": "matched_at",
4593
+ "type": "timestamp with time zone",
4594
+ "primaryKey": false,
4595
+ "notNull": false
4596
+ },
4597
+ "origin": {
4598
+ "name": "origin",
4599
+ "type": "text",
4600
+ "primaryKey": false,
4601
+ "notNull": true
4602
+ },
4603
+ "created_at": {
4604
+ "name": "created_at",
4605
+ "type": "timestamp with time zone",
4606
+ "primaryKey": false,
4607
+ "notNull": true,
4608
+ "default": "now()"
4609
+ }
4610
+ },
4611
+ "indexes": {
4612
+ "prior_links_job": {
4613
+ "name": "prior_links_job",
4614
+ "columns": [
4615
+ {
4616
+ "expression": "organisation_id",
4617
+ "isExpression": false,
4618
+ "asc": true,
4619
+ "nulls": "last"
4620
+ },
4621
+ {
4622
+ "expression": "source_system",
4623
+ "isExpression": false,
4624
+ "asc": true,
4625
+ "nulls": "last"
4626
+ },
4627
+ {
4628
+ "expression": "source_job_ref",
4629
+ "isExpression": false,
4630
+ "asc": true,
4631
+ "nulls": "last"
4632
+ },
4633
+ {
4634
+ "expression": "system",
4635
+ "isExpression": false,
4636
+ "asc": true,
4637
+ "nulls": "last"
4638
+ }
4639
+ ],
4640
+ "isUnique": true,
4641
+ "concurrently": false,
4642
+ "method": "btree",
4643
+ "with": {}
4644
+ },
4645
+ "prior_links_external": {
4646
+ "name": "prior_links_external",
4647
+ "columns": [
4648
+ {
4649
+ "expression": "organisation_id",
4650
+ "isExpression": false,
4651
+ "asc": true,
4652
+ "nulls": "last"
4653
+ },
4654
+ {
4655
+ "expression": "system",
4656
+ "isExpression": false,
4657
+ "asc": true,
4658
+ "nulls": "last"
4659
+ },
4660
+ {
4661
+ "expression": "external_id",
4662
+ "isExpression": false,
4663
+ "asc": true,
4664
+ "nulls": "last"
4665
+ }
4666
+ ],
4667
+ "isUnique": false,
4668
+ "concurrently": false,
4669
+ "method": "btree",
4670
+ "with": {}
4671
+ }
4672
+ },
4673
+ "foreignKeys": {
4674
+ "prior_links_organisation_id_organisations_id_fk": {
4675
+ "name": "prior_links_organisation_id_organisations_id_fk",
4676
+ "tableFrom": "prior_links",
4677
+ "tableTo": "organisations",
4678
+ "columnsFrom": [
4679
+ "organisation_id"
4680
+ ],
4681
+ "columnsTo": [
4682
+ "id"
4683
+ ],
4684
+ "onDelete": "no action",
4685
+ "onUpdate": "no action"
4686
+ }
4687
+ },
4688
+ "compositePrimaryKeys": {},
4689
+ "uniqueConstraints": {},
4690
+ "policies": {},
4691
+ "checkConstraints": {
4692
+ "prior_links_matched_by_valid": {
4693
+ "name": "prior_links_matched_by_valid",
4694
+ "value": "matched_by in ('person', 'imported')"
4695
+ }
4696
+ },
4697
+ "isRLSEnabled": false
4698
+ },
4699
+ "public.review_items": {
4700
+ "name": "review_items",
4701
+ "schema": "",
4702
+ "columns": {
4703
+ "id": {
4704
+ "name": "id",
4705
+ "type": "uuid",
4706
+ "primaryKey": true,
4707
+ "notNull": true,
4708
+ "default": "gen_random_uuid()"
4709
+ },
4710
+ "organisation_id": {
4711
+ "name": "organisation_id",
4712
+ "type": "uuid",
4713
+ "primaryKey": false,
4714
+ "notNull": true
4715
+ },
4716
+ "kind": {
4717
+ "name": "kind",
4718
+ "type": "text",
4719
+ "primaryKey": false,
4720
+ "notNull": true
4721
+ },
4722
+ "entity": {
4723
+ "name": "entity",
4724
+ "type": "text",
4725
+ "primaryKey": false,
4726
+ "notNull": true
4727
+ },
4728
+ "flow_id": {
4729
+ "name": "flow_id",
4730
+ "type": "uuid",
4731
+ "primaryKey": false,
4732
+ "notNull": true
4733
+ },
4734
+ "systems": {
4735
+ "name": "systems",
4736
+ "type": "text[]",
4737
+ "primaryKey": false,
4738
+ "notNull": true,
4739
+ "default": "'{}'::text[]"
4740
+ },
4741
+ "evidence": {
4742
+ "name": "evidence",
4743
+ "type": "jsonb",
4744
+ "primaryKey": false,
4745
+ "notNull": true,
4746
+ "default": "'{}'::jsonb"
4747
+ },
4748
+ "money_at_risk_cents": {
4749
+ "name": "money_at_risk_cents",
4750
+ "type": "bigint",
4751
+ "primaryKey": false,
4752
+ "notNull": true,
4753
+ "default": 0
4754
+ },
4755
+ "state": {
4756
+ "name": "state",
4757
+ "type": "text",
4758
+ "primaryKey": false,
4759
+ "notNull": true,
4760
+ "default": "'open'"
4761
+ },
4762
+ "seen_count": {
4763
+ "name": "seen_count",
4764
+ "type": "integer",
4765
+ "primaryKey": false,
4766
+ "notNull": true,
4767
+ "default": 1
4768
+ },
4769
+ "resolution": {
4770
+ "name": "resolution",
4771
+ "type": "text",
4772
+ "primaryKey": false,
4773
+ "notNull": false
4774
+ },
4775
+ "note": {
4776
+ "name": "note",
4777
+ "type": "text",
4778
+ "primaryKey": false,
4779
+ "notNull": false
4780
+ },
4781
+ "resolved_by": {
4782
+ "name": "resolved_by",
4783
+ "type": "text",
4784
+ "primaryKey": false,
4785
+ "notNull": false
4786
+ },
4787
+ "resolved_at": {
4788
+ "name": "resolved_at",
4789
+ "type": "timestamp with time zone",
4790
+ "primaryKey": false,
4791
+ "notNull": false
4792
+ },
4793
+ "created_at": {
4794
+ "name": "created_at",
4795
+ "type": "timestamp with time zone",
4796
+ "primaryKey": false,
4797
+ "notNull": true,
4798
+ "default": "now()"
4799
+ },
4800
+ "updated_at": {
4801
+ "name": "updated_at",
4802
+ "type": "timestamp with time zone",
4803
+ "primaryKey": false,
4804
+ "notNull": true,
4805
+ "default": "now()"
4806
+ }
4807
+ },
4808
+ "indexes": {
4809
+ "review_items_one_open": {
4810
+ "name": "review_items_one_open",
4811
+ "columns": [
4812
+ {
4813
+ "expression": "organisation_id",
4814
+ "isExpression": false,
4815
+ "asc": true,
4816
+ "nulls": "last"
4817
+ },
4818
+ {
4819
+ "expression": "kind",
4820
+ "isExpression": false,
4821
+ "asc": true,
4822
+ "nulls": "last"
4823
+ },
4824
+ {
4825
+ "expression": "entity",
4826
+ "isExpression": false,
4827
+ "asc": true,
4828
+ "nulls": "last"
4829
+ },
4830
+ {
4831
+ "expression": "flow_id",
4832
+ "isExpression": false,
4833
+ "asc": true,
4834
+ "nulls": "last"
4835
+ }
4836
+ ],
4837
+ "isUnique": true,
4838
+ "where": "state = 'open'",
4839
+ "concurrently": false,
4840
+ "method": "btree",
4841
+ "with": {}
4842
+ },
4843
+ "review_items_queue": {
4844
+ "name": "review_items_queue",
4845
+ "columns": [
4846
+ {
4847
+ "expression": "organisation_id",
4848
+ "isExpression": false,
4849
+ "asc": true,
4850
+ "nulls": "last"
4851
+ },
4852
+ {
4853
+ "expression": "state",
4854
+ "isExpression": false,
4855
+ "asc": true,
4856
+ "nulls": "last"
4857
+ },
4858
+ {
4859
+ "expression": "money_at_risk_cents",
4860
+ "isExpression": false,
4861
+ "asc": true,
4862
+ "nulls": "last"
4863
+ }
4864
+ ],
4865
+ "isUnique": false,
4866
+ "concurrently": false,
4867
+ "method": "btree",
4868
+ "with": {}
4869
+ }
4870
+ },
4871
+ "foreignKeys": {
4872
+ "review_items_organisation_id_organisations_id_fk": {
4873
+ "name": "review_items_organisation_id_organisations_id_fk",
4874
+ "tableFrom": "review_items",
4875
+ "tableTo": "organisations",
4876
+ "columnsFrom": [
4877
+ "organisation_id"
4878
+ ],
4879
+ "columnsTo": [
4880
+ "id"
4881
+ ],
4882
+ "onDelete": "no action",
4883
+ "onUpdate": "no action"
4884
+ }
4885
+ },
4886
+ "compositePrimaryKeys": {},
4887
+ "uniqueConstraints": {
4888
+ "review_items_org_id": {
4889
+ "name": "review_items_org_id",
4890
+ "nullsNotDistinct": false,
4891
+ "columns": [
4892
+ "organisation_id",
4893
+ "id"
4894
+ ]
4895
+ }
4896
+ },
4897
+ "policies": {},
4898
+ "checkConstraints": {
4899
+ "review_items_state_valid": {
4900
+ "name": "review_items_state_valid",
4901
+ "value": "state in ('open', 'resolved', 'dismissed')"
4902
+ },
4903
+ "review_items_money_not_negative": {
4904
+ "name": "review_items_money_not_negative",
4905
+ "value": "\"review_items\".\"money_at_risk_cents\" >= 0"
4906
+ },
4907
+ "review_items_closed_has_resolution": {
4908
+ "name": "review_items_closed_has_resolution",
4909
+ "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)"
4910
+ }
4911
+ },
4912
+ "isRLSEnabled": false
4913
+ }
4914
+ },
4915
+ "enums": {},
4916
+ "schemas": {},
4917
+ "sequences": {},
4918
+ "roles": {},
4919
+ "policies": {},
4920
+ "views": {},
4921
+ "_meta": {
4922
+ "columns": {},
4923
+ "schemas": {},
4924
+ "tables": {}
4925
+ }
4926
+ }