@arcforgelabs/flow 2026.10.33 → 2026.10.35

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