@arcforgelabs/flow 2026.10.26 → 2026.10.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +5 -0
  2. package/npm-shrinkwrap.json +627 -2
  3. package/package.json +2 -1
  4. package/server/api/invoicing.js +231 -20
  5. package/server/app.js +28 -2
  6. package/server/core/automations.js +140 -0
  7. package/server/core/invoice-rules.js +224 -0
  8. package/server/core/invoices.js +4 -1
  9. package/server/core/invoicing-rules.js +255 -0
  10. package/server/core/ledger.js +45 -12
  11. package/server/core/monitoring.js +34 -0
  12. package/server/core/pipeline.js +8 -1
  13. package/server/core/sending.js +282 -0
  14. package/server/db/migrations/0010_invoicing_rules.sql +51 -0
  15. package/server/db/migrations/0011_invoice_rules.sql +21 -0
  16. package/server/db/migrations/0012_invoice_sending.sql +9 -0
  17. package/server/db/migrations/meta/0010_snapshot.json +3158 -0
  18. package/server/db/migrations/meta/0011_snapshot.json +3314 -0
  19. package/server/db/migrations/meta/0012_snapshot.json +3380 -0
  20. package/server/db/migrations/meta/_journal.json +21 -0
  21. package/server/db/schema.js +115 -0
  22. package/server/index.js +12 -4
  23. package/server/integrations/adapters.js +2 -1
  24. package/server/integrations/port.js +5 -0
  25. package/server/integrations/seazona/ledger.js +2 -0
  26. package/server/integrations/sentry/index.js +105 -0
  27. package/server/integrations/xero/client.js +5 -0
  28. package/server/integrations/xero/drafts.js +123 -16
  29. package/server/integrations/xero/index.js +11 -1
  30. package/server/integrations/xero/migrations/0005_xero_send_modes.sql +10 -0
  31. package/server/integrations/xero/migrations/meta/_journal.json +7 -0
  32. package/server/ui/app-page.js +2 -1
  33. package/server/ui/app.js +14 -1
  34. package/server/ui/automations.js +96 -0
  35. package/server/ui/flow.css +88 -0
  36. package/server/ui/invoice-rules.js +237 -0
  37. package/server/ui/invoicing-settings.js +108 -0
  38. package/server/ui/invoicing.js +166 -20
  39. package/server/ui/jobs.js +19 -0
  40. package/server/ui/logos/sentry.svg +1 -0
  41. package/server/ui/monitoring.js +53 -0
  42. package/server/ui/routes.js +2 -2
