@arcforgelabs/flow 2026.10.22 → 2026.10.24

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