@@ -0,0 +1,3380 @@
1
+ {
2
+ "id": "db24ea2a-b74c-4621-a7f2-34af5750da29",
3
+ "prevId": "08b87727-b323-4b65-88f9-13c7780db019",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.automations": {
8
+ "name": "automations",
9
+ "schema": "",
10
+ "columns": {
11
+ "organisation_id": {
12
+ "name": "organisation_id",
13
+ "type": "uuid",
14
+ "primaryKey": false,
15
+ "notNull": true
16
+ },
17
+ "key": {
18
+ "name": "key",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "enabled": {
24
+ "name": "enabled",
25
+ "type": "boolean",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "config": {
30
+ "name": "config",
31
+ "type": "jsonb",
32
+ "primaryKey": false,
33
+ "notNull": true,
34
+ "default": "'{}'::jsonb"
35
+ },
36
+ "updated_by": {
37
+ "name": "updated_by",
38
+ "type": "uuid",
39
+ "primaryKey": false,
40
+ "notNull": false
41
+ },
42
+ "updated_at": {
43
+ "name": "updated_at",
44
+ "type": "timestamp with time zone",
45
+ "primaryKey": false,
46
+ "notNull": true,
47
+ "default": "now()"
48
+ }
49
+ },
50
+ "indexes": {},
51
+ "foreignKeys": {
52
+ "automations_organisation_id_organisations_id_fk": {
53
+ "name": "automations_organisation_id_organisations_id_fk",
54
+ "tableFrom": "automations",
55
+ "tableTo": "organisations",
56
+ "columnsFrom": [
57
+ "organisation_id"
58
+ ],
59
+ "columnsTo": [
60
+ "id"
61
+ ],
62
+ "onDelete": "no action",
63
+ "onUpdate": "no action"
64
+ },
65
+ "automations_updated_by_people_id_fk": {
66
+ "name": "automations_updated_by_people_id_fk",
67
+ "tableFrom": "automations",
68
+ "tableTo": "people",
69
+ "columnsFrom": [
70
+ "updated_by"
71
+ ],
72
+ "columnsTo": [
73
+ "id"
74
+ ],
75
+ "onDelete": "set null",
76
+ "onUpdate": "no action"
77
+ }
78
+ },
79
+ "compositePrimaryKeys": {
80
+ "automations_pk": {
81
+ "name": "automations_pk",
82
+ "columns": [
83
+ "organisation_id",
84
+ "key"
85
+ ]
86
+ }
87
+ },
88
+ "uniqueConstraints": {},
89
+ "policies": {},
90
+ "checkConstraints": {},
91
+ "isRLSEnabled": false
92
+ },
93
+ "public.background_jobs": {
94
+ "name": "background_jobs",
95
+ "schema": "",
96
+ "columns": {
97
+ "id": {
98
+ "name": "id",
99
+ "type": "uuid",
100
+ "primaryKey": true,
101
+ "notNull": true,
102
+ "default": "gen_random_uuid()"
103
+ },
104
+ "organisation_id": {
105
+ "name": "organisation_id",
106
+ "type": "uuid",
107
+ "primaryKey": false,
108
+ "notNull": true
109
+ },
110
+ "kind": {
111
+ "name": "kind",
112
+ "type": "text",
113
+ "primaryKey": false,
114
+ "notNull": true
115
+ },
116
+ "dedupe_key": {
117
+ "name": "dedupe_key",
118
+ "type": "text",
119
+ "primaryKey": false,
120
+ "notNull": true,
121
+ "default": "''"
122
+ },
123
+ "payload": {
124
+ "name": "payload",
125
+ "type": "jsonb",
126
+ "primaryKey": false,
127
+ "notNull": true,
128
+ "default": "'{}'::jsonb"
129
+ },
130
+ "state": {
131
+ "name": "state",
132
+ "type": "text",
133
+ "primaryKey": false,
134
+ "notNull": true,
135
+ "default": "'queued'"
136
+ },
137
+ "run_after": {
138
+ "name": "run_after",
139
+ "type": "timestamp with time zone",
140
+ "primaryKey": false,
141
+ "notNull": true,
142
+ "default": "now()"
143
+ },
144
+ "attempts": {
145
+ "name": "attempts",
146
+ "type": "integer",
147
+ "primaryKey": false,
148
+ "notNull": true,
149
+ "default": 0
150
+ },
151
+ "max_attempts": {
152
+ "name": "max_attempts",
153
+ "type": "integer",
154
+ "primaryKey": false,
155
+ "notNull": true,
156
+ "default": 8
157
+ },
158
+ "locked_by": {
159
+ "name": "locked_by",
160
+ "type": "text",
161
+ "primaryKey": false,
162
+ "notNull": false
163
+ },
164
+ "locked_until": {
165
+ "name": "locked_until",
166
+ "type": "timestamp with time zone",
167
+ "primaryKey": false,
168
+ "notNull": false
169
+ },
170
+ "result": {
171
+ "name": "result",
172
+ "type": "jsonb",
173
+ "primaryKey": false,
174
+ "notNull": false
175
+ },
176
+ "last_error": {
177
+ "name": "last_error",
178
+ "type": "text",
179
+ "primaryKey": false,
180
+ "notNull": false
181
+ },
182
+ "created_at": {
183
+ "name": "created_at",
184
+ "type": "timestamp with time zone",
185
+ "primaryKey": false,
186
+ "notNull": true,
187
+ "default": "now()"
188
+ },
189
+ "updated_at": {
190
+ "name": "updated_at",
191
+ "type": "timestamp with time zone",
192
+ "primaryKey": false,
193
+ "notNull": true,
194
+ "default": "now()"
195
+ }
196
+ },
197
+ "indexes": {
198
+ "background_jobs_one_open": {
199
+ "name": "background_jobs_one_open",
200
+ "columns": [
201
+ {
202
+ "expression": "organisation_id",
203
+ "isExpression": false,
204
+ "asc": true,
205
+ "nulls": "last"
206
+ },
207
+ {
208
+ "expression": "kind",
209
+ "isExpression": false,
210
+ "asc": true,
211
+ "nulls": "last"
212
+ },
213
+ {
214
+ "expression": "dedupe_key",
215
+ "isExpression": false,
216
+ "asc": true,
217
+ "nulls": "last"
218
+ }
219
+ ],
220
+ "isUnique": true,
221
+ "where": "state in ('queued', 'running')",
222
+ "concurrently": false,
223
+ "method": "btree",
224
+ "with": {}
225
+ },
226
+ "background_jobs_due": {
227
+ "name": "background_jobs_due",
228
+ "columns": [
229
+ {
230
+ "expression": "state",
231
+ "isExpression": false,
232
+ "asc": true,
233
+ "nulls": "last"
234
+ },
235
+ {
236
+ "expression": "run_after",
237
+ "isExpression": false,
238
+ "asc": true,
239
+ "nulls": "last"
240
+ }
241
+ ],
242
+ "isUnique": false,
243
+ "concurrently": false,
244
+ "method": "btree",
245
+ "with": {}
246
+ }
247
+ },
248
+ "foreignKeys": {
249
+ "background_jobs_organisation_id_organisations_id_fk": {
250
+ "name": "background_jobs_organisation_id_organisations_id_fk",
251
+ "tableFrom": "background_jobs",
252
+ "tableTo": "organisations",
253
+ "columnsFrom": [
254
+ "organisation_id"
255
+ ],
256
+ "columnsTo": [
257
+ "id"
258
+ ],
259
+ "onDelete": "no action",
260
+ "onUpdate": "no action"
261
+ }
262
+ },
263
+ "compositePrimaryKeys": {},
264
+ "uniqueConstraints": {},
265
+ "policies": {},
266
+ "checkConstraints": {
267
+ "background_jobs_state_valid": {
268
+ "name": "background_jobs_state_valid",
269
+ "value": "state in ('queued', 'running', 'succeeded', 'failed', 'dead')"
270
+ },
271
+ "background_jobs_attempts_valid": {
272
+ "name": "background_jobs_attempts_valid",
273
+ "value": "\"background_jobs\".\"attempts\" >= 0 and \"background_jobs\".\"max_attempts\" > 0"
274
+ }
275
+ },
276
+ "isRLSEnabled": false
277
+ },
278
+ "public.billing_obligations": {
279
+ "name": "billing_obligations",
280
+ "schema": "",
281
+ "columns": {
282
+ "id": {
283
+ "name": "id",
284
+ "type": "uuid",
285
+ "primaryKey": true,
286
+ "notNull": true,
287
+ "default": "gen_random_uuid()"
288
+ },
289
+ "organisation_id": {
290
+ "name": "organisation_id",
291
+ "type": "uuid",
292
+ "primaryKey": false,
293
+ "notNull": true
294
+ },
295
+ "source_system": {
296
+ "name": "source_system",
297
+ "type": "text",
298
+ "primaryKey": false,
299
+ "notNull": true
300
+ },
301
+ "source_job_ref": {
302
+ "name": "source_job_ref",
303
+ "type": "text",
304
+ "primaryKey": false,
305
+ "notNull": true
306
+ },
307
+ "source_invoice_ref": {
308
+ "name": "source_invoice_ref",
309
+ "type": "text",
310
+ "primaryKey": false,
311
+ "notNull": false
312
+ },
313
+ "case_ref": {
314
+ "name": "case_ref",
315
+ "type": "text",
316
+ "primaryKey": false,
317
+ "notNull": false
318
+ },
319
+ "contact_id": {
320
+ "name": "contact_id",
321
+ "type": "uuid",
322
+ "primaryKey": false,
323
+ "notNull": false
324
+ },
325
+ "practitioner": {
326
+ "name": "practitioner",
327
+ "type": "text",
328
+ "primaryKey": false,
329
+ "notNull": false
330
+ },
331
+ "shipped_on": {
332
+ "name": "shipped_on",
333
+ "type": "date",
334
+ "primaryKey": false,
335
+ "notNull": false
336
+ },
337
+ "job_date": {
338
+ "name": "job_date",
339
+ "type": "date",
340
+ "primaryKey": false,
341
+ "notNull": false
342
+ },
343
+ "source_status": {
344
+ "name": "source_status",
345
+ "type": "text",
346
+ "primaryKey": false,
347
+ "notNull": false
348
+ },
349
+ "ready_at": {
350
+ "name": "ready_at",
351
+ "type": "timestamp with time zone",
352
+ "primaryKey": false,
353
+ "notNull": false
354
+ },
355
+ "ready_by": {
356
+ "name": "ready_by",
357
+ "type": "text",
358
+ "primaryKey": false,
359
+ "notNull": false
360
+ },
361
+ "lines": {
362
+ "name": "lines",
363
+ "type": "jsonb",
364
+ "primaryKey": false,
365
+ "notNull": true,
366
+ "default": "'[]'::jsonb"
367
+ },
368
+ "line_fingerprint": {
369
+ "name": "line_fingerprint",
370
+ "type": "text",
371
+ "primaryKey": false,
372
+ "notNull": true
373
+ },
374
+ "subtotal_cents": {
375
+ "name": "subtotal_cents",
376
+ "type": "integer",
377
+ "primaryKey": false,
378
+ "notNull": true
379
+ },
380
+ "tax_cents": {
381
+ "name": "tax_cents",
382
+ "type": "integer",
383
+ "primaryKey": false,
384
+ "notNull": true
385
+ },
386
+ "total_cents": {
387
+ "name": "total_cents",
388
+ "type": "integer",
389
+ "primaryKey": false,
390
+ "notNull": true
391
+ },
392
+ "mapping_complete": {
393
+ "name": "mapping_complete",
394
+ "type": "boolean",
395
+ "primaryKey": false,
396
+ "notNull": true
397
+ },
398
+ "source_seen_at": {
399
+ "name": "source_seen_at",
400
+ "type": "timestamp with time zone",
401
+ "primaryKey": false,
402
+ "notNull": true
403
+ },
404
+ "hold_state": {
405
+ "name": "hold_state",
406
+ "type": "text",
407
+ "primaryKey": false,
408
+ "notNull": true,
409
+ "default": "'none'"
410
+ },
411
+ "hold_reason": {
412
+ "name": "hold_reason",
413
+ "type": "text",
414
+ "primaryKey": false,
415
+ "notNull": false
416
+ },
417
+ "invoice_id": {
418
+ "name": "invoice_id",
419
+ "type": "uuid",
420
+ "primaryKey": false,
421
+ "notNull": false
422
+ },
423
+ "accounting_state": {
424
+ "name": "accounting_state",
425
+ "type": "text",
426
+ "primaryKey": false,
427
+ "notNull": true,
428
+ "default": "'unknown'"
429
+ },
430
+ "accounting_ref": {
431
+ "name": "accounting_ref",
432
+ "type": "text",
433
+ "primaryKey": false,
434
+ "notNull": false
435
+ },
436
+ "accounting_url": {
437
+ "name": "accounting_url",
438
+ "type": "text",
439
+ "primaryKey": false,
440
+ "notNull": false
441
+ },
442
+ "accounting_matched_by": {
443
+ "name": "accounting_matched_by",
444
+ "type": "text",
445
+ "primaryKey": false,
446
+ "notNull": false
447
+ },
448
+ "accounting_checked_at": {
449
+ "name": "accounting_checked_at",
450
+ "type": "timestamp with time zone",
451
+ "primaryKey": false,
452
+ "notNull": false
453
+ },
454
+ "paid_cents": {
455
+ "name": "paid_cents",
456
+ "type": "integer",
457
+ "primaryKey": false,
458
+ "notNull": true,
459
+ "default": 0
460
+ },
461
+ "created_at": {
462
+ "name": "created_at",
463
+ "type": "timestamp with time zone",
464
+ "primaryKey": false,
465
+ "notNull": true,
466
+ "default": "now()"
467
+ },
468
+ "updated_at": {
469
+ "name": "updated_at",
470
+ "type": "timestamp with time zone",
471
+ "primaryKey": false,
472
+ "notNull": true,
473
+ "default": "now()"
474
+ }
475
+ },
476
+ "indexes": {},
477
+ "foreignKeys": {
478
+ "billing_obligations_organisation_id_organisations_id_fk": {
479
+ "name": "billing_obligations_organisation_id_organisations_id_fk",
480
+ "tableFrom": "billing_obligations",
481
+ "tableTo": "organisations",
482
+ "columnsFrom": [
483
+ "organisation_id"
484
+ ],
485
+ "columnsTo": [
486
+ "id"
487
+ ],
488
+ "onDelete": "no action",
489
+ "onUpdate": "no action"
490
+ },
491
+ "billing_obligations_contact_same_org": {
492
+ "name": "billing_obligations_contact_same_org",
493
+ "tableFrom": "billing_obligations",
494
+ "tableTo": "contacts",
495
+ "columnsFrom": [
496
+ "organisation_id",
497
+ "contact_id"
498
+ ],
499
+ "columnsTo": [
500
+ "organisation_id",
501
+ "id"
502
+ ],
503
+ "onDelete": "no action",
504
+ "onUpdate": "no action"
505
+ },
506
+ "billing_obligations_invoice_same_org": {
507
+ "name": "billing_obligations_invoice_same_org",
508
+ "tableFrom": "billing_obligations",
509
+ "tableTo": "invoices",
510
+ "columnsFrom": [
511
+ "organisation_id",
512
+ "invoice_id"
513
+ ],
514
+ "columnsTo": [
515
+ "organisation_id",
516
+ "id"
517
+ ],
518
+ "onDelete": "no action",
519
+ "onUpdate": "no action"
520
+ }
521
+ },
522
+ "compositePrimaryKeys": {},
523
+ "uniqueConstraints": {
524
+ "billing_obligations_org_id": {
525
+ "name": "billing_obligations_org_id",
526
+ "nullsNotDistinct": false,
527
+ "columns": [
528
+ "organisation_id",
529
+ "id"
530
+ ]
531
+ },
532
+ "billing_obligations_source_job": {
533
+ "name": "billing_obligations_source_job",
534
+ "nullsNotDistinct": false,
535
+ "columns": [
536
+ "organisation_id",
537
+ "source_system",
538
+ "source_job_ref"
539
+ ]
540
+ },
541
+ "billing_obligations_invoice": {
542
+ "name": "billing_obligations_invoice",
543
+ "nullsNotDistinct": false,
544
+ "columns": [
545
+ "organisation_id",
546
+ "invoice_id"
547
+ ]
548
+ }
549
+ },
550
+ "policies": {},
551
+ "checkConstraints": {
552
+ "billing_obligations_hold_state_valid": {
553
+ "name": "billing_obligations_hold_state_valid",
554
+ "value": "hold_state in ('none', 'held', 'review')"
555
+ },
556
+ "billing_obligations_accounting_state_valid": {
557
+ "name": "billing_obligations_accounting_state_valid",
558
+ "value": "accounting_state in ('unknown', 'not_found', 'drafted', 'authorised', 'part_paid', 'paid', 'voided', 'deleted', 'ambiguous', 'conflict')"
559
+ },
560
+ "billing_obligations_paid_not_negative": {
561
+ "name": "billing_obligations_paid_not_negative",
562
+ "value": "\"billing_obligations\".\"paid_cents\" >= 0"
563
+ }
564
+ },
565
+ "isRLSEnabled": false
566
+ },
567
+ "public.contacts": {
568
+ "name": "contacts",
569
+ "schema": "",
570
+ "columns": {
571
+ "id": {
572
+ "name": "id",
573
+ "type": "uuid",
574
+ "primaryKey": true,
575
+ "notNull": true,
576
+ "default": "gen_random_uuid()"
577
+ },
578
+ "organisation_id": {
579
+ "name": "organisation_id",
580
+ "type": "uuid",
581
+ "primaryKey": false,
582
+ "notNull": true
583
+ },
584
+ "kind": {
585
+ "name": "kind",
586
+ "type": "text",
587
+ "primaryKey": false,
588
+ "notNull": true
589
+ },
590
+ "name": {
591
+ "name": "name",
592
+ "type": "text",
593
+ "primaryKey": false,
594
+ "notNull": true
595
+ },
596
+ "email": {
597
+ "name": "email",
598
+ "type": "text",
599
+ "primaryKey": false,
600
+ "notNull": false
601
+ },
602
+ "created_at": {
603
+ "name": "created_at",
604
+ "type": "timestamp with time zone",
605
+ "primaryKey": false,
606
+ "notNull": true,
607
+ "default": "now()"
608
+ }
609
+ },
610
+ "indexes": {},
611
+ "foreignKeys": {
612
+ "contacts_organisation_id_organisations_id_fk": {
613
+ "name": "contacts_organisation_id_organisations_id_fk",
614
+ "tableFrom": "contacts",
615
+ "tableTo": "organisations",
616
+ "columnsFrom": [
617
+ "organisation_id"
618
+ ],
619
+ "columnsTo": [
620
+ "id"
621
+ ],
622
+ "onDelete": "no action",
623
+ "onUpdate": "no action"
624
+ }
625
+ },
626
+ "compositePrimaryKeys": {},
627
+ "uniqueConstraints": {
628
+ "contacts_org_id": {
629
+ "name": "contacts_org_id",
630
+ "nullsNotDistinct": false,
631
+ "columns": [
632
+ "organisation_id",
633
+ "id"
634
+ ]
635
+ },
636
+ "contacts_org_kind_name": {
637
+ "name": "contacts_org_kind_name",
638
+ "nullsNotDistinct": false,
639
+ "columns": [
640
+ "organisation_id",
641
+ "kind",
642
+ "name"
643
+ ]
644
+ }
645
+ },
646
+ "policies": {},
647
+ "checkConstraints": {
648
+ "contacts_kind_valid": {
649
+ "name": "contacts_kind_valid",
650
+ "value": "\"contacts\".\"kind\" in ('customer', 'supplier')"
651
+ }
652
+ },
653
+ "isRLSEnabled": false
654
+ },
655
+ "public.customer_billing_settings": {
656
+ "name": "customer_billing_settings",
657
+ "schema": "",
658
+ "columns": {
659
+ "organisation_id": {
660
+ "name": "organisation_id",
661
+ "type": "uuid",
662
+ "primaryKey": false,
663
+ "notNull": true
664
+ },
665
+ "contact_id": {
666
+ "name": "contact_id",
667
+ "type": "uuid",
668
+ "primaryKey": false,
669
+ "notNull": true
670
+ },
671
+ "billable": {
672
+ "name": "billable",
673
+ "type": "boolean",
674
+ "primaryKey": false,
675
+ "notNull": true,
676
+ "default": true
677
+ },
678
+ "default_practitioner": {
679
+ "name": "default_practitioner",
680
+ "type": "text",
681
+ "primaryKey": false,
682
+ "notNull": false
683
+ },
684
+ "auto_draft": {
685
+ "name": "auto_draft",
686
+ "type": "boolean",
687
+ "primaryKey": false,
688
+ "notNull": false
689
+ },
690
+ "send_mode": {
691
+ "name": "send_mode",
692
+ "type": "text",
693
+ "primaryKey": false,
694
+ "notNull": false
695
+ },
696
+ "payment_terms_days": {
697
+ "name": "payment_terms_days",
698
+ "type": "integer",
699
+ "primaryKey": false,
700
+ "notNull": false
701
+ },
702
+ "updated_by": {
703
+ "name": "updated_by",
704
+ "type": "uuid",
705
+ "primaryKey": false,
706
+ "notNull": false
707
+ },
708
+ "updated_at": {
709
+ "name": "updated_at",
710
+ "type": "timestamp with time zone",
711
+ "primaryKey": false,
712
+ "notNull": true,
713
+ "default": "now()"
714
+ }
715
+ },
716
+ "indexes": {},
717
+ "foreignKeys": {
718
+ "customer_billing_settings_organisation_id_organisations_id_fk": {
719
+ "name": "customer_billing_settings_organisation_id_organisations_id_fk",
720
+ "tableFrom": "customer_billing_settings",
721
+ "tableTo": "organisations",
722
+ "columnsFrom": [
723
+ "organisation_id"
724
+ ],
725
+ "columnsTo": [
726
+ "id"
727
+ ],
728
+ "onDelete": "no action",
729
+ "onUpdate": "no action"
730
+ },
731
+ "customer_billing_settings_updated_by_people_id_fk": {
732
+ "name": "customer_billing_settings_updated_by_people_id_fk",
733
+ "tableFrom": "customer_billing_settings",
734
+ "tableTo": "people",
735
+ "columnsFrom": [
736
+ "updated_by"
737
+ ],
738
+ "columnsTo": [
739
+ "id"
740
+ ],
741
+ "onDelete": "set null",
742
+ "onUpdate": "no action"
743
+ },
744
+ "customer_billing_settings_contact_same_org": {
745
+ "name": "customer_billing_settings_contact_same_org",
746
+ "tableFrom": "customer_billing_settings",
747
+ "tableTo": "contacts",
748
+ "columnsFrom": [
749
+ "organisation_id",
750
+ "contact_id"
751
+ ],
752
+ "columnsTo": [
753
+ "organisation_id",
754
+ "id"
755
+ ],
756
+ "onDelete": "no action",
757
+ "onUpdate": "no action"
758
+ }
759
+ },
760
+ "compositePrimaryKeys": {
761
+ "customer_billing_settings_pk": {
762
+ "name": "customer_billing_settings_pk",
763
+ "columns": [
764
+ "organisation_id",
765
+ "contact_id"
766
+ ]
767
+ }
768
+ },
769
+ "uniqueConstraints": {},
770
+ "policies": {},
771
+ "checkConstraints": {
772
+ "customer_billing_settings_send_mode_valid": {
773
+ "name": "customer_billing_settings_send_mode_valid",
774
+ "value": "\"customer_billing_settings\".\"send_mode\" is null or \"customer_billing_settings\".\"send_mode\" in ('accounting_draft', 'approve_and_email')"
775
+ },
776
+ "customer_billing_settings_terms_valid": {
777
+ "name": "customer_billing_settings_terms_valid",
778
+ "value": "\"customer_billing_settings\".\"payment_terms_days\" is null or \"customer_billing_settings\".\"payment_terms_days\" between 0 and 365"
779
+ }
780
+ },
781
+ "isRLSEnabled": false
782
+ },
783
+ "public.external_links": {
784
+ "name": "external_links",
785
+ "schema": "",
786
+ "columns": {
787
+ "id": {
788
+ "name": "id",
789
+ "type": "uuid",
790
+ "primaryKey": true,
791
+ "notNull": true,
792
+ "default": "gen_random_uuid()"
793
+ },
794
+ "organisation_id": {
795
+ "name": "organisation_id",
796
+ "type": "uuid",
797
+ "primaryKey": false,
798
+ "notNull": true
799
+ },
800
+ "entity": {
801
+ "name": "entity",
802
+ "type": "text",
803
+ "primaryKey": false,
804
+ "notNull": true
805
+ },
806
+ "flow_id": {
807
+ "name": "flow_id",
808
+ "type": "uuid",
809
+ "primaryKey": false,
810
+ "notNull": true
811
+ },
812
+ "system": {
813
+ "name": "system",
814
+ "type": "text",
815
+ "primaryKey": false,
816
+ "notNull": true
817
+ },
818
+ "external_id": {
819
+ "name": "external_id",
820
+ "type": "text",
821
+ "primaryKey": false,
822
+ "notNull": true
823
+ },
824
+ "matched_by": {
825
+ "name": "matched_by",
826
+ "type": "text",
827
+ "primaryKey": false,
828
+ "notNull": true
829
+ },
830
+ "state": {
831
+ "name": "state",
832
+ "type": "text",
833
+ "primaryKey": false,
834
+ "notNull": true
835
+ },
836
+ "confirmed_by": {
837
+ "name": "confirmed_by",
838
+ "type": "uuid",
839
+ "primaryKey": false,
840
+ "notNull": false
841
+ },
842
+ "confirmed_at": {
843
+ "name": "confirmed_at",
844
+ "type": "timestamp with time zone",
845
+ "primaryKey": false,
846
+ "notNull": false
847
+ },
848
+ "created_at": {
849
+ "name": "created_at",
850
+ "type": "timestamp with time zone",
851
+ "primaryKey": false,
852
+ "notNull": true,
853
+ "default": "now()"
854
+ },
855
+ "updated_at": {
856
+ "name": "updated_at",
857
+ "type": "timestamp with time zone",
858
+ "primaryKey": false,
859
+ "notNull": true,
860
+ "default": "now()"
861
+ }
862
+ },
863
+ "indexes": {
864
+ "external_links_active_external": {
865
+ "name": "external_links_active_external",
866
+ "columns": [
867
+ {
868
+ "expression": "organisation_id",
869
+ "isExpression": false,
870
+ "asc": true,
871
+ "nulls": "last"
872
+ },
873
+ {
874
+ "expression": "system",
875
+ "isExpression": false,
876
+ "asc": true,
877
+ "nulls": "last"
878
+ },
879
+ {
880
+ "expression": "entity",
881
+ "isExpression": false,
882
+ "asc": true,
883
+ "nulls": "last"
884
+ },
885
+ {
886
+ "expression": "external_id",
887
+ "isExpression": false,
888
+ "asc": true,
889
+ "nulls": "last"
890
+ }
891
+ ],
892
+ "isUnique": true,
893
+ "where": "state = 'active'",
894
+ "concurrently": false,
895
+ "method": "btree",
896
+ "with": {}
897
+ },
898
+ "external_links_active_flow": {
899
+ "name": "external_links_active_flow",
900
+ "columns": [
901
+ {
902
+ "expression": "organisation_id",
903
+ "isExpression": false,
904
+ "asc": true,
905
+ "nulls": "last"
906
+ },
907
+ {
908
+ "expression": "system",
909
+ "isExpression": false,
910
+ "asc": true,
911
+ "nulls": "last"
912
+ },
913
+ {
914
+ "expression": "entity",
915
+ "isExpression": false,
916
+ "asc": true,
917
+ "nulls": "last"
918
+ },
919
+ {
920
+ "expression": "flow_id",
921
+ "isExpression": false,
922
+ "asc": true,
923
+ "nulls": "last"
924
+ }
925
+ ],
926
+ "isUnique": true,
927
+ "where": "state = 'active'",
928
+ "concurrently": false,
929
+ "method": "btree",
930
+ "with": {}
931
+ },
932
+ "external_links_flow": {
933
+ "name": "external_links_flow",
934
+ "columns": [
935
+ {
936
+ "expression": "organisation_id",
937
+ "isExpression": false,
938
+ "asc": true,
939
+ "nulls": "last"
940
+ },
941
+ {
942
+ "expression": "entity",
943
+ "isExpression": false,
944
+ "asc": true,
945
+ "nulls": "last"
946
+ },
947
+ {
948
+ "expression": "flow_id",
949
+ "isExpression": false,
950
+ "asc": true,
951
+ "nulls": "last"
952
+ }
953
+ ],
954
+ "isUnique": false,
955
+ "concurrently": false,
956
+ "method": "btree",
957
+ "with": {}
958
+ }
959
+ },
960
+ "foreignKeys": {
961
+ "external_links_organisation_id_organisations_id_fk": {
962
+ "name": "external_links_organisation_id_organisations_id_fk",
963
+ "tableFrom": "external_links",
964
+ "tableTo": "organisations",
965
+ "columnsFrom": [
966
+ "organisation_id"
967
+ ],
968
+ "columnsTo": [
969
+ "id"
970
+ ],
971
+ "onDelete": "no action",
972
+ "onUpdate": "no action"
973
+ },
974
+ "external_links_confirmed_by_people_id_fk": {
975
+ "name": "external_links_confirmed_by_people_id_fk",
976
+ "tableFrom": "external_links",
977
+ "tableTo": "people",
978
+ "columnsFrom": [
979
+ "confirmed_by"
980
+ ],
981
+ "columnsTo": [
982
+ "id"
983
+ ],
984
+ "onDelete": "set null",
985
+ "onUpdate": "no action"
986
+ }
987
+ },
988
+ "compositePrimaryKeys": {},
989
+ "uniqueConstraints": {
990
+ "external_links_org_id": {
991
+ "name": "external_links_org_id",
992
+ "nullsNotDistinct": false,
993
+ "columns": [
994
+ "organisation_id",
995
+ "id"
996
+ ]
997
+ }
998
+ },
999
+ "policies": {},
1000
+ "checkConstraints": {
1001
+ "external_links_entity_valid": {
1002
+ "name": "external_links_entity_valid",
1003
+ "value": "entity in ('contact', 'price_item', 'obligation', 'invoice', 'payment', 'credit_note')"
1004
+ },
1005
+ "external_links_matched_by_valid": {
1006
+ "name": "external_links_matched_by_valid",
1007
+ "value": "matched_by in ('created_by_flow', 'exact_id', 'exact_name', 'imported', 'name', 'person')"
1008
+ },
1009
+ "external_links_state_valid": {
1010
+ "name": "external_links_state_valid",
1011
+ "value": "state in ('active', 'proposed', 'superseded')"
1012
+ },
1013
+ "external_links_name_needs_person": {
1014
+ "name": "external_links_name_needs_person",
1015
+ "value": "\"external_links\".\"matched_by\" <> 'name' or \"external_links\".\"state\" <> 'active' or \"external_links\".\"confirmed_at\" is not null"
1016
+ }
1017
+ },
1018
+ "isRLSEnabled": false
1019
+ },
1020
+ "public.integration_setting_events": {
1021
+ "name": "integration_setting_events",
1022
+ "schema": "",
1023
+ "columns": {
1024
+ "id": {
1025
+ "name": "id",
1026
+ "type": "uuid",
1027
+ "primaryKey": true,
1028
+ "notNull": true,
1029
+ "default": "gen_random_uuid()"
1030
+ },
1031
+ "adapter_id": {
1032
+ "name": "adapter_id",
1033
+ "type": "text",
1034
+ "primaryKey": false,
1035
+ "notNull": true
1036
+ },
1037
+ "kind": {
1038
+ "name": "kind",
1039
+ "type": "text",
1040
+ "primaryKey": false,
1041
+ "notNull": true
1042
+ },
1043
+ "settings": {
1044
+ "name": "settings",
1045
+ "type": "text[]",
1046
+ "primaryKey": false,
1047
+ "notNull": true,
1048
+ "default": "'{}'::text[]"
1049
+ },
1050
+ "actor": {
1051
+ "name": "actor",
1052
+ "type": "uuid",
1053
+ "primaryKey": false,
1054
+ "notNull": false
1055
+ },
1056
+ "created_at": {
1057
+ "name": "created_at",
1058
+ "type": "timestamp with time zone",
1059
+ "primaryKey": false,
1060
+ "notNull": true,
1061
+ "default": "now()"
1062
+ }
1063
+ },
1064
+ "indexes": {
1065
+ "integration_setting_events_adapter": {
1066
+ "name": "integration_setting_events_adapter",
1067
+ "columns": [
1068
+ {
1069
+ "expression": "adapter_id",
1070
+ "isExpression": false,
1071
+ "asc": true,
1072
+ "nulls": "last"
1073
+ },
1074
+ {
1075
+ "expression": "created_at",
1076
+ "isExpression": false,
1077
+ "asc": true,
1078
+ "nulls": "last"
1079
+ }
1080
+ ],
1081
+ "isUnique": false,
1082
+ "concurrently": false,
1083
+ "method": "btree",
1084
+ "with": {}
1085
+ }
1086
+ },
1087
+ "foreignKeys": {
1088
+ "integration_setting_events_actor_people_id_fk": {
1089
+ "name": "integration_setting_events_actor_people_id_fk",
1090
+ "tableFrom": "integration_setting_events",
1091
+ "tableTo": "people",
1092
+ "columnsFrom": [
1093
+ "actor"
1094
+ ],
1095
+ "columnsTo": [
1096
+ "id"
1097
+ ],
1098
+ "onDelete": "set null",
1099
+ "onUpdate": "no action"
1100
+ }
1101
+ },
1102
+ "compositePrimaryKeys": {},
1103
+ "uniqueConstraints": {},
1104
+ "policies": {},
1105
+ "checkConstraints": {
1106
+ "integration_setting_events_kind_valid": {
1107
+ "name": "integration_setting_events_kind_valid",
1108
+ "value": "kind in ('turned_on', 'turned_off', 'setting_changed', 'secret_set', 'secret_removed')"
1109
+ }
1110
+ },
1111
+ "isRLSEnabled": false
1112
+ },
1113
+ "public.integration_settings": {
1114
+ "name": "integration_settings",
1115
+ "schema": "",
1116
+ "columns": {
1117
+ "adapter_id": {
1118
+ "name": "adapter_id",
1119
+ "type": "text",
1120
+ "primaryKey": true,
1121
+ "notNull": true
1122
+ },
1123
+ "enabled": {
1124
+ "name": "enabled",
1125
+ "type": "boolean",
1126
+ "primaryKey": false,
1127
+ "notNull": true,
1128
+ "default": false
1129
+ },
1130
+ "config": {
1131
+ "name": "config",
1132
+ "type": "jsonb",
1133
+ "primaryKey": false,
1134
+ "notNull": true,
1135
+ "default": "'{}'::jsonb"
1136
+ },
1137
+ "secrets": {
1138
+ "name": "secrets",
1139
+ "type": "jsonb",
1140
+ "primaryKey": false,
1141
+ "notNull": true,
1142
+ "default": "'{}'::jsonb"
1143
+ },
1144
+ "updated_by": {
1145
+ "name": "updated_by",
1146
+ "type": "uuid",
1147
+ "primaryKey": false,
1148
+ "notNull": false
1149
+ },
1150
+ "created_at": {
1151
+ "name": "created_at",
1152
+ "type": "timestamp with time zone",
1153
+ "primaryKey": false,
1154
+ "notNull": true,
1155
+ "default": "now()"
1156
+ },
1157
+ "updated_at": {
1158
+ "name": "updated_at",
1159
+ "type": "timestamp with time zone",
1160
+ "primaryKey": false,
1161
+ "notNull": true,
1162
+ "default": "now()"
1163
+ }
1164
+ },
1165
+ "indexes": {},
1166
+ "foreignKeys": {
1167
+ "integration_settings_updated_by_people_id_fk": {
1168
+ "name": "integration_settings_updated_by_people_id_fk",
1169
+ "tableFrom": "integration_settings",
1170
+ "tableTo": "people",
1171
+ "columnsFrom": [
1172
+ "updated_by"
1173
+ ],
1174
+ "columnsTo": [
1175
+ "id"
1176
+ ],
1177
+ "onDelete": "set null",
1178
+ "onUpdate": "no action"
1179
+ }
1180
+ },
1181
+ "compositePrimaryKeys": {},
1182
+ "uniqueConstraints": {},
1183
+ "policies": {},
1184
+ "checkConstraints": {},
1185
+ "isRLSEnabled": false
1186
+ },
1187
+ "public.invoice_lines": {
1188
+ "name": "invoice_lines",
1189
+ "schema": "",
1190
+ "columns": {
1191
+ "id": {
1192
+ "name": "id",
1193
+ "type": "uuid",
1194
+ "primaryKey": true,
1195
+ "notNull": true,
1196
+ "default": "gen_random_uuid()"
1197
+ },
1198
+ "organisation_id": {
1199
+ "name": "organisation_id",
1200
+ "type": "uuid",
1201
+ "primaryKey": false,
1202
+ "notNull": true
1203
+ },
1204
+ "invoice_id": {
1205
+ "name": "invoice_id",
1206
+ "type": "uuid",
1207
+ "primaryKey": false,
1208
+ "notNull": true
1209
+ },
1210
+ "position": {
1211
+ "name": "position",
1212
+ "type": "integer",
1213
+ "primaryKey": false,
1214
+ "notNull": true
1215
+ },
1216
+ "price_item_id": {
1217
+ "name": "price_item_id",
1218
+ "type": "uuid",
1219
+ "primaryKey": false,
1220
+ "notNull": false
1221
+ },
1222
+ "description": {
1223
+ "name": "description",
1224
+ "type": "text",
1225
+ "primaryKey": false,
1226
+ "notNull": true
1227
+ },
1228
+ "quantity": {
1229
+ "name": "quantity",
1230
+ "type": "integer",
1231
+ "primaryKey": false,
1232
+ "notNull": true
1233
+ },
1234
+ "unit_amount_cents": {
1235
+ "name": "unit_amount_cents",
1236
+ "type": "integer",
1237
+ "primaryKey": false,
1238
+ "notNull": true
1239
+ },
1240
+ "tax_code": {
1241
+ "name": "tax_code",
1242
+ "type": "text",
1243
+ "primaryKey": false,
1244
+ "notNull": true
1245
+ },
1246
+ "line_amount_cents": {
1247
+ "name": "line_amount_cents",
1248
+ "type": "integer",
1249
+ "primaryKey": false,
1250
+ "notNull": true
1251
+ },
1252
+ "tax_cents": {
1253
+ "name": "tax_cents",
1254
+ "type": "integer",
1255
+ "primaryKey": false,
1256
+ "notNull": true
1257
+ }
1258
+ },
1259
+ "indexes": {},
1260
+ "foreignKeys": {
1261
+ "invoice_lines_invoice_same_org": {
1262
+ "name": "invoice_lines_invoice_same_org",
1263
+ "tableFrom": "invoice_lines",
1264
+ "tableTo": "invoices",
1265
+ "columnsFrom": [
1266
+ "organisation_id",
1267
+ "invoice_id"
1268
+ ],
1269
+ "columnsTo": [
1270
+ "organisation_id",
1271
+ "id"
1272
+ ],
1273
+ "onDelete": "cascade",
1274
+ "onUpdate": "no action"
1275
+ },
1276
+ "invoice_lines_price_item_same_org": {
1277
+ "name": "invoice_lines_price_item_same_org",
1278
+ "tableFrom": "invoice_lines",
1279
+ "tableTo": "price_items",
1280
+ "columnsFrom": [
1281
+ "organisation_id",
1282
+ "price_item_id"
1283
+ ],
1284
+ "columnsTo": [
1285
+ "organisation_id",
1286
+ "id"
1287
+ ],
1288
+ "onDelete": "no action",
1289
+ "onUpdate": "no action"
1290
+ }
1291
+ },
1292
+ "compositePrimaryKeys": {},
1293
+ "uniqueConstraints": {
1294
+ "invoice_lines_invoice_position": {
1295
+ "name": "invoice_lines_invoice_position",
1296
+ "nullsNotDistinct": false,
1297
+ "columns": [
1298
+ "invoice_id",
1299
+ "position"
1300
+ ]
1301
+ }
1302
+ },
1303
+ "policies": {},
1304
+ "checkConstraints": {
1305
+ "invoice_lines_quantity_positive": {
1306
+ "name": "invoice_lines_quantity_positive",
1307
+ "value": "\"invoice_lines\".\"quantity\" > 0"
1308
+ },
1309
+ "invoice_lines_tax_code_valid": {
1310
+ "name": "invoice_lines_tax_code_valid",
1311
+ "value": "\"invoice_lines\".\"tax_code\" in ('GST', 'GST_FREE')"
1312
+ }
1313
+ },
1314
+ "isRLSEnabled": false
1315
+ },
1316
+ "public.invoice_rules": {
1317
+ "name": "invoice_rules",
1318
+ "schema": "",
1319
+ "columns": {
1320
+ "id": {
1321
+ "name": "id",
1322
+ "type": "uuid",
1323
+ "primaryKey": true,
1324
+ "notNull": true,
1325
+ "default": "gen_random_uuid()"
1326
+ },
1327
+ "organisation_id": {
1328
+ "name": "organisation_id",
1329
+ "type": "uuid",
1330
+ "primaryKey": false,
1331
+ "notNull": true
1332
+ },
1333
+ "name": {
1334
+ "name": "name",
1335
+ "type": "text",
1336
+ "primaryKey": false,
1337
+ "notNull": true
1338
+ },
1339
+ "position": {
1340
+ "name": "position",
1341
+ "type": "integer",
1342
+ "primaryKey": false,
1343
+ "notNull": true
1344
+ },
1345
+ "enabled": {
1346
+ "name": "enabled",
1347
+ "type": "boolean",
1348
+ "primaryKey": false,
1349
+ "notNull": true,
1350
+ "default": true
1351
+ },
1352
+ "trigger": {
1353
+ "name": "trigger",
1354
+ "type": "text",
1355
+ "primaryKey": false,
1356
+ "notNull": true,
1357
+ "default": "'job_ready'"
1358
+ },
1359
+ "conditions": {
1360
+ "name": "conditions",
1361
+ "type": "jsonb",
1362
+ "primaryKey": false,
1363
+ "notNull": true,
1364
+ "default": "'[]'::jsonb"
1365
+ },
1366
+ "action": {
1367
+ "name": "action",
1368
+ "type": "jsonb",
1369
+ "primaryKey": false,
1370
+ "notNull": true
1371
+ },
1372
+ "starter_key": {
1373
+ "name": "starter_key",
1374
+ "type": "text",
1375
+ "primaryKey": false,
1376
+ "notNull": false
1377
+ },
1378
+ "updated_by": {
1379
+ "name": "updated_by",
1380
+ "type": "uuid",
1381
+ "primaryKey": false,
1382
+ "notNull": false
1383
+ },
1384
+ "created_at": {
1385
+ "name": "created_at",
1386
+ "type": "timestamp with time zone",
1387
+ "primaryKey": false,
1388
+ "notNull": true,
1389
+ "default": "now()"
1390
+ },
1391
+ "updated_at": {
1392
+ "name": "updated_at",
1393
+ "type": "timestamp with time zone",
1394
+ "primaryKey": false,
1395
+ "notNull": true,
1396
+ "default": "now()"
1397
+ }
1398
+ },
1399
+ "indexes": {
1400
+ "invoice_rules_starter_key": {
1401
+ "name": "invoice_rules_starter_key",
1402
+ "columns": [
1403
+ {
1404
+ "expression": "organisation_id",
1405
+ "isExpression": false,
1406
+ "asc": true,
1407
+ "nulls": "last"
1408
+ },
1409
+ {
1410
+ "expression": "starter_key",
1411
+ "isExpression": false,
1412
+ "asc": true,
1413
+ "nulls": "last"
1414
+ }
1415
+ ],
1416
+ "isUnique": true,
1417
+ "concurrently": false,
1418
+ "method": "btree",
1419
+ "with": {}
1420
+ }
1421
+ },
1422
+ "foreignKeys": {
1423
+ "invoice_rules_organisation_id_organisations_id_fk": {
1424
+ "name": "invoice_rules_organisation_id_organisations_id_fk",
1425
+ "tableFrom": "invoice_rules",
1426
+ "tableTo": "organisations",
1427
+ "columnsFrom": [
1428
+ "organisation_id"
1429
+ ],
1430
+ "columnsTo": [
1431
+ "id"
1432
+ ],
1433
+ "onDelete": "no action",
1434
+ "onUpdate": "no action"
1435
+ },
1436
+ "invoice_rules_updated_by_people_id_fk": {
1437
+ "name": "invoice_rules_updated_by_people_id_fk",
1438
+ "tableFrom": "invoice_rules",
1439
+ "tableTo": "people",
1440
+ "columnsFrom": [
1441
+ "updated_by"
1442
+ ],
1443
+ "columnsTo": [
1444
+ "id"
1445
+ ],
1446
+ "onDelete": "set null",
1447
+ "onUpdate": "no action"
1448
+ }
1449
+ },
1450
+ "compositePrimaryKeys": {},
1451
+ "uniqueConstraints": {},
1452
+ "policies": {},
1453
+ "checkConstraints": {
1454
+ "invoice_rules_trigger_valid": {
1455
+ "name": "invoice_rules_trigger_valid",
1456
+ "value": "\"invoice_rules\".\"trigger\" in ('job_ready')"
1457
+ },
1458
+ "invoice_rules_name_valid": {
1459
+ "name": "invoice_rules_name_valid",
1460
+ "value": "length(\"invoice_rules\".\"name\") between 1 and 120"
1461
+ }
1462
+ },
1463
+ "isRLSEnabled": false
1464
+ },
1465
+ "public.invoice_versions": {
1466
+ "name": "invoice_versions",
1467
+ "schema": "",
1468
+ "columns": {
1469
+ "id": {
1470
+ "name": "id",
1471
+ "type": "uuid",
1472
+ "primaryKey": true,
1473
+ "notNull": true,
1474
+ "default": "gen_random_uuid()"
1475
+ },
1476
+ "organisation_id": {
1477
+ "name": "organisation_id",
1478
+ "type": "uuid",
1479
+ "primaryKey": false,
1480
+ "notNull": true
1481
+ },
1482
+ "invoice_id": {
1483
+ "name": "invoice_id",
1484
+ "type": "uuid",
1485
+ "primaryKey": false,
1486
+ "notNull": true
1487
+ },
1488
+ "version": {
1489
+ "name": "version",
1490
+ "type": "integer",
1491
+ "primaryKey": false,
1492
+ "notNull": true
1493
+ },
1494
+ "issued_at": {
1495
+ "name": "issued_at",
1496
+ "type": "timestamp with time zone",
1497
+ "primaryKey": false,
1498
+ "notNull": true,
1499
+ "default": "now()"
1500
+ },
1501
+ "issued_by": {
1502
+ "name": "issued_by",
1503
+ "type": "text",
1504
+ "primaryKey": false,
1505
+ "notNull": true
1506
+ },
1507
+ "document": {
1508
+ "name": "document",
1509
+ "type": "jsonb",
1510
+ "primaryKey": false,
1511
+ "notNull": true
1512
+ }
1513
+ },
1514
+ "indexes": {},
1515
+ "foreignKeys": {
1516
+ "invoice_versions_invoice_same_org": {
1517
+ "name": "invoice_versions_invoice_same_org",
1518
+ "tableFrom": "invoice_versions",
1519
+ "tableTo": "invoices",
1520
+ "columnsFrom": [
1521
+ "organisation_id",
1522
+ "invoice_id"
1523
+ ],
1524
+ "columnsTo": [
1525
+ "organisation_id",
1526
+ "id"
1527
+ ],
1528
+ "onDelete": "no action",
1529
+ "onUpdate": "no action"
1530
+ }
1531
+ },
1532
+ "compositePrimaryKeys": {},
1533
+ "uniqueConstraints": {
1534
+ "invoice_versions_invoice_version": {
1535
+ "name": "invoice_versions_invoice_version",
1536
+ "nullsNotDistinct": false,
1537
+ "columns": [
1538
+ "invoice_id",
1539
+ "version"
1540
+ ]
1541
+ }
1542
+ },
1543
+ "policies": {},
1544
+ "checkConstraints": {
1545
+ "invoice_versions_version_positive": {
1546
+ "name": "invoice_versions_version_positive",
1547
+ "value": "\"invoice_versions\".\"version\" > 0"
1548
+ }
1549
+ },
1550
+ "isRLSEnabled": false
1551
+ },
1552
+ "public.invoices": {
1553
+ "name": "invoices",
1554
+ "schema": "",
1555
+ "columns": {
1556
+ "id": {
1557
+ "name": "id",
1558
+ "type": "uuid",
1559
+ "primaryKey": true,
1560
+ "notNull": true,
1561
+ "default": "gen_random_uuid()"
1562
+ },
1563
+ "organisation_id": {
1564
+ "name": "organisation_id",
1565
+ "type": "uuid",
1566
+ "primaryKey": false,
1567
+ "notNull": true
1568
+ },
1569
+ "contact_id": {
1570
+ "name": "contact_id",
1571
+ "type": "uuid",
1572
+ "primaryKey": false,
1573
+ "notNull": true
1574
+ },
1575
+ "number": {
1576
+ "name": "number",
1577
+ "type": "text",
1578
+ "primaryKey": false,
1579
+ "notNull": false
1580
+ },
1581
+ "status": {
1582
+ "name": "status",
1583
+ "type": "text",
1584
+ "primaryKey": false,
1585
+ "notNull": true,
1586
+ "default": "'draft'"
1587
+ },
1588
+ "issued_version": {
1589
+ "name": "issued_version",
1590
+ "type": "integer",
1591
+ "primaryKey": false,
1592
+ "notNull": true,
1593
+ "default": 0
1594
+ },
1595
+ "reference": {
1596
+ "name": "reference",
1597
+ "type": "text",
1598
+ "primaryKey": false,
1599
+ "notNull": false
1600
+ },
1601
+ "currency": {
1602
+ "name": "currency",
1603
+ "type": "text",
1604
+ "primaryKey": false,
1605
+ "notNull": true,
1606
+ "default": "'AUD'"
1607
+ },
1608
+ "issue_date": {
1609
+ "name": "issue_date",
1610
+ "type": "date",
1611
+ "primaryKey": false,
1612
+ "notNull": false
1613
+ },
1614
+ "due_date": {
1615
+ "name": "due_date",
1616
+ "type": "date",
1617
+ "primaryKey": false,
1618
+ "notNull": false
1619
+ },
1620
+ "subtotal_cents": {
1621
+ "name": "subtotal_cents",
1622
+ "type": "integer",
1623
+ "primaryKey": false,
1624
+ "notNull": true,
1625
+ "default": 0
1626
+ },
1627
+ "tax_cents": {
1628
+ "name": "tax_cents",
1629
+ "type": "integer",
1630
+ "primaryKey": false,
1631
+ "notNull": true,
1632
+ "default": 0
1633
+ },
1634
+ "total_cents": {
1635
+ "name": "total_cents",
1636
+ "type": "integer",
1637
+ "primaryKey": false,
1638
+ "notNull": true,
1639
+ "default": 0
1640
+ },
1641
+ "ready_at": {
1642
+ "name": "ready_at",
1643
+ "type": "timestamp with time zone",
1644
+ "primaryKey": false,
1645
+ "notNull": false
1646
+ },
1647
+ "ready_by": {
1648
+ "name": "ready_by",
1649
+ "type": "uuid",
1650
+ "primaryKey": false,
1651
+ "notNull": false
1652
+ },
1653
+ "send_state": {
1654
+ "name": "send_state",
1655
+ "type": "text",
1656
+ "primaryKey": false,
1657
+ "notNull": false
1658
+ },
1659
+ "send_error": {
1660
+ "name": "send_error",
1661
+ "type": "jsonb",
1662
+ "primaryKey": false,
1663
+ "notNull": false
1664
+ },
1665
+ "send_requested_by": {
1666
+ "name": "send_requested_by",
1667
+ "type": "uuid",
1668
+ "primaryKey": false,
1669
+ "notNull": false
1670
+ },
1671
+ "send_updated_at": {
1672
+ "name": "send_updated_at",
1673
+ "type": "timestamp with time zone",
1674
+ "primaryKey": false,
1675
+ "notNull": false
1676
+ },
1677
+ "created_at": {
1678
+ "name": "created_at",
1679
+ "type": "timestamp with time zone",
1680
+ "primaryKey": false,
1681
+ "notNull": true,
1682
+ "default": "now()"
1683
+ },
1684
+ "updated_at": {
1685
+ "name": "updated_at",
1686
+ "type": "timestamp with time zone",
1687
+ "primaryKey": false,
1688
+ "notNull": true,
1689
+ "default": "now()"
1690
+ }
1691
+ },
1692
+ "indexes": {},
1693
+ "foreignKeys": {
1694
+ "invoices_organisation_id_organisations_id_fk": {
1695
+ "name": "invoices_organisation_id_organisations_id_fk",
1696
+ "tableFrom": "invoices",
1697
+ "tableTo": "organisations",
1698
+ "columnsFrom": [
1699
+ "organisation_id"
1700
+ ],
1701
+ "columnsTo": [
1702
+ "id"
1703
+ ],
1704
+ "onDelete": "no action",
1705
+ "onUpdate": "no action"
1706
+ },
1707
+ "invoices_ready_by_people_id_fk": {
1708
+ "name": "invoices_ready_by_people_id_fk",
1709
+ "tableFrom": "invoices",
1710
+ "tableTo": "people",
1711
+ "columnsFrom": [
1712
+ "ready_by"
1713
+ ],
1714
+ "columnsTo": [
1715
+ "id"
1716
+ ],
1717
+ "onDelete": "set null",
1718
+ "onUpdate": "no action"
1719
+ },
1720
+ "invoices_send_requested_by_people_id_fk": {
1721
+ "name": "invoices_send_requested_by_people_id_fk",
1722
+ "tableFrom": "invoices",
1723
+ "tableTo": "people",
1724
+ "columnsFrom": [
1725
+ "send_requested_by"
1726
+ ],
1727
+ "columnsTo": [
1728
+ "id"
1729
+ ],
1730
+ "onDelete": "set null",
1731
+ "onUpdate": "no action"
1732
+ },
1733
+ "invoices_contact_same_org": {
1734
+ "name": "invoices_contact_same_org",
1735
+ "tableFrom": "invoices",
1736
+ "tableTo": "contacts",
1737
+ "columnsFrom": [
1738
+ "organisation_id",
1739
+ "contact_id"
1740
+ ],
1741
+ "columnsTo": [
1742
+ "organisation_id",
1743
+ "id"
1744
+ ],
1745
+ "onDelete": "no action",
1746
+ "onUpdate": "no action"
1747
+ }
1748
+ },
1749
+ "compositePrimaryKeys": {},
1750
+ "uniqueConstraints": {
1751
+ "invoices_org_id": {
1752
+ "name": "invoices_org_id",
1753
+ "nullsNotDistinct": false,
1754
+ "columns": [
1755
+ "organisation_id",
1756
+ "id"
1757
+ ]
1758
+ },
1759
+ "invoices_org_number": {
1760
+ "name": "invoices_org_number",
1761
+ "nullsNotDistinct": false,
1762
+ "columns": [
1763
+ "organisation_id",
1764
+ "number"
1765
+ ]
1766
+ }
1767
+ },
1768
+ "policies": {},
1769
+ "checkConstraints": {
1770
+ "invoices_status_valid": {
1771
+ "name": "invoices_status_valid",
1772
+ "value": "\"invoices\".\"status\" in ('draft', 'issued', 'void')"
1773
+ },
1774
+ "invoices_issued_has_number": {
1775
+ "name": "invoices_issued_has_number",
1776
+ "value": "\"invoices\".\"status\" = 'draft' or \"invoices\".\"number\" is not null"
1777
+ },
1778
+ "invoices_send_state_valid": {
1779
+ "name": "invoices_send_state_valid",
1780
+ "value": "\"invoices\".\"send_state\" is null or \"invoices\".\"send_state\" in ('queued', 'sent', 'failed')"
1781
+ }
1782
+ },
1783
+ "isRLSEnabled": false
1784
+ },
1785
+ "public.invoicing_settings": {
1786
+ "name": "invoicing_settings",
1787
+ "schema": "",
1788
+ "columns": {
1789
+ "organisation_id": {
1790
+ "name": "organisation_id",
1791
+ "type": "uuid",
1792
+ "primaryKey": true,
1793
+ "notNull": true
1794
+ },
1795
+ "send_mode": {
1796
+ "name": "send_mode",
1797
+ "type": "text",
1798
+ "primaryKey": false,
1799
+ "notNull": true,
1800
+ "default": "'accounting_draft'"
1801
+ },
1802
+ "stale_days": {
1803
+ "name": "stale_days",
1804
+ "type": "integer",
1805
+ "primaryKey": false,
1806
+ "notNull": true,
1807
+ "default": 90
1808
+ },
1809
+ "payment_terms_days": {
1810
+ "name": "payment_terms_days",
1811
+ "type": "integer",
1812
+ "primaryKey": false,
1813
+ "notNull": true,
1814
+ "default": 30
1815
+ },
1816
+ "require_practitioner": {
1817
+ "name": "require_practitioner",
1818
+ "type": "boolean",
1819
+ "primaryKey": false,
1820
+ "notNull": true,
1821
+ "default": false
1822
+ },
1823
+ "rush_item_code": {
1824
+ "name": "rush_item_code",
1825
+ "type": "text",
1826
+ "primaryKey": false,
1827
+ "notNull": false
1828
+ },
1829
+ "rush_percent": {
1830
+ "name": "rush_percent",
1831
+ "type": "integer",
1832
+ "primaryKey": false,
1833
+ "notNull": true,
1834
+ "default": 20
1835
+ },
1836
+ "rules_seeded": {
1837
+ "name": "rules_seeded",
1838
+ "type": "boolean",
1839
+ "primaryKey": false,
1840
+ "notNull": true,
1841
+ "default": false
1842
+ },
1843
+ "updated_by": {
1844
+ "name": "updated_by",
1845
+ "type": "uuid",
1846
+ "primaryKey": false,
1847
+ "notNull": false
1848
+ },
1849
+ "updated_at": {
1850
+ "name": "updated_at",
1851
+ "type": "timestamp with time zone",
1852
+ "primaryKey": false,
1853
+ "notNull": true,
1854
+ "default": "now()"
1855
+ }
1856
+ },
1857
+ "indexes": {},
1858
+ "foreignKeys": {
1859
+ "invoicing_settings_organisation_id_organisations_id_fk": {
1860
+ "name": "invoicing_settings_organisation_id_organisations_id_fk",
1861
+ "tableFrom": "invoicing_settings",
1862
+ "tableTo": "organisations",
1863
+ "columnsFrom": [
1864
+ "organisation_id"
1865
+ ],
1866
+ "columnsTo": [
1867
+ "id"
1868
+ ],
1869
+ "onDelete": "no action",
1870
+ "onUpdate": "no action"
1871
+ },
1872
+ "invoicing_settings_updated_by_people_id_fk": {
1873
+ "name": "invoicing_settings_updated_by_people_id_fk",
1874
+ "tableFrom": "invoicing_settings",
1875
+ "tableTo": "people",
1876
+ "columnsFrom": [
1877
+ "updated_by"
1878
+ ],
1879
+ "columnsTo": [
1880
+ "id"
1881
+ ],
1882
+ "onDelete": "set null",
1883
+ "onUpdate": "no action"
1884
+ }
1885
+ },
1886
+ "compositePrimaryKeys": {},
1887
+ "uniqueConstraints": {},
1888
+ "policies": {},
1889
+ "checkConstraints": {
1890
+ "invoicing_settings_send_mode_valid": {
1891
+ "name": "invoicing_settings_send_mode_valid",
1892
+ "value": "send_mode in ('accounting_draft', 'approve_and_email')"
1893
+ },
1894
+ "invoicing_settings_stale_days_valid": {
1895
+ "name": "invoicing_settings_stale_days_valid",
1896
+ "value": "\"invoicing_settings\".\"stale_days\" between 1 and 3650"
1897
+ },
1898
+ "invoicing_settings_terms_valid": {
1899
+ "name": "invoicing_settings_terms_valid",
1900
+ "value": "\"invoicing_settings\".\"payment_terms_days\" between 0 and 365"
1901
+ },
1902
+ "invoicing_settings_rush_valid": {
1903
+ "name": "invoicing_settings_rush_valid",
1904
+ "value": "\"invoicing_settings\".\"rush_percent\" between 0 and 100"
1905
+ }
1906
+ },
1907
+ "isRLSEnabled": false
1908
+ },
1909
+ "public.link_rejections": {
1910
+ "name": "link_rejections",
1911
+ "schema": "",
1912
+ "columns": {
1913
+ "organisation_id": {
1914
+ "name": "organisation_id",
1915
+ "type": "uuid",
1916
+ "primaryKey": false,
1917
+ "notNull": true
1918
+ },
1919
+ "obligation_id": {
1920
+ "name": "obligation_id",
1921
+ "type": "uuid",
1922
+ "primaryKey": false,
1923
+ "notNull": true
1924
+ },
1925
+ "system": {
1926
+ "name": "system",
1927
+ "type": "text",
1928
+ "primaryKey": false,
1929
+ "notNull": true
1930
+ },
1931
+ "external_id": {
1932
+ "name": "external_id",
1933
+ "type": "text",
1934
+ "primaryKey": false,
1935
+ "notNull": true
1936
+ },
1937
+ "actor": {
1938
+ "name": "actor",
1939
+ "type": "text",
1940
+ "primaryKey": false,
1941
+ "notNull": true
1942
+ },
1943
+ "created_at": {
1944
+ "name": "created_at",
1945
+ "type": "timestamp with time zone",
1946
+ "primaryKey": false,
1947
+ "notNull": true,
1948
+ "default": "now()"
1949
+ }
1950
+ },
1951
+ "indexes": {},
1952
+ "foreignKeys": {
1953
+ "link_rejections_organisation_id_organisations_id_fk": {
1954
+ "name": "link_rejections_organisation_id_organisations_id_fk",
1955
+ "tableFrom": "link_rejections",
1956
+ "tableTo": "organisations",
1957
+ "columnsFrom": [
1958
+ "organisation_id"
1959
+ ],
1960
+ "columnsTo": [
1961
+ "id"
1962
+ ],
1963
+ "onDelete": "no action",
1964
+ "onUpdate": "no action"
1965
+ },
1966
+ "link_rejections_obligation_same_org": {
1967
+ "name": "link_rejections_obligation_same_org",
1968
+ "tableFrom": "link_rejections",
1969
+ "tableTo": "billing_obligations",
1970
+ "columnsFrom": [
1971
+ "organisation_id",
1972
+ "obligation_id"
1973
+ ],
1974
+ "columnsTo": [
1975
+ "organisation_id",
1976
+ "id"
1977
+ ],
1978
+ "onDelete": "no action",
1979
+ "onUpdate": "no action"
1980
+ }
1981
+ },
1982
+ "compositePrimaryKeys": {
1983
+ "link_rejections_pk": {
1984
+ "name": "link_rejections_pk",
1985
+ "columns": [
1986
+ "organisation_id",
1987
+ "obligation_id",
1988
+ "system",
1989
+ "external_id"
1990
+ ]
1991
+ }
1992
+ },
1993
+ "uniqueConstraints": {},
1994
+ "policies": {},
1995
+ "checkConstraints": {},
1996
+ "isRLSEnabled": false
1997
+ },
1998
+ "public.link_suggestions": {
1999
+ "name": "link_suggestions",
2000
+ "schema": "",
2001
+ "columns": {
2002
+ "id": {
2003
+ "name": "id",
2004
+ "type": "uuid",
2005
+ "primaryKey": true,
2006
+ "notNull": true,
2007
+ "default": "gen_random_uuid()"
2008
+ },
2009
+ "organisation_id": {
2010
+ "name": "organisation_id",
2011
+ "type": "uuid",
2012
+ "primaryKey": false,
2013
+ "notNull": true
2014
+ },
2015
+ "obligation_id": {
2016
+ "name": "obligation_id",
2017
+ "type": "uuid",
2018
+ "primaryKey": false,
2019
+ "notNull": true
2020
+ },
2021
+ "system": {
2022
+ "name": "system",
2023
+ "type": "text",
2024
+ "primaryKey": false,
2025
+ "notNull": true
2026
+ },
2027
+ "external_id": {
2028
+ "name": "external_id",
2029
+ "type": "text",
2030
+ "primaryKey": false,
2031
+ "notNull": true
2032
+ },
2033
+ "external_number": {
2034
+ "name": "external_number",
2035
+ "type": "text",
2036
+ "primaryKey": false,
2037
+ "notNull": false
2038
+ },
2039
+ "score": {
2040
+ "name": "score",
2041
+ "type": "integer",
2042
+ "primaryKey": false,
2043
+ "notNull": true
2044
+ },
2045
+ "rank": {
2046
+ "name": "rank",
2047
+ "type": "integer",
2048
+ "primaryKey": false,
2049
+ "notNull": true
2050
+ },
2051
+ "signals": {
2052
+ "name": "signals",
2053
+ "type": "jsonb",
2054
+ "primaryKey": false,
2055
+ "notNull": true,
2056
+ "default": "'[]'::jsonb"
2057
+ },
2058
+ "state": {
2059
+ "name": "state",
2060
+ "type": "text",
2061
+ "primaryKey": false,
2062
+ "notNull": true,
2063
+ "default": "'open'"
2064
+ },
2065
+ "decided_by": {
2066
+ "name": "decided_by",
2067
+ "type": "text",
2068
+ "primaryKey": false,
2069
+ "notNull": false
2070
+ },
2071
+ "decided_at": {
2072
+ "name": "decided_at",
2073
+ "type": "timestamp with time zone",
2074
+ "primaryKey": false,
2075
+ "notNull": false
2076
+ },
2077
+ "created_at": {
2078
+ "name": "created_at",
2079
+ "type": "timestamp with time zone",
2080
+ "primaryKey": false,
2081
+ "notNull": true,
2082
+ "default": "now()"
2083
+ },
2084
+ "updated_at": {
2085
+ "name": "updated_at",
2086
+ "type": "timestamp with time zone",
2087
+ "primaryKey": false,
2088
+ "notNull": true,
2089
+ "default": "now()"
2090
+ }
2091
+ },
2092
+ "indexes": {
2093
+ "link_suggestions_open": {
2094
+ "name": "link_suggestions_open",
2095
+ "columns": [
2096
+ {
2097
+ "expression": "organisation_id",
2098
+ "isExpression": false,
2099
+ "asc": true,
2100
+ "nulls": "last"
2101
+ },
2102
+ {
2103
+ "expression": "state",
2104
+ "isExpression": false,
2105
+ "asc": true,
2106
+ "nulls": "last"
2107
+ },
2108
+ {
2109
+ "expression": "obligation_id",
2110
+ "isExpression": false,
2111
+ "asc": true,
2112
+ "nulls": "last"
2113
+ }
2114
+ ],
2115
+ "isUnique": false,
2116
+ "concurrently": false,
2117
+ "method": "btree",
2118
+ "with": {}
2119
+ }
2120
+ },
2121
+ "foreignKeys": {
2122
+ "link_suggestions_organisation_id_organisations_id_fk": {
2123
+ "name": "link_suggestions_organisation_id_organisations_id_fk",
2124
+ "tableFrom": "link_suggestions",
2125
+ "tableTo": "organisations",
2126
+ "columnsFrom": [
2127
+ "organisation_id"
2128
+ ],
2129
+ "columnsTo": [
2130
+ "id"
2131
+ ],
2132
+ "onDelete": "no action",
2133
+ "onUpdate": "no action"
2134
+ },
2135
+ "link_suggestions_obligation_same_org": {
2136
+ "name": "link_suggestions_obligation_same_org",
2137
+ "tableFrom": "link_suggestions",
2138
+ "tableTo": "billing_obligations",
2139
+ "columnsFrom": [
2140
+ "organisation_id",
2141
+ "obligation_id"
2142
+ ],
2143
+ "columnsTo": [
2144
+ "organisation_id",
2145
+ "id"
2146
+ ],
2147
+ "onDelete": "no action",
2148
+ "onUpdate": "no action"
2149
+ }
2150
+ },
2151
+ "compositePrimaryKeys": {},
2152
+ "uniqueConstraints": {
2153
+ "link_suggestions_pair": {
2154
+ "name": "link_suggestions_pair",
2155
+ "nullsNotDistinct": false,
2156
+ "columns": [
2157
+ "organisation_id",
2158
+ "obligation_id",
2159
+ "system",
2160
+ "external_id"
2161
+ ]
2162
+ }
2163
+ },
2164
+ "policies": {},
2165
+ "checkConstraints": {
2166
+ "link_suggestions_state_valid": {
2167
+ "name": "link_suggestions_state_valid",
2168
+ "value": "state in ('open', 'accepted', 'rejected', 'stale')"
2169
+ }
2170
+ },
2171
+ "isRLSEnabled": false
2172
+ },
2173
+ "public.obligation_events": {
2174
+ "name": "obligation_events",
2175
+ "schema": "",
2176
+ "columns": {
2177
+ "id": {
2178
+ "name": "id",
2179
+ "type": "uuid",
2180
+ "primaryKey": true,
2181
+ "notNull": true,
2182
+ "default": "gen_random_uuid()"
2183
+ },
2184
+ "organisation_id": {
2185
+ "name": "organisation_id",
2186
+ "type": "uuid",
2187
+ "primaryKey": false,
2188
+ "notNull": true
2189
+ },
2190
+ "obligation_id": {
2191
+ "name": "obligation_id",
2192
+ "type": "uuid",
2193
+ "primaryKey": false,
2194
+ "notNull": true
2195
+ },
2196
+ "kind": {
2197
+ "name": "kind",
2198
+ "type": "text",
2199
+ "primaryKey": false,
2200
+ "notNull": true
2201
+ },
2202
+ "actor": {
2203
+ "name": "actor",
2204
+ "type": "text",
2205
+ "primaryKey": false,
2206
+ "notNull": true
2207
+ },
2208
+ "evidence": {
2209
+ "name": "evidence",
2210
+ "type": "jsonb",
2211
+ "primaryKey": false,
2212
+ "notNull": true,
2213
+ "default": "'{}'::jsonb"
2214
+ },
2215
+ "created_at": {
2216
+ "name": "created_at",
2217
+ "type": "timestamp with time zone",
2218
+ "primaryKey": false,
2219
+ "notNull": true,
2220
+ "default": "now()"
2221
+ }
2222
+ },
2223
+ "indexes": {},
2224
+ "foreignKeys": {
2225
+ "obligation_events_obligation_same_org": {
2226
+ "name": "obligation_events_obligation_same_org",
2227
+ "tableFrom": "obligation_events",
2228
+ "tableTo": "billing_obligations",
2229
+ "columnsFrom": [
2230
+ "organisation_id",
2231
+ "obligation_id"
2232
+ ],
2233
+ "columnsTo": [
2234
+ "organisation_id",
2235
+ "id"
2236
+ ],
2237
+ "onDelete": "no action",
2238
+ "onUpdate": "no action"
2239
+ }
2240
+ },
2241
+ "compositePrimaryKeys": {},
2242
+ "uniqueConstraints": {},
2243
+ "policies": {},
2244
+ "checkConstraints": {},
2245
+ "isRLSEnabled": false
2246
+ },
2247
+ "public.obligation_payments": {
2248
+ "name": "obligation_payments",
2249
+ "schema": "",
2250
+ "columns": {
2251
+ "id": {
2252
+ "name": "id",
2253
+ "type": "uuid",
2254
+ "primaryKey": true,
2255
+ "notNull": true,
2256
+ "default": "gen_random_uuid()"
2257
+ },
2258
+ "organisation_id": {
2259
+ "name": "organisation_id",
2260
+ "type": "uuid",
2261
+ "primaryKey": false,
2262
+ "notNull": true
2263
+ },
2264
+ "obligation_id": {
2265
+ "name": "obligation_id",
2266
+ "type": "uuid",
2267
+ "primaryKey": false,
2268
+ "notNull": true
2269
+ },
2270
+ "payment_ref": {
2271
+ "name": "payment_ref",
2272
+ "type": "text",
2273
+ "primaryKey": false,
2274
+ "notNull": true
2275
+ },
2276
+ "paid_on": {
2277
+ "name": "paid_on",
2278
+ "type": "date",
2279
+ "primaryKey": false,
2280
+ "notNull": true
2281
+ },
2282
+ "amount_cents": {
2283
+ "name": "amount_cents",
2284
+ "type": "integer",
2285
+ "primaryKey": false,
2286
+ "notNull": true
2287
+ },
2288
+ "reference": {
2289
+ "name": "reference",
2290
+ "type": "text",
2291
+ "primaryKey": false,
2292
+ "notNull": false
2293
+ },
2294
+ "reconciled": {
2295
+ "name": "reconciled",
2296
+ "type": "boolean",
2297
+ "primaryKey": false,
2298
+ "notNull": true
2299
+ },
2300
+ "accounting_url": {
2301
+ "name": "accounting_url",
2302
+ "type": "text",
2303
+ "primaryKey": false,
2304
+ "notNull": false
2305
+ },
2306
+ "observed_at": {
2307
+ "name": "observed_at",
2308
+ "type": "timestamp with time zone",
2309
+ "primaryKey": false,
2310
+ "notNull": true,
2311
+ "default": "now()"
2312
+ }
2313
+ },
2314
+ "indexes": {},
2315
+ "foreignKeys": {
2316
+ "obligation_payments_obligation_same_org": {
2317
+ "name": "obligation_payments_obligation_same_org",
2318
+ "tableFrom": "obligation_payments",
2319
+ "tableTo": "billing_obligations",
2320
+ "columnsFrom": [
2321
+ "organisation_id",
2322
+ "obligation_id"
2323
+ ],
2324
+ "columnsTo": [
2325
+ "organisation_id",
2326
+ "id"
2327
+ ],
2328
+ "onDelete": "no action",
2329
+ "onUpdate": "no action"
2330
+ }
2331
+ },
2332
+ "compositePrimaryKeys": {},
2333
+ "uniqueConstraints": {
2334
+ "obligation_payments_ref": {
2335
+ "name": "obligation_payments_ref",
2336
+ "nullsNotDistinct": false,
2337
+ "columns": [
2338
+ "organisation_id",
2339
+ "obligation_id",
2340
+ "payment_ref"
2341
+ ]
2342
+ }
2343
+ },
2344
+ "policies": {},
2345
+ "checkConstraints": {
2346
+ "obligation_payments_amount_positive": {
2347
+ "name": "obligation_payments_amount_positive",
2348
+ "value": "\"obligation_payments\".\"amount_cents\" > 0"
2349
+ }
2350
+ },
2351
+ "isRLSEnabled": false
2352
+ },
2353
+ "public.obligation_writebacks": {
2354
+ "name": "obligation_writebacks",
2355
+ "schema": "",
2356
+ "columns": {
2357
+ "id": {
2358
+ "name": "id",
2359
+ "type": "uuid",
2360
+ "primaryKey": true,
2361
+ "notNull": true,
2362
+ "default": "gen_random_uuid()"
2363
+ },
2364
+ "organisation_id": {
2365
+ "name": "organisation_id",
2366
+ "type": "uuid",
2367
+ "primaryKey": false,
2368
+ "notNull": true
2369
+ },
2370
+ "obligation_id": {
2371
+ "name": "obligation_id",
2372
+ "type": "uuid",
2373
+ "primaryKey": false,
2374
+ "notNull": true
2375
+ },
2376
+ "target_system": {
2377
+ "name": "target_system",
2378
+ "type": "text",
2379
+ "primaryKey": false,
2380
+ "notNull": true
2381
+ },
2382
+ "status": {
2383
+ "name": "status",
2384
+ "type": "text",
2385
+ "primaryKey": false,
2386
+ "notNull": true
2387
+ },
2388
+ "state": {
2389
+ "name": "state",
2390
+ "type": "text",
2391
+ "primaryKey": false,
2392
+ "notNull": true,
2393
+ "default": "'pending'"
2394
+ },
2395
+ "evidence": {
2396
+ "name": "evidence",
2397
+ "type": "jsonb",
2398
+ "primaryKey": false,
2399
+ "notNull": true
2400
+ },
2401
+ "attempts": {
2402
+ "name": "attempts",
2403
+ "type": "integer",
2404
+ "primaryKey": false,
2405
+ "notNull": true,
2406
+ "default": 0
2407
+ },
2408
+ "last_error": {
2409
+ "name": "last_error",
2410
+ "type": "text",
2411
+ "primaryKey": false,
2412
+ "notNull": false
2413
+ },
2414
+ "sent_at": {
2415
+ "name": "sent_at",
2416
+ "type": "timestamp with time zone",
2417
+ "primaryKey": false,
2418
+ "notNull": false
2419
+ },
2420
+ "created_at": {
2421
+ "name": "created_at",
2422
+ "type": "timestamp with time zone",
2423
+ "primaryKey": false,
2424
+ "notNull": true,
2425
+ "default": "now()"
2426
+ },
2427
+ "updated_at": {
2428
+ "name": "updated_at",
2429
+ "type": "timestamp with time zone",
2430
+ "primaryKey": false,
2431
+ "notNull": true,
2432
+ "default": "now()"
2433
+ }
2434
+ },
2435
+ "indexes": {},
2436
+ "foreignKeys": {
2437
+ "obligation_writebacks_obligation_same_org": {
2438
+ "name": "obligation_writebacks_obligation_same_org",
2439
+ "tableFrom": "obligation_writebacks",
2440
+ "tableTo": "billing_obligations",
2441
+ "columnsFrom": [
2442
+ "organisation_id",
2443
+ "obligation_id"
2444
+ ],
2445
+ "columnsTo": [
2446
+ "organisation_id",
2447
+ "id"
2448
+ ],
2449
+ "onDelete": "no action",
2450
+ "onUpdate": "no action"
2451
+ }
2452
+ },
2453
+ "compositePrimaryKeys": {},
2454
+ "uniqueConstraints": {
2455
+ "obligation_writebacks_status": {
2456
+ "name": "obligation_writebacks_status",
2457
+ "nullsNotDistinct": false,
2458
+ "columns": [
2459
+ "organisation_id",
2460
+ "obligation_id",
2461
+ "status"
2462
+ ]
2463
+ }
2464
+ },
2465
+ "policies": {},
2466
+ "checkConstraints": {
2467
+ "obligation_writebacks_state_valid": {
2468
+ "name": "obligation_writebacks_state_valid",
2469
+ "value": "state in ('pending', 'sent', 'failed', 'not_supported')"
2470
+ }
2471
+ },
2472
+ "isRLSEnabled": false
2473
+ },
2474
+ "public.organisations": {
2475
+ "name": "organisations",
2476
+ "schema": "",
2477
+ "columns": {
2478
+ "id": {
2479
+ "name": "id",
2480
+ "type": "uuid",
2481
+ "primaryKey": true,
2482
+ "notNull": true,
2483
+ "default": "gen_random_uuid()"
2484
+ },
2485
+ "name": {
2486
+ "name": "name",
2487
+ "type": "text",
2488
+ "primaryKey": false,
2489
+ "notNull": true
2490
+ },
2491
+ "invoice_prefix": {
2492
+ "name": "invoice_prefix",
2493
+ "type": "text",
2494
+ "primaryKey": false,
2495
+ "notNull": true,
2496
+ "default": "'INV-'"
2497
+ },
2498
+ "next_invoice_number": {
2499
+ "name": "next_invoice_number",
2500
+ "type": "integer",
2501
+ "primaryKey": false,
2502
+ "notNull": true,
2503
+ "default": 1
2504
+ },
2505
+ "created_at": {
2506
+ "name": "created_at",
2507
+ "type": "timestamp with time zone",
2508
+ "primaryKey": false,
2509
+ "notNull": true,
2510
+ "default": "now()"
2511
+ }
2512
+ },
2513
+ "indexes": {},
2514
+ "foreignKeys": {},
2515
+ "compositePrimaryKeys": {},
2516
+ "uniqueConstraints": {},
2517
+ "policies": {},
2518
+ "checkConstraints": {
2519
+ "organisations_next_invoice_number_positive": {
2520
+ "name": "organisations_next_invoice_number_positive",
2521
+ "value": "\"organisations\".\"next_invoice_number\" > 0"
2522
+ }
2523
+ },
2524
+ "isRLSEnabled": false
2525
+ },
2526
+ "public.outbox": {
2527
+ "name": "outbox",
2528
+ "schema": "",
2529
+ "columns": {
2530
+ "id": {
2531
+ "name": "id",
2532
+ "type": "uuid",
2533
+ "primaryKey": true,
2534
+ "notNull": true,
2535
+ "default": "gen_random_uuid()"
2536
+ },
2537
+ "organisation_id": {
2538
+ "name": "organisation_id",
2539
+ "type": "uuid",
2540
+ "primaryKey": false,
2541
+ "notNull": true
2542
+ },
2543
+ "system": {
2544
+ "name": "system",
2545
+ "type": "text",
2546
+ "primaryKey": false,
2547
+ "notNull": true
2548
+ },
2549
+ "action": {
2550
+ "name": "action",
2551
+ "type": "text",
2552
+ "primaryKey": false,
2553
+ "notNull": true
2554
+ },
2555
+ "entity": {
2556
+ "name": "entity",
2557
+ "type": "text",
2558
+ "primaryKey": false,
2559
+ "notNull": true
2560
+ },
2561
+ "flow_id": {
2562
+ "name": "flow_id",
2563
+ "type": "uuid",
2564
+ "primaryKey": false,
2565
+ "notNull": true
2566
+ },
2567
+ "idempotency_key": {
2568
+ "name": "idempotency_key",
2569
+ "type": "text",
2570
+ "primaryKey": false,
2571
+ "notNull": true
2572
+ },
2573
+ "request": {
2574
+ "name": "request",
2575
+ "type": "jsonb",
2576
+ "primaryKey": false,
2577
+ "notNull": true
2578
+ },
2579
+ "state": {
2580
+ "name": "state",
2581
+ "type": "text",
2582
+ "primaryKey": false,
2583
+ "notNull": true,
2584
+ "default": "'pending'"
2585
+ },
2586
+ "external_id": {
2587
+ "name": "external_id",
2588
+ "type": "text",
2589
+ "primaryKey": false,
2590
+ "notNull": false
2591
+ },
2592
+ "attempts": {
2593
+ "name": "attempts",
2594
+ "type": "integer",
2595
+ "primaryKey": false,
2596
+ "notNull": true,
2597
+ "default": 0
2598
+ },
2599
+ "last_error": {
2600
+ "name": "last_error",
2601
+ "type": "text",
2602
+ "primaryKey": false,
2603
+ "notNull": false
2604
+ },
2605
+ "created_by": {
2606
+ "name": "created_by",
2607
+ "type": "text",
2608
+ "primaryKey": false,
2609
+ "notNull": true
2610
+ },
2611
+ "sent_at": {
2612
+ "name": "sent_at",
2613
+ "type": "timestamp with time zone",
2614
+ "primaryKey": false,
2615
+ "notNull": false
2616
+ },
2617
+ "created_at": {
2618
+ "name": "created_at",
2619
+ "type": "timestamp with time zone",
2620
+ "primaryKey": false,
2621
+ "notNull": true,
2622
+ "default": "now()"
2623
+ },
2624
+ "updated_at": {
2625
+ "name": "updated_at",
2626
+ "type": "timestamp with time zone",
2627
+ "primaryKey": false,
2628
+ "notNull": true,
2629
+ "default": "now()"
2630
+ }
2631
+ },
2632
+ "indexes": {
2633
+ "outbox_pending": {
2634
+ "name": "outbox_pending",
2635
+ "columns": [
2636
+ {
2637
+ "expression": "system",
2638
+ "isExpression": false,
2639
+ "asc": true,
2640
+ "nulls": "last"
2641
+ },
2642
+ {
2643
+ "expression": "state",
2644
+ "isExpression": false,
2645
+ "asc": true,
2646
+ "nulls": "last"
2647
+ },
2648
+ {
2649
+ "expression": "created_at",
2650
+ "isExpression": false,
2651
+ "asc": true,
2652
+ "nulls": "last"
2653
+ }
2654
+ ],
2655
+ "isUnique": false,
2656
+ "concurrently": false,
2657
+ "method": "btree",
2658
+ "with": {}
2659
+ }
2660
+ },
2661
+ "foreignKeys": {
2662
+ "outbox_organisation_id_organisations_id_fk": {
2663
+ "name": "outbox_organisation_id_organisations_id_fk",
2664
+ "tableFrom": "outbox",
2665
+ "tableTo": "organisations",
2666
+ "columnsFrom": [
2667
+ "organisation_id"
2668
+ ],
2669
+ "columnsTo": [
2670
+ "id"
2671
+ ],
2672
+ "onDelete": "no action",
2673
+ "onUpdate": "no action"
2674
+ }
2675
+ },
2676
+ "compositePrimaryKeys": {},
2677
+ "uniqueConstraints": {
2678
+ "outbox_org_id": {
2679
+ "name": "outbox_org_id",
2680
+ "nullsNotDistinct": false,
2681
+ "columns": [
2682
+ "organisation_id",
2683
+ "id"
2684
+ ]
2685
+ },
2686
+ "outbox_idempotency_key": {
2687
+ "name": "outbox_idempotency_key",
2688
+ "nullsNotDistinct": false,
2689
+ "columns": [
2690
+ "idempotency_key"
2691
+ ]
2692
+ }
2693
+ },
2694
+ "policies": {},
2695
+ "checkConstraints": {
2696
+ "outbox_state_valid": {
2697
+ "name": "outbox_state_valid",
2698
+ "value": "state in ('pending', 'sending', 'ambiguous', 'sent', 'failed', 'cancelled')"
2699
+ },
2700
+ "outbox_sent_has_id": {
2701
+ "name": "outbox_sent_has_id",
2702
+ "value": "\"outbox\".\"state\" <> 'sent' or \"outbox\".\"external_id\" is not null"
2703
+ }
2704
+ },
2705
+ "isRLSEnabled": false
2706
+ },
2707
+ "public.people": {
2708
+ "name": "people",
2709
+ "schema": "",
2710
+ "columns": {
2711
+ "id": {
2712
+ "name": "id",
2713
+ "type": "uuid",
2714
+ "primaryKey": true,
2715
+ "notNull": true,
2716
+ "default": "gen_random_uuid()"
2717
+ },
2718
+ "email": {
2719
+ "name": "email",
2720
+ "type": "text",
2721
+ "primaryKey": false,
2722
+ "notNull": true
2723
+ },
2724
+ "name": {
2725
+ "name": "name",
2726
+ "type": "text",
2727
+ "primaryKey": false,
2728
+ "notNull": false
2729
+ },
2730
+ "role": {
2731
+ "name": "role",
2732
+ "type": "text",
2733
+ "primaryKey": false,
2734
+ "notNull": true
2735
+ },
2736
+ "status": {
2737
+ "name": "status",
2738
+ "type": "text",
2739
+ "primaryKey": false,
2740
+ "notNull": true,
2741
+ "default": "'active'"
2742
+ },
2743
+ "clerk_user_id": {
2744
+ "name": "clerk_user_id",
2745
+ "type": "text",
2746
+ "primaryKey": false,
2747
+ "notNull": false
2748
+ },
2749
+ "invited_by": {
2750
+ "name": "invited_by",
2751
+ "type": "uuid",
2752
+ "primaryKey": false,
2753
+ "notNull": false
2754
+ },
2755
+ "linked_at": {
2756
+ "name": "linked_at",
2757
+ "type": "timestamp with time zone",
2758
+ "primaryKey": false,
2759
+ "notNull": false
2760
+ },
2761
+ "appearance": {
2762
+ "name": "appearance",
2763
+ "type": "jsonb",
2764
+ "primaryKey": false,
2765
+ "notNull": false
2766
+ },
2767
+ "created_at": {
2768
+ "name": "created_at",
2769
+ "type": "timestamp with time zone",
2770
+ "primaryKey": false,
2771
+ "notNull": true,
2772
+ "default": "now()"
2773
+ },
2774
+ "updated_at": {
2775
+ "name": "updated_at",
2776
+ "type": "timestamp with time zone",
2777
+ "primaryKey": false,
2778
+ "notNull": true,
2779
+ "default": "now()"
2780
+ }
2781
+ },
2782
+ "indexes": {},
2783
+ "foreignKeys": {
2784
+ "people_invited_by_people_id_fk": {
2785
+ "name": "people_invited_by_people_id_fk",
2786
+ "tableFrom": "people",
2787
+ "tableTo": "people",
2788
+ "columnsFrom": [
2789
+ "invited_by"
2790
+ ],
2791
+ "columnsTo": [
2792
+ "id"
2793
+ ],
2794
+ "onDelete": "set null",
2795
+ "onUpdate": "no action"
2796
+ }
2797
+ },
2798
+ "compositePrimaryKeys": {},
2799
+ "uniqueConstraints": {
2800
+ "people_email": {
2801
+ "name": "people_email",
2802
+ "nullsNotDistinct": false,
2803
+ "columns": [
2804
+ "email"
2805
+ ]
2806
+ },
2807
+ "people_clerk_user_id": {
2808
+ "name": "people_clerk_user_id",
2809
+ "nullsNotDistinct": false,
2810
+ "columns": [
2811
+ "clerk_user_id"
2812
+ ]
2813
+ }
2814
+ },
2815
+ "policies": {},
2816
+ "checkConstraints": {
2817
+ "people_email_lower": {
2818
+ "name": "people_email_lower",
2819
+ "value": "\"people\".\"email\" = lower(\"people\".\"email\")"
2820
+ },
2821
+ "people_role_valid": {
2822
+ "name": "people_role_valid",
2823
+ "value": "\"people\".\"role\" in ('owner', 'admin', 'staff')"
2824
+ },
2825
+ "people_status_valid": {
2826
+ "name": "people_status_valid",
2827
+ "value": "\"people\".\"status\" in ('active', 'pending', 'disabled')"
2828
+ }
2829
+ },
2830
+ "isRLSEnabled": false
2831
+ },
2832
+ "public.pipeline_cursors": {
2833
+ "name": "pipeline_cursors",
2834
+ "schema": "",
2835
+ "columns": {
2836
+ "organisation_id": {
2837
+ "name": "organisation_id",
2838
+ "type": "uuid",
2839
+ "primaryKey": false,
2840
+ "notNull": true
2841
+ },
2842
+ "name": {
2843
+ "name": "name",
2844
+ "type": "text",
2845
+ "primaryKey": false,
2846
+ "notNull": true
2847
+ },
2848
+ "cursor": {
2849
+ "name": "cursor",
2850
+ "type": "text",
2851
+ "primaryKey": false,
2852
+ "notNull": false
2853
+ },
2854
+ "updated_at": {
2855
+ "name": "updated_at",
2856
+ "type": "timestamp with time zone",
2857
+ "primaryKey": false,
2858
+ "notNull": true,
2859
+ "default": "now()"
2860
+ }
2861
+ },
2862
+ "indexes": {},
2863
+ "foreignKeys": {
2864
+ "pipeline_cursors_organisation_id_organisations_id_fk": {
2865
+ "name": "pipeline_cursors_organisation_id_organisations_id_fk",
2866
+ "tableFrom": "pipeline_cursors",
2867
+ "tableTo": "organisations",
2868
+ "columnsFrom": [
2869
+ "organisation_id"
2870
+ ],
2871
+ "columnsTo": [
2872
+ "id"
2873
+ ],
2874
+ "onDelete": "no action",
2875
+ "onUpdate": "no action"
2876
+ }
2877
+ },
2878
+ "compositePrimaryKeys": {
2879
+ "pipeline_cursors_pk": {
2880
+ "name": "pipeline_cursors_pk",
2881
+ "columns": [
2882
+ "organisation_id",
2883
+ "name"
2884
+ ]
2885
+ }
2886
+ },
2887
+ "uniqueConstraints": {},
2888
+ "policies": {},
2889
+ "checkConstraints": {},
2890
+ "isRLSEnabled": false
2891
+ },
2892
+ "public.price_items": {
2893
+ "name": "price_items",
2894
+ "schema": "",
2895
+ "columns": {
2896
+ "id": {
2897
+ "name": "id",
2898
+ "type": "uuid",
2899
+ "primaryKey": true,
2900
+ "notNull": true,
2901
+ "default": "gen_random_uuid()"
2902
+ },
2903
+ "organisation_id": {
2904
+ "name": "organisation_id",
2905
+ "type": "uuid",
2906
+ "primaryKey": false,
2907
+ "notNull": true
2908
+ },
2909
+ "code": {
2910
+ "name": "code",
2911
+ "type": "text",
2912
+ "primaryKey": false,
2913
+ "notNull": true
2914
+ },
2915
+ "name": {
2916
+ "name": "name",
2917
+ "type": "text",
2918
+ "primaryKey": false,
2919
+ "notNull": true
2920
+ },
2921
+ "unit_amount_cents": {
2922
+ "name": "unit_amount_cents",
2923
+ "type": "integer",
2924
+ "primaryKey": false,
2925
+ "notNull": true
2926
+ },
2927
+ "tax_code": {
2928
+ "name": "tax_code",
2929
+ "type": "text",
2930
+ "primaryKey": false,
2931
+ "notNull": true,
2932
+ "default": "'GST'"
2933
+ },
2934
+ "archived_at": {
2935
+ "name": "archived_at",
2936
+ "type": "timestamp with time zone",
2937
+ "primaryKey": false,
2938
+ "notNull": false
2939
+ },
2940
+ "created_at": {
2941
+ "name": "created_at",
2942
+ "type": "timestamp with time zone",
2943
+ "primaryKey": false,
2944
+ "notNull": true,
2945
+ "default": "now()"
2946
+ }
2947
+ },
2948
+ "indexes": {},
2949
+ "foreignKeys": {
2950
+ "price_items_organisation_id_organisations_id_fk": {
2951
+ "name": "price_items_organisation_id_organisations_id_fk",
2952
+ "tableFrom": "price_items",
2953
+ "tableTo": "organisations",
2954
+ "columnsFrom": [
2955
+ "organisation_id"
2956
+ ],
2957
+ "columnsTo": [
2958
+ "id"
2959
+ ],
2960
+ "onDelete": "no action",
2961
+ "onUpdate": "no action"
2962
+ }
2963
+ },
2964
+ "compositePrimaryKeys": {},
2965
+ "uniqueConstraints": {
2966
+ "price_items_org_id": {
2967
+ "name": "price_items_org_id",
2968
+ "nullsNotDistinct": false,
2969
+ "columns": [
2970
+ "organisation_id",
2971
+ "id"
2972
+ ]
2973
+ },
2974
+ "price_items_org_code": {
2975
+ "name": "price_items_org_code",
2976
+ "nullsNotDistinct": false,
2977
+ "columns": [
2978
+ "organisation_id",
2979
+ "code"
2980
+ ]
2981
+ }
2982
+ },
2983
+ "policies": {},
2984
+ "checkConstraints": {
2985
+ "price_items_tax_code_valid": {
2986
+ "name": "price_items_tax_code_valid",
2987
+ "value": "\"price_items\".\"tax_code\" in ('GST', 'GST_FREE')"
2988
+ }
2989
+ },
2990
+ "isRLSEnabled": false
2991
+ },
2992
+ "public.prior_links": {
2993
+ "name": "prior_links",
2994
+ "schema": "",
2995
+ "columns": {
2996
+ "id": {
2997
+ "name": "id",
2998
+ "type": "uuid",
2999
+ "primaryKey": true,
3000
+ "notNull": true,
3001
+ "default": "gen_random_uuid()"
3002
+ },
3003
+ "organisation_id": {
3004
+ "name": "organisation_id",
3005
+ "type": "uuid",
3006
+ "primaryKey": false,
3007
+ "notNull": true
3008
+ },
3009
+ "source_system": {
3010
+ "name": "source_system",
3011
+ "type": "text",
3012
+ "primaryKey": false,
3013
+ "notNull": true
3014
+ },
3015
+ "source_job_ref": {
3016
+ "name": "source_job_ref",
3017
+ "type": "text",
3018
+ "primaryKey": false,
3019
+ "notNull": true
3020
+ },
3021
+ "system": {
3022
+ "name": "system",
3023
+ "type": "text",
3024
+ "primaryKey": false,
3025
+ "notNull": true
3026
+ },
3027
+ "external_id": {
3028
+ "name": "external_id",
3029
+ "type": "text",
3030
+ "primaryKey": false,
3031
+ "notNull": true
3032
+ },
3033
+ "external_number": {
3034
+ "name": "external_number",
3035
+ "type": "text",
3036
+ "primaryKey": false,
3037
+ "notNull": false
3038
+ },
3039
+ "matched_by": {
3040
+ "name": "matched_by",
3041
+ "type": "text",
3042
+ "primaryKey": false,
3043
+ "notNull": true
3044
+ },
3045
+ "matched_at": {
3046
+ "name": "matched_at",
3047
+ "type": "timestamp with time zone",
3048
+ "primaryKey": false,
3049
+ "notNull": false
3050
+ },
3051
+ "origin": {
3052
+ "name": "origin",
3053
+ "type": "text",
3054
+ "primaryKey": false,
3055
+ "notNull": true
3056
+ },
3057
+ "created_at": {
3058
+ "name": "created_at",
3059
+ "type": "timestamp with time zone",
3060
+ "primaryKey": false,
3061
+ "notNull": true,
3062
+ "default": "now()"
3063
+ }
3064
+ },
3065
+ "indexes": {
3066
+ "prior_links_job": {
3067
+ "name": "prior_links_job",
3068
+ "columns": [
3069
+ {
3070
+ "expression": "organisation_id",
3071
+ "isExpression": false,
3072
+ "asc": true,
3073
+ "nulls": "last"
3074
+ },
3075
+ {
3076
+ "expression": "source_system",
3077
+ "isExpression": false,
3078
+ "asc": true,
3079
+ "nulls": "last"
3080
+ },
3081
+ {
3082
+ "expression": "source_job_ref",
3083
+ "isExpression": false,
3084
+ "asc": true,
3085
+ "nulls": "last"
3086
+ },
3087
+ {
3088
+ "expression": "system",
3089
+ "isExpression": false,
3090
+ "asc": true,
3091
+ "nulls": "last"
3092
+ }
3093
+ ],
3094
+ "isUnique": true,
3095
+ "concurrently": false,
3096
+ "method": "btree",
3097
+ "with": {}
3098
+ },
3099
+ "prior_links_external": {
3100
+ "name": "prior_links_external",
3101
+ "columns": [
3102
+ {
3103
+ "expression": "organisation_id",
3104
+ "isExpression": false,
3105
+ "asc": true,
3106
+ "nulls": "last"
3107
+ },
3108
+ {
3109
+ "expression": "system",
3110
+ "isExpression": false,
3111
+ "asc": true,
3112
+ "nulls": "last"
3113
+ },
3114
+ {
3115
+ "expression": "external_id",
3116
+ "isExpression": false,
3117
+ "asc": true,
3118
+ "nulls": "last"
3119
+ }
3120
+ ],
3121
+ "isUnique": false,
3122
+ "concurrently": false,
3123
+ "method": "btree",
3124
+ "with": {}
3125
+ }
3126
+ },
3127
+ "foreignKeys": {
3128
+ "prior_links_organisation_id_organisations_id_fk": {
3129
+ "name": "prior_links_organisation_id_organisations_id_fk",
3130
+ "tableFrom": "prior_links",
3131
+ "tableTo": "organisations",
3132
+ "columnsFrom": [
3133
+ "organisation_id"
3134
+ ],
3135
+ "columnsTo": [
3136
+ "id"
3137
+ ],
3138
+ "onDelete": "no action",
3139
+ "onUpdate": "no action"
3140
+ }
3141
+ },
3142
+ "compositePrimaryKeys": {},
3143
+ "uniqueConstraints": {},
3144
+ "policies": {},
3145
+ "checkConstraints": {
3146
+ "prior_links_matched_by_valid": {
3147
+ "name": "prior_links_matched_by_valid",
3148
+ "value": "matched_by in ('person', 'imported')"
3149
+ }
3150
+ },
3151
+ "isRLSEnabled": false
3152
+ },
3153
+ "public.review_items": {
3154
+ "name": "review_items",
3155
+ "schema": "",
3156
+ "columns": {
3157
+ "id": {
3158
+ "name": "id",
3159
+ "type": "uuid",
3160
+ "primaryKey": true,
3161
+ "notNull": true,
3162
+ "default": "gen_random_uuid()"
3163
+ },
3164
+ "organisation_id": {
3165
+ "name": "organisation_id",
3166
+ "type": "uuid",
3167
+ "primaryKey": false,
3168
+ "notNull": true
3169
+ },
3170
+ "kind": {
3171
+ "name": "kind",
3172
+ "type": "text",
3173
+ "primaryKey": false,
3174
+ "notNull": true
3175
+ },
3176
+ "entity": {
3177
+ "name": "entity",
3178
+ "type": "text",
3179
+ "primaryKey": false,
3180
+ "notNull": true
3181
+ },
3182
+ "flow_id": {
3183
+ "name": "flow_id",
3184
+ "type": "uuid",
3185
+ "primaryKey": false,
3186
+ "notNull": true
3187
+ },
3188
+ "systems": {
3189
+ "name": "systems",
3190
+ "type": "text[]",
3191
+ "primaryKey": false,
3192
+ "notNull": true,
3193
+ "default": "'{}'::text[]"
3194
+ },
3195
+ "evidence": {
3196
+ "name": "evidence",
3197
+ "type": "jsonb",
3198
+ "primaryKey": false,
3199
+ "notNull": true,
3200
+ "default": "'{}'::jsonb"
3201
+ },
3202
+ "money_at_risk_cents": {
3203
+ "name": "money_at_risk_cents",
3204
+ "type": "bigint",
3205
+ "primaryKey": false,
3206
+ "notNull": true,
3207
+ "default": 0
3208
+ },
3209
+ "state": {
3210
+ "name": "state",
3211
+ "type": "text",
3212
+ "primaryKey": false,
3213
+ "notNull": true,
3214
+ "default": "'open'"
3215
+ },
3216
+ "seen_count": {
3217
+ "name": "seen_count",
3218
+ "type": "integer",
3219
+ "primaryKey": false,
3220
+ "notNull": true,
3221
+ "default": 1
3222
+ },
3223
+ "resolution": {
3224
+ "name": "resolution",
3225
+ "type": "text",
3226
+ "primaryKey": false,
3227
+ "notNull": false
3228
+ },
3229
+ "note": {
3230
+ "name": "note",
3231
+ "type": "text",
3232
+ "primaryKey": false,
3233
+ "notNull": false
3234
+ },
3235
+ "resolved_by": {
3236
+ "name": "resolved_by",
3237
+ "type": "text",
3238
+ "primaryKey": false,
3239
+ "notNull": false
3240
+ },
3241
+ "resolved_at": {
3242
+ "name": "resolved_at",
3243
+ "type": "timestamp with time zone",
3244
+ "primaryKey": false,
3245
+ "notNull": false
3246
+ },
3247
+ "created_at": {
3248
+ "name": "created_at",
3249
+ "type": "timestamp with time zone",
3250
+ "primaryKey": false,
3251
+ "notNull": true,
3252
+ "default": "now()"
3253
+ },
3254
+ "updated_at": {
3255
+ "name": "updated_at",
3256
+ "type": "timestamp with time zone",
3257
+ "primaryKey": false,
3258
+ "notNull": true,
3259
+ "default": "now()"
3260
+ }
3261
+ },
3262
+ "indexes": {
3263
+ "review_items_one_open": {
3264
+ "name": "review_items_one_open",
3265
+ "columns": [
3266
+ {
3267
+ "expression": "organisation_id",
3268
+ "isExpression": false,
3269
+ "asc": true,
3270
+ "nulls": "last"
3271
+ },
3272
+ {
3273
+ "expression": "kind",
3274
+ "isExpression": false,
3275
+ "asc": true,
3276
+ "nulls": "last"
3277
+ },
3278
+ {
3279
+ "expression": "entity",
3280
+ "isExpression": false,
3281
+ "asc": true,
3282
+ "nulls": "last"
3283
+ },
3284
+ {
3285
+ "expression": "flow_id",
3286
+ "isExpression": false,
3287
+ "asc": true,
3288
+ "nulls": "last"
3289
+ }
3290
+ ],
3291
+ "isUnique": true,
3292
+ "where": "state = 'open'",
3293
+ "concurrently": false,
3294
+ "method": "btree",
3295
+ "with": {}
3296
+ },
3297
+ "review_items_queue": {
3298
+ "name": "review_items_queue",
3299
+ "columns": [
3300
+ {
3301
+ "expression": "organisation_id",
3302
+ "isExpression": false,
3303
+ "asc": true,
3304
+ "nulls": "last"
3305
+ },
3306
+ {
3307
+ "expression": "state",
3308
+ "isExpression": false,
3309
+ "asc": true,
3310
+ "nulls": "last"
3311
+ },
3312
+ {
3313
+ "expression": "money_at_risk_cents",
3314
+ "isExpression": false,
3315
+ "asc": true,
3316
+ "nulls": "last"
3317
+ }
3318
+ ],
3319
+ "isUnique": false,
3320
+ "concurrently": false,
3321
+ "method": "btree",
3322
+ "with": {}
3323
+ }
3324
+ },
3325
+ "foreignKeys": {
3326
+ "review_items_organisation_id_organisations_id_fk": {
3327
+ "name": "review_items_organisation_id_organisations_id_fk",
3328
+ "tableFrom": "review_items",
3329
+ "tableTo": "organisations",
3330
+ "columnsFrom": [
3331
+ "organisation_id"
3332
+ ],
3333
+ "columnsTo": [
3334
+ "id"
3335
+ ],
3336
+ "onDelete": "no action",
3337
+ "onUpdate": "no action"
3338
+ }
3339
+ },
3340
+ "compositePrimaryKeys": {},
3341
+ "uniqueConstraints": {
3342
+ "review_items_org_id": {
3343
+ "name": "review_items_org_id",
3344
+ "nullsNotDistinct": false,
3345
+ "columns": [
3346
+ "organisation_id",
3347
+ "id"
3348
+ ]
3349
+ }
3350
+ },
3351
+ "policies": {},
3352
+ "checkConstraints": {
3353
+ "review_items_state_valid": {
3354
+ "name": "review_items_state_valid",
3355
+ "value": "state in ('open', 'resolved', 'dismissed')"
3356
+ },
3357
+ "review_items_money_not_negative": {
3358
+ "name": "review_items_money_not_negative",
3359
+ "value": "\"review_items\".\"money_at_risk_cents\" >= 0"
3360
+ },
3361
+ "review_items_closed_has_resolution": {
3362
+ "name": "review_items_closed_has_resolution",
3363
+ "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)"
3364
+ }
3365
+ },
3366
+ "isRLSEnabled": false
3367
+ }
3368
+ },
3369
+ "enums": {},
3370
+ "schemas": {},
3371
+ "sequences": {},
3372
+ "roles": {},
3373
+ "policies": {},
3374
+ "views": {},
3375
+ "_meta": {
3376
+ "columns": {},
3377
+ "schemas": {},
3378
+ "tables": {}
3379
+ }
3380
+ }