@arcforgelabs/flow 2026.10.37 → 2026.10.39

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 (57) hide show
  1. package/README.md +2 -1
  2. package/npm-shrinkwrap.json +2 -2
  3. package/package.json +4 -2
  4. package/server/api/custom-fields.js +27 -9
  5. package/server/api/invoicing.js +198 -51
  6. package/server/app.js +5 -2
  7. package/server/core/alerts.js +1 -1
  8. package/server/core/automations.js +1 -1
  9. package/server/core/custom-fields.js +89 -3
  10. package/server/core/job-board.js +2 -1
  11. package/server/core/job-match.js +241 -0
  12. package/server/core/ledger.js +109 -8
  13. package/server/core/price-list.js +27 -2
  14. package/server/core/read-before-act.js +3 -2
  15. package/server/core/sending.js +36 -18
  16. package/server/db/doctor.js +18 -19
  17. package/server/db/index.js +74 -3
  18. package/server/db/migrate-all.js +3 -4
  19. package/server/db/migrations/0020_custom_field_colours.sql +21 -0
  20. package/server/db/migrations/meta/0020_snapshot.json +4377 -0
  21. package/server/db/migrations/meta/_journal.json +7 -0
  22. package/server/db/schema.js +14 -0
  23. package/server/integrations/call-guard.js +148 -0
  24. package/server/integrations/port.js +3 -2
  25. package/server/integrations/schema.js +9 -5
  26. package/server/integrations/seazona/feed.js +4 -1
  27. package/server/integrations/seazona/settings.js +8 -4
  28. package/server/integrations/xero/drafts.js +4 -4
  29. package/server/integrations/xero/fit.js +108 -0
  30. package/server/integrations/xero/import.js +6 -1
  31. package/server/integrations/xero/index.js +6 -2
  32. package/server/integrations/xero/ledger.js +3 -0
  33. package/server/integrations/xero/links.js +293 -0
  34. package/server/integrations/xero/migrations/0008_xero_invoice_links.sql +26 -0
  35. package/server/integrations/xero/migrations/0009_xero_sent_to_contact.sql +3 -0
  36. package/server/integrations/xero/migrations/meta/_journal.json +14 -0
  37. package/server/integrations/xero/mirror.js +4 -3
  38. package/server/integrations/xero/reconcile.js +42 -12
  39. package/server/integrations/xero/routes.js +66 -7
  40. package/server/integrations/xero/settings.js +6 -5
  41. package/server/ui/app-page.js +1 -1
  42. package/server/ui/app.js +89 -3
  43. package/server/ui/bulk-bar.js +4 -3
  44. package/server/ui/custom-fields.js +252 -94
  45. package/server/ui/flow.css +326 -29
  46. package/server/ui/invoice-notes.js +2 -2
  47. package/server/ui/invoicing.js +92 -137
  48. package/server/ui/job-board.js +9 -7
  49. package/server/ui/job-change.js +23 -12
  50. package/server/ui/job-view.js +189 -31
  51. package/server/ui/jobs.js +738 -70
  52. package/server/ui/price-list.js +43 -86
  53. package/server/ui/price-match.js +93 -0
  54. package/server/ui/price-reconcile.js +357 -0
  55. package/server/ui/reconcile.js +275 -0
  56. package/server/ui/routes.js +1 -1
  57. package/server/ui/xero-import.js +329 -0
@@ -0,0 +1,4377 @@
1
+ {
2
+ "id": "8b05cd6a-08f3-4268-9c93-fb6d2c929c77",
3
+ "prevId": "8d7ccaa0-6dfa-4b40-bd22-c24f341dc081",
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_settings": {
2155
+ "name": "job_field_settings",
2156
+ "schema": "",
2157
+ "columns": {
2158
+ "organisation_id": {
2159
+ "name": "organisation_id",
2160
+ "type": "uuid",
2161
+ "primaryKey": true,
2162
+ "notNull": true
2163
+ },
2164
+ "group_colors": {
2165
+ "name": "group_colors",
2166
+ "type": "jsonb",
2167
+ "primaryKey": false,
2168
+ "notNull": true,
2169
+ "default": "'{}'::jsonb"
2170
+ },
2171
+ "assignee_made_at": {
2172
+ "name": "assignee_made_at",
2173
+ "type": "timestamp with time zone",
2174
+ "primaryKey": false,
2175
+ "notNull": false
2176
+ },
2177
+ "updated_by": {
2178
+ "name": "updated_by",
2179
+ "type": "uuid",
2180
+ "primaryKey": false,
2181
+ "notNull": false
2182
+ },
2183
+ "updated_at": {
2184
+ "name": "updated_at",
2185
+ "type": "timestamp with time zone",
2186
+ "primaryKey": false,
2187
+ "notNull": true,
2188
+ "default": "now()"
2189
+ }
2190
+ },
2191
+ "indexes": {},
2192
+ "foreignKeys": {
2193
+ "job_field_settings_organisation_id_organisations_id_fk": {
2194
+ "name": "job_field_settings_organisation_id_organisations_id_fk",
2195
+ "tableFrom": "job_field_settings",
2196
+ "tableTo": "organisations",
2197
+ "columnsFrom": [
2198
+ "organisation_id"
2199
+ ],
2200
+ "columnsTo": [
2201
+ "id"
2202
+ ],
2203
+ "onDelete": "no action",
2204
+ "onUpdate": "no action"
2205
+ },
2206
+ "job_field_settings_updated_by_people_id_fk": {
2207
+ "name": "job_field_settings_updated_by_people_id_fk",
2208
+ "tableFrom": "job_field_settings",
2209
+ "tableTo": "people",
2210
+ "columnsFrom": [
2211
+ "updated_by"
2212
+ ],
2213
+ "columnsTo": [
2214
+ "id"
2215
+ ],
2216
+ "onDelete": "set null",
2217
+ "onUpdate": "no action"
2218
+ }
2219
+ },
2220
+ "compositePrimaryKeys": {},
2221
+ "uniqueConstraints": {},
2222
+ "policies": {},
2223
+ "checkConstraints": {},
2224
+ "isRLSEnabled": false
2225
+ },
2226
+ "public.job_field_values": {
2227
+ "name": "job_field_values",
2228
+ "schema": "",
2229
+ "columns": {
2230
+ "organisation_id": {
2231
+ "name": "organisation_id",
2232
+ "type": "uuid",
2233
+ "primaryKey": false,
2234
+ "notNull": true
2235
+ },
2236
+ "field_id": {
2237
+ "name": "field_id",
2238
+ "type": "uuid",
2239
+ "primaryKey": false,
2240
+ "notNull": true
2241
+ },
2242
+ "source_system": {
2243
+ "name": "source_system",
2244
+ "type": "text",
2245
+ "primaryKey": false,
2246
+ "notNull": true
2247
+ },
2248
+ "source_job_ref": {
2249
+ "name": "source_job_ref",
2250
+ "type": "text",
2251
+ "primaryKey": false,
2252
+ "notNull": true
2253
+ },
2254
+ "value": {
2255
+ "name": "value",
2256
+ "type": "jsonb",
2257
+ "primaryKey": false,
2258
+ "notNull": true
2259
+ },
2260
+ "updated_by": {
2261
+ "name": "updated_by",
2262
+ "type": "uuid",
2263
+ "primaryKey": false,
2264
+ "notNull": false
2265
+ },
2266
+ "updated_at": {
2267
+ "name": "updated_at",
2268
+ "type": "timestamp with time zone",
2269
+ "primaryKey": false,
2270
+ "notNull": true,
2271
+ "default": "now()"
2272
+ }
2273
+ },
2274
+ "indexes": {
2275
+ "job_field_values_job": {
2276
+ "name": "job_field_values_job",
2277
+ "columns": [
2278
+ {
2279
+ "expression": "organisation_id",
2280
+ "isExpression": false,
2281
+ "asc": true,
2282
+ "nulls": "last"
2283
+ },
2284
+ {
2285
+ "expression": "source_system",
2286
+ "isExpression": false,
2287
+ "asc": true,
2288
+ "nulls": "last"
2289
+ },
2290
+ {
2291
+ "expression": "source_job_ref",
2292
+ "isExpression": false,
2293
+ "asc": true,
2294
+ "nulls": "last"
2295
+ }
2296
+ ],
2297
+ "isUnique": false,
2298
+ "concurrently": false,
2299
+ "method": "btree",
2300
+ "with": {}
2301
+ }
2302
+ },
2303
+ "foreignKeys": {
2304
+ "job_field_values_organisation_id_organisations_id_fk": {
2305
+ "name": "job_field_values_organisation_id_organisations_id_fk",
2306
+ "tableFrom": "job_field_values",
2307
+ "tableTo": "organisations",
2308
+ "columnsFrom": [
2309
+ "organisation_id"
2310
+ ],
2311
+ "columnsTo": [
2312
+ "id"
2313
+ ],
2314
+ "onDelete": "no action",
2315
+ "onUpdate": "no action"
2316
+ },
2317
+ "job_field_values_updated_by_people_id_fk": {
2318
+ "name": "job_field_values_updated_by_people_id_fk",
2319
+ "tableFrom": "job_field_values",
2320
+ "tableTo": "people",
2321
+ "columnsFrom": [
2322
+ "updated_by"
2323
+ ],
2324
+ "columnsTo": [
2325
+ "id"
2326
+ ],
2327
+ "onDelete": "set null",
2328
+ "onUpdate": "no action"
2329
+ },
2330
+ "job_field_values_field_same_org": {
2331
+ "name": "job_field_values_field_same_org",
2332
+ "tableFrom": "job_field_values",
2333
+ "tableTo": "job_fields",
2334
+ "columnsFrom": [
2335
+ "organisation_id",
2336
+ "field_id"
2337
+ ],
2338
+ "columnsTo": [
2339
+ "organisation_id",
2340
+ "id"
2341
+ ],
2342
+ "onDelete": "cascade",
2343
+ "onUpdate": "no action"
2344
+ }
2345
+ },
2346
+ "compositePrimaryKeys": {
2347
+ "job_field_values_organisation_id_field_id_source_system_source_job_ref_pk": {
2348
+ "name": "job_field_values_organisation_id_field_id_source_system_source_job_ref_pk",
2349
+ "columns": [
2350
+ "organisation_id",
2351
+ "field_id",
2352
+ "source_system",
2353
+ "source_job_ref"
2354
+ ]
2355
+ }
2356
+ },
2357
+ "uniqueConstraints": {},
2358
+ "policies": {},
2359
+ "checkConstraints": {},
2360
+ "isRLSEnabled": false
2361
+ },
2362
+ "public.job_fields": {
2363
+ "name": "job_fields",
2364
+ "schema": "",
2365
+ "columns": {
2366
+ "id": {
2367
+ "name": "id",
2368
+ "type": "uuid",
2369
+ "primaryKey": true,
2370
+ "notNull": true,
2371
+ "default": "gen_random_uuid()"
2372
+ },
2373
+ "organisation_id": {
2374
+ "name": "organisation_id",
2375
+ "type": "uuid",
2376
+ "primaryKey": false,
2377
+ "notNull": true
2378
+ },
2379
+ "name": {
2380
+ "name": "name",
2381
+ "type": "text",
2382
+ "primaryKey": false,
2383
+ "notNull": true
2384
+ },
2385
+ "type": {
2386
+ "name": "type",
2387
+ "type": "text",
2388
+ "primaryKey": false,
2389
+ "notNull": true
2390
+ },
2391
+ "options": {
2392
+ "name": "options",
2393
+ "type": "jsonb",
2394
+ "primaryKey": false,
2395
+ "notNull": true,
2396
+ "default": "'[]'::jsonb"
2397
+ },
2398
+ "color": {
2399
+ "name": "color",
2400
+ "type": "text",
2401
+ "primaryKey": false,
2402
+ "notNull": false
2403
+ },
2404
+ "position": {
2405
+ "name": "position",
2406
+ "type": "integer",
2407
+ "primaryKey": false,
2408
+ "notNull": true
2409
+ },
2410
+ "archived_at": {
2411
+ "name": "archived_at",
2412
+ "type": "timestamp with time zone",
2413
+ "primaryKey": false,
2414
+ "notNull": false
2415
+ },
2416
+ "created_by": {
2417
+ "name": "created_by",
2418
+ "type": "uuid",
2419
+ "primaryKey": false,
2420
+ "notNull": false
2421
+ },
2422
+ "updated_by": {
2423
+ "name": "updated_by",
2424
+ "type": "uuid",
2425
+ "primaryKey": false,
2426
+ "notNull": false
2427
+ },
2428
+ "created_at": {
2429
+ "name": "created_at",
2430
+ "type": "timestamp with time zone",
2431
+ "primaryKey": false,
2432
+ "notNull": true,
2433
+ "default": "now()"
2434
+ },
2435
+ "updated_at": {
2436
+ "name": "updated_at",
2437
+ "type": "timestamp with time zone",
2438
+ "primaryKey": false,
2439
+ "notNull": true,
2440
+ "default": "now()"
2441
+ }
2442
+ },
2443
+ "indexes": {},
2444
+ "foreignKeys": {
2445
+ "job_fields_organisation_id_organisations_id_fk": {
2446
+ "name": "job_fields_organisation_id_organisations_id_fk",
2447
+ "tableFrom": "job_fields",
2448
+ "tableTo": "organisations",
2449
+ "columnsFrom": [
2450
+ "organisation_id"
2451
+ ],
2452
+ "columnsTo": [
2453
+ "id"
2454
+ ],
2455
+ "onDelete": "no action",
2456
+ "onUpdate": "no action"
2457
+ },
2458
+ "job_fields_created_by_people_id_fk": {
2459
+ "name": "job_fields_created_by_people_id_fk",
2460
+ "tableFrom": "job_fields",
2461
+ "tableTo": "people",
2462
+ "columnsFrom": [
2463
+ "created_by"
2464
+ ],
2465
+ "columnsTo": [
2466
+ "id"
2467
+ ],
2468
+ "onDelete": "set null",
2469
+ "onUpdate": "no action"
2470
+ },
2471
+ "job_fields_updated_by_people_id_fk": {
2472
+ "name": "job_fields_updated_by_people_id_fk",
2473
+ "tableFrom": "job_fields",
2474
+ "tableTo": "people",
2475
+ "columnsFrom": [
2476
+ "updated_by"
2477
+ ],
2478
+ "columnsTo": [
2479
+ "id"
2480
+ ],
2481
+ "onDelete": "set null",
2482
+ "onUpdate": "no action"
2483
+ }
2484
+ },
2485
+ "compositePrimaryKeys": {},
2486
+ "uniqueConstraints": {
2487
+ "job_fields_org_id": {
2488
+ "name": "job_fields_org_id",
2489
+ "nullsNotDistinct": false,
2490
+ "columns": [
2491
+ "organisation_id",
2492
+ "id"
2493
+ ]
2494
+ }
2495
+ },
2496
+ "policies": {},
2497
+ "checkConstraints": {
2498
+ "job_fields_type_valid": {
2499
+ "name": "job_fields_type_valid",
2500
+ "value": "\"job_fields\".\"type\" in ('dropdown', 'person', 'checkbox', 'date', 'number', 'text')"
2501
+ },
2502
+ "job_fields_name_valid": {
2503
+ "name": "job_fields_name_valid",
2504
+ "value": "length(\"job_fields\".\"name\") between 1 and 60"
2505
+ },
2506
+ "job_fields_color_valid": {
2507
+ "name": "job_fields_color_valid",
2508
+ "value": "\"job_fields\".\"color\" is null or \"job_fields\".\"color\" in ('gray', 'blue', 'teal', 'green', 'amber', 'red', 'purple', 'pink')"
2509
+ }
2510
+ },
2511
+ "isRLSEnabled": false
2512
+ },
2513
+ "public.line_mappings": {
2514
+ "name": "line_mappings",
2515
+ "schema": "",
2516
+ "columns": {
2517
+ "id": {
2518
+ "name": "id",
2519
+ "type": "uuid",
2520
+ "primaryKey": true,
2521
+ "notNull": true,
2522
+ "default": "gen_random_uuid()"
2523
+ },
2524
+ "organisation_id": {
2525
+ "name": "organisation_id",
2526
+ "type": "uuid",
2527
+ "primaryKey": false,
2528
+ "notNull": true
2529
+ },
2530
+ "kind": {
2531
+ "name": "kind",
2532
+ "type": "text",
2533
+ "primaryKey": false,
2534
+ "notNull": true
2535
+ },
2536
+ "match": {
2537
+ "name": "match",
2538
+ "type": "text",
2539
+ "primaryKey": false,
2540
+ "notNull": true,
2541
+ "default": "'exact'"
2542
+ },
2543
+ "label": {
2544
+ "name": "label",
2545
+ "type": "text",
2546
+ "primaryKey": false,
2547
+ "notNull": true
2548
+ },
2549
+ "unit_amount_cents": {
2550
+ "name": "unit_amount_cents",
2551
+ "type": "integer",
2552
+ "primaryKey": false,
2553
+ "notNull": false
2554
+ },
2555
+ "item_code": {
2556
+ "name": "item_code",
2557
+ "type": "text",
2558
+ "primaryKey": false,
2559
+ "notNull": false
2560
+ },
2561
+ "account_code": {
2562
+ "name": "account_code",
2563
+ "type": "text",
2564
+ "primaryKey": false,
2565
+ "notNull": false
2566
+ },
2567
+ "tax_code": {
2568
+ "name": "tax_code",
2569
+ "type": "text",
2570
+ "primaryKey": false,
2571
+ "notNull": false
2572
+ },
2573
+ "description": {
2574
+ "name": "description",
2575
+ "type": "text",
2576
+ "primaryKey": false,
2577
+ "notNull": false
2578
+ },
2579
+ "enabled": {
2580
+ "name": "enabled",
2581
+ "type": "boolean",
2582
+ "primaryKey": false,
2583
+ "notNull": true,
2584
+ "default": true
2585
+ },
2586
+ "origin": {
2587
+ "name": "origin",
2588
+ "type": "text",
2589
+ "primaryKey": false,
2590
+ "notNull": true,
2591
+ "default": "'person'"
2592
+ },
2593
+ "updated_by": {
2594
+ "name": "updated_by",
2595
+ "type": "uuid",
2596
+ "primaryKey": false,
2597
+ "notNull": false
2598
+ },
2599
+ "created_at": {
2600
+ "name": "created_at",
2601
+ "type": "timestamp with time zone",
2602
+ "primaryKey": false,
2603
+ "notNull": true,
2604
+ "default": "now()"
2605
+ },
2606
+ "updated_at": {
2607
+ "name": "updated_at",
2608
+ "type": "timestamp with time zone",
2609
+ "primaryKey": false,
2610
+ "notNull": true,
2611
+ "default": "now()"
2612
+ }
2613
+ },
2614
+ "indexes": {
2615
+ "line_mappings_unique": {
2616
+ "name": "line_mappings_unique",
2617
+ "columns": [
2618
+ {
2619
+ "expression": "organisation_id",
2620
+ "isExpression": false,
2621
+ "asc": true,
2622
+ "nulls": "last"
2623
+ },
2624
+ {
2625
+ "expression": "kind",
2626
+ "isExpression": false,
2627
+ "asc": true,
2628
+ "nulls": "last"
2629
+ },
2630
+ {
2631
+ "expression": "match",
2632
+ "isExpression": false,
2633
+ "asc": true,
2634
+ "nulls": "last"
2635
+ },
2636
+ {
2637
+ "expression": "label",
2638
+ "isExpression": false,
2639
+ "asc": true,
2640
+ "nulls": "last"
2641
+ },
2642
+ {
2643
+ "expression": "coalesce(\"unit_amount_cents\", -1)",
2644
+ "asc": true,
2645
+ "isExpression": true,
2646
+ "nulls": "last"
2647
+ }
2648
+ ],
2649
+ "isUnique": true,
2650
+ "concurrently": false,
2651
+ "method": "btree",
2652
+ "with": {}
2653
+ }
2654
+ },
2655
+ "foreignKeys": {
2656
+ "line_mappings_organisation_id_organisations_id_fk": {
2657
+ "name": "line_mappings_organisation_id_organisations_id_fk",
2658
+ "tableFrom": "line_mappings",
2659
+ "tableTo": "organisations",
2660
+ "columnsFrom": [
2661
+ "organisation_id"
2662
+ ],
2663
+ "columnsTo": [
2664
+ "id"
2665
+ ],
2666
+ "onDelete": "no action",
2667
+ "onUpdate": "no action"
2668
+ },
2669
+ "line_mappings_updated_by_people_id_fk": {
2670
+ "name": "line_mappings_updated_by_people_id_fk",
2671
+ "tableFrom": "line_mappings",
2672
+ "tableTo": "people",
2673
+ "columnsFrom": [
2674
+ "updated_by"
2675
+ ],
2676
+ "columnsTo": [
2677
+ "id"
2678
+ ],
2679
+ "onDelete": "set null",
2680
+ "onUpdate": "no action"
2681
+ }
2682
+ },
2683
+ "compositePrimaryKeys": {},
2684
+ "uniqueConstraints": {},
2685
+ "policies": {},
2686
+ "checkConstraints": {
2687
+ "line_mappings_kind_valid": {
2688
+ "name": "line_mappings_kind_valid",
2689
+ "value": "\"line_mappings\".\"kind\" in ('alias', 'price_alias', 'saved', 'account')"
2690
+ },
2691
+ "line_mappings_match_valid": {
2692
+ "name": "line_mappings_match_valid",
2693
+ "value": "\"line_mappings\".\"match\" in ('exact', 'starts_with')"
2694
+ },
2695
+ "line_mappings_tax_code_valid": {
2696
+ "name": "line_mappings_tax_code_valid",
2697
+ "value": "\"line_mappings\".\"tax_code\" is null or \"line_mappings\".\"tax_code\" in ('GST', 'GST_FREE')"
2698
+ },
2699
+ "line_mappings_target": {
2700
+ "name": "line_mappings_target",
2701
+ "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)"
2702
+ },
2703
+ "line_mappings_price": {
2704
+ "name": "line_mappings_price",
2705
+ "value": "\"line_mappings\".\"kind\" not in ('price_alias', 'saved') or \"line_mappings\".\"unit_amount_cents\" is not null"
2706
+ },
2707
+ "line_mappings_label_valid": {
2708
+ "name": "line_mappings_label_valid",
2709
+ "value": "length(\"line_mappings\".\"label\") between 1 and 200"
2710
+ }
2711
+ },
2712
+ "isRLSEnabled": false
2713
+ },
2714
+ "public.link_rejections": {
2715
+ "name": "link_rejections",
2716
+ "schema": "",
2717
+ "columns": {
2718
+ "organisation_id": {
2719
+ "name": "organisation_id",
2720
+ "type": "uuid",
2721
+ "primaryKey": false,
2722
+ "notNull": true
2723
+ },
2724
+ "obligation_id": {
2725
+ "name": "obligation_id",
2726
+ "type": "uuid",
2727
+ "primaryKey": false,
2728
+ "notNull": true
2729
+ },
2730
+ "system": {
2731
+ "name": "system",
2732
+ "type": "text",
2733
+ "primaryKey": false,
2734
+ "notNull": true
2735
+ },
2736
+ "external_id": {
2737
+ "name": "external_id",
2738
+ "type": "text",
2739
+ "primaryKey": false,
2740
+ "notNull": true
2741
+ },
2742
+ "actor": {
2743
+ "name": "actor",
2744
+ "type": "text",
2745
+ "primaryKey": false,
2746
+ "notNull": true
2747
+ },
2748
+ "created_at": {
2749
+ "name": "created_at",
2750
+ "type": "timestamp with time zone",
2751
+ "primaryKey": false,
2752
+ "notNull": true,
2753
+ "default": "now()"
2754
+ }
2755
+ },
2756
+ "indexes": {},
2757
+ "foreignKeys": {
2758
+ "link_rejections_organisation_id_organisations_id_fk": {
2759
+ "name": "link_rejections_organisation_id_organisations_id_fk",
2760
+ "tableFrom": "link_rejections",
2761
+ "tableTo": "organisations",
2762
+ "columnsFrom": [
2763
+ "organisation_id"
2764
+ ],
2765
+ "columnsTo": [
2766
+ "id"
2767
+ ],
2768
+ "onDelete": "no action",
2769
+ "onUpdate": "no action"
2770
+ },
2771
+ "link_rejections_obligation_same_org": {
2772
+ "name": "link_rejections_obligation_same_org",
2773
+ "tableFrom": "link_rejections",
2774
+ "tableTo": "billing_obligations",
2775
+ "columnsFrom": [
2776
+ "organisation_id",
2777
+ "obligation_id"
2778
+ ],
2779
+ "columnsTo": [
2780
+ "organisation_id",
2781
+ "id"
2782
+ ],
2783
+ "onDelete": "no action",
2784
+ "onUpdate": "no action"
2785
+ }
2786
+ },
2787
+ "compositePrimaryKeys": {
2788
+ "link_rejections_pk": {
2789
+ "name": "link_rejections_pk",
2790
+ "columns": [
2791
+ "organisation_id",
2792
+ "obligation_id",
2793
+ "system",
2794
+ "external_id"
2795
+ ]
2796
+ }
2797
+ },
2798
+ "uniqueConstraints": {},
2799
+ "policies": {},
2800
+ "checkConstraints": {},
2801
+ "isRLSEnabled": false
2802
+ },
2803
+ "public.link_suggestions": {
2804
+ "name": "link_suggestions",
2805
+ "schema": "",
2806
+ "columns": {
2807
+ "id": {
2808
+ "name": "id",
2809
+ "type": "uuid",
2810
+ "primaryKey": true,
2811
+ "notNull": true,
2812
+ "default": "gen_random_uuid()"
2813
+ },
2814
+ "organisation_id": {
2815
+ "name": "organisation_id",
2816
+ "type": "uuid",
2817
+ "primaryKey": false,
2818
+ "notNull": true
2819
+ },
2820
+ "obligation_id": {
2821
+ "name": "obligation_id",
2822
+ "type": "uuid",
2823
+ "primaryKey": false,
2824
+ "notNull": true
2825
+ },
2826
+ "system": {
2827
+ "name": "system",
2828
+ "type": "text",
2829
+ "primaryKey": false,
2830
+ "notNull": true
2831
+ },
2832
+ "external_id": {
2833
+ "name": "external_id",
2834
+ "type": "text",
2835
+ "primaryKey": false,
2836
+ "notNull": true
2837
+ },
2838
+ "external_number": {
2839
+ "name": "external_number",
2840
+ "type": "text",
2841
+ "primaryKey": false,
2842
+ "notNull": false
2843
+ },
2844
+ "score": {
2845
+ "name": "score",
2846
+ "type": "integer",
2847
+ "primaryKey": false,
2848
+ "notNull": true
2849
+ },
2850
+ "rank": {
2851
+ "name": "rank",
2852
+ "type": "integer",
2853
+ "primaryKey": false,
2854
+ "notNull": true
2855
+ },
2856
+ "signals": {
2857
+ "name": "signals",
2858
+ "type": "jsonb",
2859
+ "primaryKey": false,
2860
+ "notNull": true,
2861
+ "default": "'[]'::jsonb"
2862
+ },
2863
+ "state": {
2864
+ "name": "state",
2865
+ "type": "text",
2866
+ "primaryKey": false,
2867
+ "notNull": true,
2868
+ "default": "'open'"
2869
+ },
2870
+ "decided_by": {
2871
+ "name": "decided_by",
2872
+ "type": "text",
2873
+ "primaryKey": false,
2874
+ "notNull": false
2875
+ },
2876
+ "decided_at": {
2877
+ "name": "decided_at",
2878
+ "type": "timestamp with time zone",
2879
+ "primaryKey": false,
2880
+ "notNull": false
2881
+ },
2882
+ "created_at": {
2883
+ "name": "created_at",
2884
+ "type": "timestamp with time zone",
2885
+ "primaryKey": false,
2886
+ "notNull": true,
2887
+ "default": "now()"
2888
+ },
2889
+ "updated_at": {
2890
+ "name": "updated_at",
2891
+ "type": "timestamp with time zone",
2892
+ "primaryKey": false,
2893
+ "notNull": true,
2894
+ "default": "now()"
2895
+ }
2896
+ },
2897
+ "indexes": {
2898
+ "link_suggestions_open": {
2899
+ "name": "link_suggestions_open",
2900
+ "columns": [
2901
+ {
2902
+ "expression": "organisation_id",
2903
+ "isExpression": false,
2904
+ "asc": true,
2905
+ "nulls": "last"
2906
+ },
2907
+ {
2908
+ "expression": "state",
2909
+ "isExpression": false,
2910
+ "asc": true,
2911
+ "nulls": "last"
2912
+ },
2913
+ {
2914
+ "expression": "obligation_id",
2915
+ "isExpression": false,
2916
+ "asc": true,
2917
+ "nulls": "last"
2918
+ }
2919
+ ],
2920
+ "isUnique": false,
2921
+ "concurrently": false,
2922
+ "method": "btree",
2923
+ "with": {}
2924
+ }
2925
+ },
2926
+ "foreignKeys": {
2927
+ "link_suggestions_organisation_id_organisations_id_fk": {
2928
+ "name": "link_suggestions_organisation_id_organisations_id_fk",
2929
+ "tableFrom": "link_suggestions",
2930
+ "tableTo": "organisations",
2931
+ "columnsFrom": [
2932
+ "organisation_id"
2933
+ ],
2934
+ "columnsTo": [
2935
+ "id"
2936
+ ],
2937
+ "onDelete": "no action",
2938
+ "onUpdate": "no action"
2939
+ },
2940
+ "link_suggestions_obligation_same_org": {
2941
+ "name": "link_suggestions_obligation_same_org",
2942
+ "tableFrom": "link_suggestions",
2943
+ "tableTo": "billing_obligations",
2944
+ "columnsFrom": [
2945
+ "organisation_id",
2946
+ "obligation_id"
2947
+ ],
2948
+ "columnsTo": [
2949
+ "organisation_id",
2950
+ "id"
2951
+ ],
2952
+ "onDelete": "no action",
2953
+ "onUpdate": "no action"
2954
+ }
2955
+ },
2956
+ "compositePrimaryKeys": {},
2957
+ "uniqueConstraints": {
2958
+ "link_suggestions_pair": {
2959
+ "name": "link_suggestions_pair",
2960
+ "nullsNotDistinct": false,
2961
+ "columns": [
2962
+ "organisation_id",
2963
+ "obligation_id",
2964
+ "system",
2965
+ "external_id"
2966
+ ]
2967
+ }
2968
+ },
2969
+ "policies": {},
2970
+ "checkConstraints": {
2971
+ "link_suggestions_state_valid": {
2972
+ "name": "link_suggestions_state_valid",
2973
+ "value": "state in ('open', 'accepted', 'rejected', 'stale')"
2974
+ }
2975
+ },
2976
+ "isRLSEnabled": false
2977
+ },
2978
+ "public.obligation_events": {
2979
+ "name": "obligation_events",
2980
+ "schema": "",
2981
+ "columns": {
2982
+ "id": {
2983
+ "name": "id",
2984
+ "type": "uuid",
2985
+ "primaryKey": true,
2986
+ "notNull": true,
2987
+ "default": "gen_random_uuid()"
2988
+ },
2989
+ "organisation_id": {
2990
+ "name": "organisation_id",
2991
+ "type": "uuid",
2992
+ "primaryKey": false,
2993
+ "notNull": true
2994
+ },
2995
+ "obligation_id": {
2996
+ "name": "obligation_id",
2997
+ "type": "uuid",
2998
+ "primaryKey": false,
2999
+ "notNull": true
3000
+ },
3001
+ "kind": {
3002
+ "name": "kind",
3003
+ "type": "text",
3004
+ "primaryKey": false,
3005
+ "notNull": true
3006
+ },
3007
+ "actor": {
3008
+ "name": "actor",
3009
+ "type": "text",
3010
+ "primaryKey": false,
3011
+ "notNull": true
3012
+ },
3013
+ "evidence": {
3014
+ "name": "evidence",
3015
+ "type": "jsonb",
3016
+ "primaryKey": false,
3017
+ "notNull": true,
3018
+ "default": "'{}'::jsonb"
3019
+ },
3020
+ "created_at": {
3021
+ "name": "created_at",
3022
+ "type": "timestamp with time zone",
3023
+ "primaryKey": false,
3024
+ "notNull": true,
3025
+ "default": "now()"
3026
+ }
3027
+ },
3028
+ "indexes": {},
3029
+ "foreignKeys": {
3030
+ "obligation_events_obligation_same_org": {
3031
+ "name": "obligation_events_obligation_same_org",
3032
+ "tableFrom": "obligation_events",
3033
+ "tableTo": "billing_obligations",
3034
+ "columnsFrom": [
3035
+ "organisation_id",
3036
+ "obligation_id"
3037
+ ],
3038
+ "columnsTo": [
3039
+ "organisation_id",
3040
+ "id"
3041
+ ],
3042
+ "onDelete": "no action",
3043
+ "onUpdate": "no action"
3044
+ }
3045
+ },
3046
+ "compositePrimaryKeys": {},
3047
+ "uniqueConstraints": {},
3048
+ "policies": {},
3049
+ "checkConstraints": {},
3050
+ "isRLSEnabled": false
3051
+ },
3052
+ "public.obligation_payments": {
3053
+ "name": "obligation_payments",
3054
+ "schema": "",
3055
+ "columns": {
3056
+ "id": {
3057
+ "name": "id",
3058
+ "type": "uuid",
3059
+ "primaryKey": true,
3060
+ "notNull": true,
3061
+ "default": "gen_random_uuid()"
3062
+ },
3063
+ "organisation_id": {
3064
+ "name": "organisation_id",
3065
+ "type": "uuid",
3066
+ "primaryKey": false,
3067
+ "notNull": true
3068
+ },
3069
+ "obligation_id": {
3070
+ "name": "obligation_id",
3071
+ "type": "uuid",
3072
+ "primaryKey": false,
3073
+ "notNull": true
3074
+ },
3075
+ "payment_ref": {
3076
+ "name": "payment_ref",
3077
+ "type": "text",
3078
+ "primaryKey": false,
3079
+ "notNull": true
3080
+ },
3081
+ "paid_on": {
3082
+ "name": "paid_on",
3083
+ "type": "date",
3084
+ "primaryKey": false,
3085
+ "notNull": true
3086
+ },
3087
+ "amount_cents": {
3088
+ "name": "amount_cents",
3089
+ "type": "integer",
3090
+ "primaryKey": false,
3091
+ "notNull": true
3092
+ },
3093
+ "reference": {
3094
+ "name": "reference",
3095
+ "type": "text",
3096
+ "primaryKey": false,
3097
+ "notNull": false
3098
+ },
3099
+ "reconciled": {
3100
+ "name": "reconciled",
3101
+ "type": "boolean",
3102
+ "primaryKey": false,
3103
+ "notNull": true
3104
+ },
3105
+ "accounting_url": {
3106
+ "name": "accounting_url",
3107
+ "type": "text",
3108
+ "primaryKey": false,
3109
+ "notNull": false
3110
+ },
3111
+ "observed_at": {
3112
+ "name": "observed_at",
3113
+ "type": "timestamp with time zone",
3114
+ "primaryKey": false,
3115
+ "notNull": true,
3116
+ "default": "now()"
3117
+ }
3118
+ },
3119
+ "indexes": {},
3120
+ "foreignKeys": {
3121
+ "obligation_payments_obligation_same_org": {
3122
+ "name": "obligation_payments_obligation_same_org",
3123
+ "tableFrom": "obligation_payments",
3124
+ "tableTo": "billing_obligations",
3125
+ "columnsFrom": [
3126
+ "organisation_id",
3127
+ "obligation_id"
3128
+ ],
3129
+ "columnsTo": [
3130
+ "organisation_id",
3131
+ "id"
3132
+ ],
3133
+ "onDelete": "no action",
3134
+ "onUpdate": "no action"
3135
+ }
3136
+ },
3137
+ "compositePrimaryKeys": {},
3138
+ "uniqueConstraints": {
3139
+ "obligation_payments_ref": {
3140
+ "name": "obligation_payments_ref",
3141
+ "nullsNotDistinct": false,
3142
+ "columns": [
3143
+ "organisation_id",
3144
+ "obligation_id",
3145
+ "payment_ref"
3146
+ ]
3147
+ }
3148
+ },
3149
+ "policies": {},
3150
+ "checkConstraints": {
3151
+ "obligation_payments_amount_positive": {
3152
+ "name": "obligation_payments_amount_positive",
3153
+ "value": "\"obligation_payments\".\"amount_cents\" > 0"
3154
+ }
3155
+ },
3156
+ "isRLSEnabled": false
3157
+ },
3158
+ "public.obligation_writebacks": {
3159
+ "name": "obligation_writebacks",
3160
+ "schema": "",
3161
+ "columns": {
3162
+ "id": {
3163
+ "name": "id",
3164
+ "type": "uuid",
3165
+ "primaryKey": true,
3166
+ "notNull": true,
3167
+ "default": "gen_random_uuid()"
3168
+ },
3169
+ "organisation_id": {
3170
+ "name": "organisation_id",
3171
+ "type": "uuid",
3172
+ "primaryKey": false,
3173
+ "notNull": true
3174
+ },
3175
+ "obligation_id": {
3176
+ "name": "obligation_id",
3177
+ "type": "uuid",
3178
+ "primaryKey": false,
3179
+ "notNull": true
3180
+ },
3181
+ "target_system": {
3182
+ "name": "target_system",
3183
+ "type": "text",
3184
+ "primaryKey": false,
3185
+ "notNull": true
3186
+ },
3187
+ "status": {
3188
+ "name": "status",
3189
+ "type": "text",
3190
+ "primaryKey": false,
3191
+ "notNull": true
3192
+ },
3193
+ "state": {
3194
+ "name": "state",
3195
+ "type": "text",
3196
+ "primaryKey": false,
3197
+ "notNull": true,
3198
+ "default": "'pending'"
3199
+ },
3200
+ "evidence": {
3201
+ "name": "evidence",
3202
+ "type": "jsonb",
3203
+ "primaryKey": false,
3204
+ "notNull": true
3205
+ },
3206
+ "attempts": {
3207
+ "name": "attempts",
3208
+ "type": "integer",
3209
+ "primaryKey": false,
3210
+ "notNull": true,
3211
+ "default": 0
3212
+ },
3213
+ "last_error": {
3214
+ "name": "last_error",
3215
+ "type": "text",
3216
+ "primaryKey": false,
3217
+ "notNull": false
3218
+ },
3219
+ "sent_at": {
3220
+ "name": "sent_at",
3221
+ "type": "timestamp with time zone",
3222
+ "primaryKey": false,
3223
+ "notNull": false
3224
+ },
3225
+ "created_at": {
3226
+ "name": "created_at",
3227
+ "type": "timestamp with time zone",
3228
+ "primaryKey": false,
3229
+ "notNull": true,
3230
+ "default": "now()"
3231
+ },
3232
+ "updated_at": {
3233
+ "name": "updated_at",
3234
+ "type": "timestamp with time zone",
3235
+ "primaryKey": false,
3236
+ "notNull": true,
3237
+ "default": "now()"
3238
+ }
3239
+ },
3240
+ "indexes": {},
3241
+ "foreignKeys": {
3242
+ "obligation_writebacks_obligation_same_org": {
3243
+ "name": "obligation_writebacks_obligation_same_org",
3244
+ "tableFrom": "obligation_writebacks",
3245
+ "tableTo": "billing_obligations",
3246
+ "columnsFrom": [
3247
+ "organisation_id",
3248
+ "obligation_id"
3249
+ ],
3250
+ "columnsTo": [
3251
+ "organisation_id",
3252
+ "id"
3253
+ ],
3254
+ "onDelete": "no action",
3255
+ "onUpdate": "no action"
3256
+ }
3257
+ },
3258
+ "compositePrimaryKeys": {},
3259
+ "uniqueConstraints": {
3260
+ "obligation_writebacks_status": {
3261
+ "name": "obligation_writebacks_status",
3262
+ "nullsNotDistinct": false,
3263
+ "columns": [
3264
+ "organisation_id",
3265
+ "obligation_id",
3266
+ "status"
3267
+ ]
3268
+ }
3269
+ },
3270
+ "policies": {},
3271
+ "checkConstraints": {
3272
+ "obligation_writebacks_state_valid": {
3273
+ "name": "obligation_writebacks_state_valid",
3274
+ "value": "state in ('pending', 'sent', 'failed', 'not_supported')"
3275
+ }
3276
+ },
3277
+ "isRLSEnabled": false
3278
+ },
3279
+ "public.organisations": {
3280
+ "name": "organisations",
3281
+ "schema": "",
3282
+ "columns": {
3283
+ "id": {
3284
+ "name": "id",
3285
+ "type": "uuid",
3286
+ "primaryKey": true,
3287
+ "notNull": true,
3288
+ "default": "gen_random_uuid()"
3289
+ },
3290
+ "name": {
3291
+ "name": "name",
3292
+ "type": "text",
3293
+ "primaryKey": false,
3294
+ "notNull": true
3295
+ },
3296
+ "invoice_prefix": {
3297
+ "name": "invoice_prefix",
3298
+ "type": "text",
3299
+ "primaryKey": false,
3300
+ "notNull": true,
3301
+ "default": "'INV-'"
3302
+ },
3303
+ "next_invoice_number": {
3304
+ "name": "next_invoice_number",
3305
+ "type": "integer",
3306
+ "primaryKey": false,
3307
+ "notNull": true,
3308
+ "default": 1
3309
+ },
3310
+ "created_at": {
3311
+ "name": "created_at",
3312
+ "type": "timestamp with time zone",
3313
+ "primaryKey": false,
3314
+ "notNull": true,
3315
+ "default": "now()"
3316
+ }
3317
+ },
3318
+ "indexes": {},
3319
+ "foreignKeys": {},
3320
+ "compositePrimaryKeys": {},
3321
+ "uniqueConstraints": {},
3322
+ "policies": {},
3323
+ "checkConstraints": {
3324
+ "organisations_next_invoice_number_positive": {
3325
+ "name": "organisations_next_invoice_number_positive",
3326
+ "value": "\"organisations\".\"next_invoice_number\" > 0"
3327
+ }
3328
+ },
3329
+ "isRLSEnabled": false
3330
+ },
3331
+ "public.outbox": {
3332
+ "name": "outbox",
3333
+ "schema": "",
3334
+ "columns": {
3335
+ "id": {
3336
+ "name": "id",
3337
+ "type": "uuid",
3338
+ "primaryKey": true,
3339
+ "notNull": true,
3340
+ "default": "gen_random_uuid()"
3341
+ },
3342
+ "organisation_id": {
3343
+ "name": "organisation_id",
3344
+ "type": "uuid",
3345
+ "primaryKey": false,
3346
+ "notNull": true
3347
+ },
3348
+ "system": {
3349
+ "name": "system",
3350
+ "type": "text",
3351
+ "primaryKey": false,
3352
+ "notNull": true
3353
+ },
3354
+ "action": {
3355
+ "name": "action",
3356
+ "type": "text",
3357
+ "primaryKey": false,
3358
+ "notNull": true
3359
+ },
3360
+ "entity": {
3361
+ "name": "entity",
3362
+ "type": "text",
3363
+ "primaryKey": false,
3364
+ "notNull": true
3365
+ },
3366
+ "flow_id": {
3367
+ "name": "flow_id",
3368
+ "type": "uuid",
3369
+ "primaryKey": false,
3370
+ "notNull": true
3371
+ },
3372
+ "idempotency_key": {
3373
+ "name": "idempotency_key",
3374
+ "type": "text",
3375
+ "primaryKey": false,
3376
+ "notNull": true
3377
+ },
3378
+ "request": {
3379
+ "name": "request",
3380
+ "type": "jsonb",
3381
+ "primaryKey": false,
3382
+ "notNull": true
3383
+ },
3384
+ "state": {
3385
+ "name": "state",
3386
+ "type": "text",
3387
+ "primaryKey": false,
3388
+ "notNull": true,
3389
+ "default": "'pending'"
3390
+ },
3391
+ "external_id": {
3392
+ "name": "external_id",
3393
+ "type": "text",
3394
+ "primaryKey": false,
3395
+ "notNull": false
3396
+ },
3397
+ "attempts": {
3398
+ "name": "attempts",
3399
+ "type": "integer",
3400
+ "primaryKey": false,
3401
+ "notNull": true,
3402
+ "default": 0
3403
+ },
3404
+ "last_error": {
3405
+ "name": "last_error",
3406
+ "type": "text",
3407
+ "primaryKey": false,
3408
+ "notNull": false
3409
+ },
3410
+ "created_by": {
3411
+ "name": "created_by",
3412
+ "type": "text",
3413
+ "primaryKey": false,
3414
+ "notNull": true
3415
+ },
3416
+ "sent_at": {
3417
+ "name": "sent_at",
3418
+ "type": "timestamp with time zone",
3419
+ "primaryKey": false,
3420
+ "notNull": false
3421
+ },
3422
+ "created_at": {
3423
+ "name": "created_at",
3424
+ "type": "timestamp with time zone",
3425
+ "primaryKey": false,
3426
+ "notNull": true,
3427
+ "default": "now()"
3428
+ },
3429
+ "updated_at": {
3430
+ "name": "updated_at",
3431
+ "type": "timestamp with time zone",
3432
+ "primaryKey": false,
3433
+ "notNull": true,
3434
+ "default": "now()"
3435
+ }
3436
+ },
3437
+ "indexes": {
3438
+ "outbox_pending": {
3439
+ "name": "outbox_pending",
3440
+ "columns": [
3441
+ {
3442
+ "expression": "system",
3443
+ "isExpression": false,
3444
+ "asc": true,
3445
+ "nulls": "last"
3446
+ },
3447
+ {
3448
+ "expression": "state",
3449
+ "isExpression": false,
3450
+ "asc": true,
3451
+ "nulls": "last"
3452
+ },
3453
+ {
3454
+ "expression": "created_at",
3455
+ "isExpression": false,
3456
+ "asc": true,
3457
+ "nulls": "last"
3458
+ }
3459
+ ],
3460
+ "isUnique": false,
3461
+ "concurrently": false,
3462
+ "method": "btree",
3463
+ "with": {}
3464
+ }
3465
+ },
3466
+ "foreignKeys": {
3467
+ "outbox_organisation_id_organisations_id_fk": {
3468
+ "name": "outbox_organisation_id_organisations_id_fk",
3469
+ "tableFrom": "outbox",
3470
+ "tableTo": "organisations",
3471
+ "columnsFrom": [
3472
+ "organisation_id"
3473
+ ],
3474
+ "columnsTo": [
3475
+ "id"
3476
+ ],
3477
+ "onDelete": "no action",
3478
+ "onUpdate": "no action"
3479
+ }
3480
+ },
3481
+ "compositePrimaryKeys": {},
3482
+ "uniqueConstraints": {
3483
+ "outbox_org_id": {
3484
+ "name": "outbox_org_id",
3485
+ "nullsNotDistinct": false,
3486
+ "columns": [
3487
+ "organisation_id",
3488
+ "id"
3489
+ ]
3490
+ },
3491
+ "outbox_idempotency_key": {
3492
+ "name": "outbox_idempotency_key",
3493
+ "nullsNotDistinct": false,
3494
+ "columns": [
3495
+ "idempotency_key"
3496
+ ]
3497
+ }
3498
+ },
3499
+ "policies": {},
3500
+ "checkConstraints": {
3501
+ "outbox_state_valid": {
3502
+ "name": "outbox_state_valid",
3503
+ "value": "state in ('pending', 'sending', 'ambiguous', 'sent', 'failed', 'cancelled')"
3504
+ },
3505
+ "outbox_sent_has_id": {
3506
+ "name": "outbox_sent_has_id",
3507
+ "value": "\"outbox\".\"state\" <> 'sent' or \"outbox\".\"external_id\" is not null"
3508
+ }
3509
+ },
3510
+ "isRLSEnabled": false
3511
+ },
3512
+ "public.people": {
3513
+ "name": "people",
3514
+ "schema": "",
3515
+ "columns": {
3516
+ "id": {
3517
+ "name": "id",
3518
+ "type": "uuid",
3519
+ "primaryKey": true,
3520
+ "notNull": true,
3521
+ "default": "gen_random_uuid()"
3522
+ },
3523
+ "email": {
3524
+ "name": "email",
3525
+ "type": "text",
3526
+ "primaryKey": false,
3527
+ "notNull": true
3528
+ },
3529
+ "name": {
3530
+ "name": "name",
3531
+ "type": "text",
3532
+ "primaryKey": false,
3533
+ "notNull": false
3534
+ },
3535
+ "role": {
3536
+ "name": "role",
3537
+ "type": "text",
3538
+ "primaryKey": false,
3539
+ "notNull": true
3540
+ },
3541
+ "status": {
3542
+ "name": "status",
3543
+ "type": "text",
3544
+ "primaryKey": false,
3545
+ "notNull": true,
3546
+ "default": "'active'"
3547
+ },
3548
+ "clerk_user_id": {
3549
+ "name": "clerk_user_id",
3550
+ "type": "text",
3551
+ "primaryKey": false,
3552
+ "notNull": false
3553
+ },
3554
+ "invited_by": {
3555
+ "name": "invited_by",
3556
+ "type": "uuid",
3557
+ "primaryKey": false,
3558
+ "notNull": false
3559
+ },
3560
+ "linked_at": {
3561
+ "name": "linked_at",
3562
+ "type": "timestamp with time zone",
3563
+ "primaryKey": false,
3564
+ "notNull": false
3565
+ },
3566
+ "appearance": {
3567
+ "name": "appearance",
3568
+ "type": "jsonb",
3569
+ "primaryKey": false,
3570
+ "notNull": false
3571
+ },
3572
+ "views": {
3573
+ "name": "views",
3574
+ "type": "jsonb",
3575
+ "primaryKey": false,
3576
+ "notNull": false
3577
+ },
3578
+ "created_at": {
3579
+ "name": "created_at",
3580
+ "type": "timestamp with time zone",
3581
+ "primaryKey": false,
3582
+ "notNull": true,
3583
+ "default": "now()"
3584
+ },
3585
+ "updated_at": {
3586
+ "name": "updated_at",
3587
+ "type": "timestamp with time zone",
3588
+ "primaryKey": false,
3589
+ "notNull": true,
3590
+ "default": "now()"
3591
+ }
3592
+ },
3593
+ "indexes": {},
3594
+ "foreignKeys": {
3595
+ "people_invited_by_people_id_fk": {
3596
+ "name": "people_invited_by_people_id_fk",
3597
+ "tableFrom": "people",
3598
+ "tableTo": "people",
3599
+ "columnsFrom": [
3600
+ "invited_by"
3601
+ ],
3602
+ "columnsTo": [
3603
+ "id"
3604
+ ],
3605
+ "onDelete": "set null",
3606
+ "onUpdate": "no action"
3607
+ }
3608
+ },
3609
+ "compositePrimaryKeys": {},
3610
+ "uniqueConstraints": {
3611
+ "people_email": {
3612
+ "name": "people_email",
3613
+ "nullsNotDistinct": false,
3614
+ "columns": [
3615
+ "email"
3616
+ ]
3617
+ },
3618
+ "people_clerk_user_id": {
3619
+ "name": "people_clerk_user_id",
3620
+ "nullsNotDistinct": false,
3621
+ "columns": [
3622
+ "clerk_user_id"
3623
+ ]
3624
+ }
3625
+ },
3626
+ "policies": {},
3627
+ "checkConstraints": {
3628
+ "people_email_lower": {
3629
+ "name": "people_email_lower",
3630
+ "value": "\"people\".\"email\" = lower(\"people\".\"email\")"
3631
+ },
3632
+ "people_role_valid": {
3633
+ "name": "people_role_valid",
3634
+ "value": "\"people\".\"role\" in ('owner', 'admin', 'staff')"
3635
+ },
3636
+ "people_status_valid": {
3637
+ "name": "people_status_valid",
3638
+ "value": "\"people\".\"status\" in ('active', 'pending', 'disabled')"
3639
+ }
3640
+ },
3641
+ "isRLSEnabled": false
3642
+ },
3643
+ "public.pipeline_cursors": {
3644
+ "name": "pipeline_cursors",
3645
+ "schema": "",
3646
+ "columns": {
3647
+ "organisation_id": {
3648
+ "name": "organisation_id",
3649
+ "type": "uuid",
3650
+ "primaryKey": false,
3651
+ "notNull": true
3652
+ },
3653
+ "name": {
3654
+ "name": "name",
3655
+ "type": "text",
3656
+ "primaryKey": false,
3657
+ "notNull": true
3658
+ },
3659
+ "cursor": {
3660
+ "name": "cursor",
3661
+ "type": "text",
3662
+ "primaryKey": false,
3663
+ "notNull": false
3664
+ },
3665
+ "updated_at": {
3666
+ "name": "updated_at",
3667
+ "type": "timestamp with time zone",
3668
+ "primaryKey": false,
3669
+ "notNull": true,
3670
+ "default": "now()"
3671
+ }
3672
+ },
3673
+ "indexes": {},
3674
+ "foreignKeys": {
3675
+ "pipeline_cursors_organisation_id_organisations_id_fk": {
3676
+ "name": "pipeline_cursors_organisation_id_organisations_id_fk",
3677
+ "tableFrom": "pipeline_cursors",
3678
+ "tableTo": "organisations",
3679
+ "columnsFrom": [
3680
+ "organisation_id"
3681
+ ],
3682
+ "columnsTo": [
3683
+ "id"
3684
+ ],
3685
+ "onDelete": "no action",
3686
+ "onUpdate": "no action"
3687
+ }
3688
+ },
3689
+ "compositePrimaryKeys": {
3690
+ "pipeline_cursors_pk": {
3691
+ "name": "pipeline_cursors_pk",
3692
+ "columns": [
3693
+ "organisation_id",
3694
+ "name"
3695
+ ]
3696
+ }
3697
+ },
3698
+ "uniqueConstraints": {},
3699
+ "policies": {},
3700
+ "checkConstraints": {},
3701
+ "isRLSEnabled": false
3702
+ },
3703
+ "public.price_item_links": {
3704
+ "name": "price_item_links",
3705
+ "schema": "",
3706
+ "columns": {
3707
+ "id": {
3708
+ "name": "id",
3709
+ "type": "uuid",
3710
+ "primaryKey": true,
3711
+ "notNull": true,
3712
+ "default": "gen_random_uuid()"
3713
+ },
3714
+ "organisation_id": {
3715
+ "name": "organisation_id",
3716
+ "type": "uuid",
3717
+ "primaryKey": false,
3718
+ "notNull": true
3719
+ },
3720
+ "price_item_id": {
3721
+ "name": "price_item_id",
3722
+ "type": "uuid",
3723
+ "primaryKey": false,
3724
+ "notNull": true
3725
+ },
3726
+ "system": {
3727
+ "name": "system",
3728
+ "type": "text",
3729
+ "primaryKey": false,
3730
+ "notNull": true
3731
+ },
3732
+ "external_id": {
3733
+ "name": "external_id",
3734
+ "type": "text",
3735
+ "primaryKey": false,
3736
+ "notNull": true
3737
+ },
3738
+ "external_code": {
3739
+ "name": "external_code",
3740
+ "type": "text",
3741
+ "primaryKey": false,
3742
+ "notNull": false
3743
+ },
3744
+ "matched_by": {
3745
+ "name": "matched_by",
3746
+ "type": "text",
3747
+ "primaryKey": false,
3748
+ "notNull": true
3749
+ },
3750
+ "created_by": {
3751
+ "name": "created_by",
3752
+ "type": "uuid",
3753
+ "primaryKey": false,
3754
+ "notNull": false
3755
+ },
3756
+ "created_at": {
3757
+ "name": "created_at",
3758
+ "type": "timestamp with time zone",
3759
+ "primaryKey": false,
3760
+ "notNull": true,
3761
+ "default": "now()"
3762
+ }
3763
+ },
3764
+ "indexes": {
3765
+ "price_item_links_external": {
3766
+ "name": "price_item_links_external",
3767
+ "columns": [
3768
+ {
3769
+ "expression": "organisation_id",
3770
+ "isExpression": false,
3771
+ "asc": true,
3772
+ "nulls": "last"
3773
+ },
3774
+ {
3775
+ "expression": "system",
3776
+ "isExpression": false,
3777
+ "asc": true,
3778
+ "nulls": "last"
3779
+ },
3780
+ {
3781
+ "expression": "external_id",
3782
+ "isExpression": false,
3783
+ "asc": true,
3784
+ "nulls": "last"
3785
+ }
3786
+ ],
3787
+ "isUnique": true,
3788
+ "concurrently": false,
3789
+ "method": "btree",
3790
+ "with": {}
3791
+ }
3792
+ },
3793
+ "foreignKeys": {
3794
+ "price_item_links_organisation_id_organisations_id_fk": {
3795
+ "name": "price_item_links_organisation_id_organisations_id_fk",
3796
+ "tableFrom": "price_item_links",
3797
+ "tableTo": "organisations",
3798
+ "columnsFrom": [
3799
+ "organisation_id"
3800
+ ],
3801
+ "columnsTo": [
3802
+ "id"
3803
+ ],
3804
+ "onDelete": "no action",
3805
+ "onUpdate": "no action"
3806
+ },
3807
+ "price_item_links_created_by_people_id_fk": {
3808
+ "name": "price_item_links_created_by_people_id_fk",
3809
+ "tableFrom": "price_item_links",
3810
+ "tableTo": "people",
3811
+ "columnsFrom": [
3812
+ "created_by"
3813
+ ],
3814
+ "columnsTo": [
3815
+ "id"
3816
+ ],
3817
+ "onDelete": "set null",
3818
+ "onUpdate": "no action"
3819
+ },
3820
+ "price_item_links_item_same_org": {
3821
+ "name": "price_item_links_item_same_org",
3822
+ "tableFrom": "price_item_links",
3823
+ "tableTo": "price_items",
3824
+ "columnsFrom": [
3825
+ "organisation_id",
3826
+ "price_item_id"
3827
+ ],
3828
+ "columnsTo": [
3829
+ "organisation_id",
3830
+ "id"
3831
+ ],
3832
+ "onDelete": "cascade",
3833
+ "onUpdate": "no action"
3834
+ }
3835
+ },
3836
+ "compositePrimaryKeys": {},
3837
+ "uniqueConstraints": {},
3838
+ "policies": {},
3839
+ "checkConstraints": {
3840
+ "price_item_links_matched_by_valid": {
3841
+ "name": "price_item_links_matched_by_valid",
3842
+ "value": "\"price_item_links\".\"matched_by\" in ('code', 'person')"
3843
+ },
3844
+ "price_item_links_system_valid": {
3845
+ "name": "price_item_links_system_valid",
3846
+ "value": "\"price_item_links\".\"system\" ~ '^[a-z][a-z0-9-]{1,31}$'"
3847
+ }
3848
+ },
3849
+ "isRLSEnabled": false
3850
+ },
3851
+ "public.price_items": {
3852
+ "name": "price_items",
3853
+ "schema": "",
3854
+ "columns": {
3855
+ "id": {
3856
+ "name": "id",
3857
+ "type": "uuid",
3858
+ "primaryKey": true,
3859
+ "notNull": true,
3860
+ "default": "gen_random_uuid()"
3861
+ },
3862
+ "organisation_id": {
3863
+ "name": "organisation_id",
3864
+ "type": "uuid",
3865
+ "primaryKey": false,
3866
+ "notNull": true
3867
+ },
3868
+ "code": {
3869
+ "name": "code",
3870
+ "type": "text",
3871
+ "primaryKey": false,
3872
+ "notNull": true
3873
+ },
3874
+ "name": {
3875
+ "name": "name",
3876
+ "type": "text",
3877
+ "primaryKey": false,
3878
+ "notNull": true
3879
+ },
3880
+ "description": {
3881
+ "name": "description",
3882
+ "type": "text",
3883
+ "primaryKey": false,
3884
+ "notNull": false
3885
+ },
3886
+ "unit_amount_cents": {
3887
+ "name": "unit_amount_cents",
3888
+ "type": "integer",
3889
+ "primaryKey": false,
3890
+ "notNull": true
3891
+ },
3892
+ "tax_code": {
3893
+ "name": "tax_code",
3894
+ "type": "text",
3895
+ "primaryKey": false,
3896
+ "notNull": true,
3897
+ "default": "'GST'"
3898
+ },
3899
+ "account_code": {
3900
+ "name": "account_code",
3901
+ "type": "text",
3902
+ "primaryKey": false,
3903
+ "notNull": false
3904
+ },
3905
+ "archived_at": {
3906
+ "name": "archived_at",
3907
+ "type": "timestamp with time zone",
3908
+ "primaryKey": false,
3909
+ "notNull": false
3910
+ },
3911
+ "updated_by": {
3912
+ "name": "updated_by",
3913
+ "type": "uuid",
3914
+ "primaryKey": false,
3915
+ "notNull": false
3916
+ },
3917
+ "created_at": {
3918
+ "name": "created_at",
3919
+ "type": "timestamp with time zone",
3920
+ "primaryKey": false,
3921
+ "notNull": true,
3922
+ "default": "now()"
3923
+ },
3924
+ "updated_at": {
3925
+ "name": "updated_at",
3926
+ "type": "timestamp with time zone",
3927
+ "primaryKey": false,
3928
+ "notNull": true,
3929
+ "default": "now()"
3930
+ }
3931
+ },
3932
+ "indexes": {},
3933
+ "foreignKeys": {
3934
+ "price_items_organisation_id_organisations_id_fk": {
3935
+ "name": "price_items_organisation_id_organisations_id_fk",
3936
+ "tableFrom": "price_items",
3937
+ "tableTo": "organisations",
3938
+ "columnsFrom": [
3939
+ "organisation_id"
3940
+ ],
3941
+ "columnsTo": [
3942
+ "id"
3943
+ ],
3944
+ "onDelete": "no action",
3945
+ "onUpdate": "no action"
3946
+ },
3947
+ "price_items_updated_by_people_id_fk": {
3948
+ "name": "price_items_updated_by_people_id_fk",
3949
+ "tableFrom": "price_items",
3950
+ "tableTo": "people",
3951
+ "columnsFrom": [
3952
+ "updated_by"
3953
+ ],
3954
+ "columnsTo": [
3955
+ "id"
3956
+ ],
3957
+ "onDelete": "set null",
3958
+ "onUpdate": "no action"
3959
+ }
3960
+ },
3961
+ "compositePrimaryKeys": {},
3962
+ "uniqueConstraints": {
3963
+ "price_items_org_id": {
3964
+ "name": "price_items_org_id",
3965
+ "nullsNotDistinct": false,
3966
+ "columns": [
3967
+ "organisation_id",
3968
+ "id"
3969
+ ]
3970
+ },
3971
+ "price_items_org_code": {
3972
+ "name": "price_items_org_code",
3973
+ "nullsNotDistinct": false,
3974
+ "columns": [
3975
+ "organisation_id",
3976
+ "code"
3977
+ ]
3978
+ }
3979
+ },
3980
+ "policies": {},
3981
+ "checkConstraints": {
3982
+ "price_items_tax_code_valid": {
3983
+ "name": "price_items_tax_code_valid",
3984
+ "value": "\"price_items\".\"tax_code\" in ('GST', 'GST_FREE')"
3985
+ }
3986
+ },
3987
+ "isRLSEnabled": false
3988
+ },
3989
+ "public.prior_links": {
3990
+ "name": "prior_links",
3991
+ "schema": "",
3992
+ "columns": {
3993
+ "id": {
3994
+ "name": "id",
3995
+ "type": "uuid",
3996
+ "primaryKey": true,
3997
+ "notNull": true,
3998
+ "default": "gen_random_uuid()"
3999
+ },
4000
+ "organisation_id": {
4001
+ "name": "organisation_id",
4002
+ "type": "uuid",
4003
+ "primaryKey": false,
4004
+ "notNull": true
4005
+ },
4006
+ "source_system": {
4007
+ "name": "source_system",
4008
+ "type": "text",
4009
+ "primaryKey": false,
4010
+ "notNull": true
4011
+ },
4012
+ "source_job_ref": {
4013
+ "name": "source_job_ref",
4014
+ "type": "text",
4015
+ "primaryKey": false,
4016
+ "notNull": true
4017
+ },
4018
+ "system": {
4019
+ "name": "system",
4020
+ "type": "text",
4021
+ "primaryKey": false,
4022
+ "notNull": true
4023
+ },
4024
+ "external_id": {
4025
+ "name": "external_id",
4026
+ "type": "text",
4027
+ "primaryKey": false,
4028
+ "notNull": true
4029
+ },
4030
+ "external_number": {
4031
+ "name": "external_number",
4032
+ "type": "text",
4033
+ "primaryKey": false,
4034
+ "notNull": false
4035
+ },
4036
+ "matched_by": {
4037
+ "name": "matched_by",
4038
+ "type": "text",
4039
+ "primaryKey": false,
4040
+ "notNull": true
4041
+ },
4042
+ "matched_at": {
4043
+ "name": "matched_at",
4044
+ "type": "timestamp with time zone",
4045
+ "primaryKey": false,
4046
+ "notNull": false
4047
+ },
4048
+ "origin": {
4049
+ "name": "origin",
4050
+ "type": "text",
4051
+ "primaryKey": false,
4052
+ "notNull": true
4053
+ },
4054
+ "created_at": {
4055
+ "name": "created_at",
4056
+ "type": "timestamp with time zone",
4057
+ "primaryKey": false,
4058
+ "notNull": true,
4059
+ "default": "now()"
4060
+ }
4061
+ },
4062
+ "indexes": {
4063
+ "prior_links_job": {
4064
+ "name": "prior_links_job",
4065
+ "columns": [
4066
+ {
4067
+ "expression": "organisation_id",
4068
+ "isExpression": false,
4069
+ "asc": true,
4070
+ "nulls": "last"
4071
+ },
4072
+ {
4073
+ "expression": "source_system",
4074
+ "isExpression": false,
4075
+ "asc": true,
4076
+ "nulls": "last"
4077
+ },
4078
+ {
4079
+ "expression": "source_job_ref",
4080
+ "isExpression": false,
4081
+ "asc": true,
4082
+ "nulls": "last"
4083
+ },
4084
+ {
4085
+ "expression": "system",
4086
+ "isExpression": false,
4087
+ "asc": true,
4088
+ "nulls": "last"
4089
+ }
4090
+ ],
4091
+ "isUnique": true,
4092
+ "concurrently": false,
4093
+ "method": "btree",
4094
+ "with": {}
4095
+ },
4096
+ "prior_links_external": {
4097
+ "name": "prior_links_external",
4098
+ "columns": [
4099
+ {
4100
+ "expression": "organisation_id",
4101
+ "isExpression": false,
4102
+ "asc": true,
4103
+ "nulls": "last"
4104
+ },
4105
+ {
4106
+ "expression": "system",
4107
+ "isExpression": false,
4108
+ "asc": true,
4109
+ "nulls": "last"
4110
+ },
4111
+ {
4112
+ "expression": "external_id",
4113
+ "isExpression": false,
4114
+ "asc": true,
4115
+ "nulls": "last"
4116
+ }
4117
+ ],
4118
+ "isUnique": false,
4119
+ "concurrently": false,
4120
+ "method": "btree",
4121
+ "with": {}
4122
+ }
4123
+ },
4124
+ "foreignKeys": {
4125
+ "prior_links_organisation_id_organisations_id_fk": {
4126
+ "name": "prior_links_organisation_id_organisations_id_fk",
4127
+ "tableFrom": "prior_links",
4128
+ "tableTo": "organisations",
4129
+ "columnsFrom": [
4130
+ "organisation_id"
4131
+ ],
4132
+ "columnsTo": [
4133
+ "id"
4134
+ ],
4135
+ "onDelete": "no action",
4136
+ "onUpdate": "no action"
4137
+ }
4138
+ },
4139
+ "compositePrimaryKeys": {},
4140
+ "uniqueConstraints": {},
4141
+ "policies": {},
4142
+ "checkConstraints": {
4143
+ "prior_links_matched_by_valid": {
4144
+ "name": "prior_links_matched_by_valid",
4145
+ "value": "matched_by in ('person', 'imported')"
4146
+ }
4147
+ },
4148
+ "isRLSEnabled": false
4149
+ },
4150
+ "public.review_items": {
4151
+ "name": "review_items",
4152
+ "schema": "",
4153
+ "columns": {
4154
+ "id": {
4155
+ "name": "id",
4156
+ "type": "uuid",
4157
+ "primaryKey": true,
4158
+ "notNull": true,
4159
+ "default": "gen_random_uuid()"
4160
+ },
4161
+ "organisation_id": {
4162
+ "name": "organisation_id",
4163
+ "type": "uuid",
4164
+ "primaryKey": false,
4165
+ "notNull": true
4166
+ },
4167
+ "kind": {
4168
+ "name": "kind",
4169
+ "type": "text",
4170
+ "primaryKey": false,
4171
+ "notNull": true
4172
+ },
4173
+ "entity": {
4174
+ "name": "entity",
4175
+ "type": "text",
4176
+ "primaryKey": false,
4177
+ "notNull": true
4178
+ },
4179
+ "flow_id": {
4180
+ "name": "flow_id",
4181
+ "type": "uuid",
4182
+ "primaryKey": false,
4183
+ "notNull": true
4184
+ },
4185
+ "systems": {
4186
+ "name": "systems",
4187
+ "type": "text[]",
4188
+ "primaryKey": false,
4189
+ "notNull": true,
4190
+ "default": "'{}'::text[]"
4191
+ },
4192
+ "evidence": {
4193
+ "name": "evidence",
4194
+ "type": "jsonb",
4195
+ "primaryKey": false,
4196
+ "notNull": true,
4197
+ "default": "'{}'::jsonb"
4198
+ },
4199
+ "money_at_risk_cents": {
4200
+ "name": "money_at_risk_cents",
4201
+ "type": "bigint",
4202
+ "primaryKey": false,
4203
+ "notNull": true,
4204
+ "default": 0
4205
+ },
4206
+ "state": {
4207
+ "name": "state",
4208
+ "type": "text",
4209
+ "primaryKey": false,
4210
+ "notNull": true,
4211
+ "default": "'open'"
4212
+ },
4213
+ "seen_count": {
4214
+ "name": "seen_count",
4215
+ "type": "integer",
4216
+ "primaryKey": false,
4217
+ "notNull": true,
4218
+ "default": 1
4219
+ },
4220
+ "resolution": {
4221
+ "name": "resolution",
4222
+ "type": "text",
4223
+ "primaryKey": false,
4224
+ "notNull": false
4225
+ },
4226
+ "note": {
4227
+ "name": "note",
4228
+ "type": "text",
4229
+ "primaryKey": false,
4230
+ "notNull": false
4231
+ },
4232
+ "resolved_by": {
4233
+ "name": "resolved_by",
4234
+ "type": "text",
4235
+ "primaryKey": false,
4236
+ "notNull": false
4237
+ },
4238
+ "resolved_at": {
4239
+ "name": "resolved_at",
4240
+ "type": "timestamp with time zone",
4241
+ "primaryKey": false,
4242
+ "notNull": false
4243
+ },
4244
+ "created_at": {
4245
+ "name": "created_at",
4246
+ "type": "timestamp with time zone",
4247
+ "primaryKey": false,
4248
+ "notNull": true,
4249
+ "default": "now()"
4250
+ },
4251
+ "updated_at": {
4252
+ "name": "updated_at",
4253
+ "type": "timestamp with time zone",
4254
+ "primaryKey": false,
4255
+ "notNull": true,
4256
+ "default": "now()"
4257
+ }
4258
+ },
4259
+ "indexes": {
4260
+ "review_items_one_open": {
4261
+ "name": "review_items_one_open",
4262
+ "columns": [
4263
+ {
4264
+ "expression": "organisation_id",
4265
+ "isExpression": false,
4266
+ "asc": true,
4267
+ "nulls": "last"
4268
+ },
4269
+ {
4270
+ "expression": "kind",
4271
+ "isExpression": false,
4272
+ "asc": true,
4273
+ "nulls": "last"
4274
+ },
4275
+ {
4276
+ "expression": "entity",
4277
+ "isExpression": false,
4278
+ "asc": true,
4279
+ "nulls": "last"
4280
+ },
4281
+ {
4282
+ "expression": "flow_id",
4283
+ "isExpression": false,
4284
+ "asc": true,
4285
+ "nulls": "last"
4286
+ }
4287
+ ],
4288
+ "isUnique": true,
4289
+ "where": "state = 'open'",
4290
+ "concurrently": false,
4291
+ "method": "btree",
4292
+ "with": {}
4293
+ },
4294
+ "review_items_queue": {
4295
+ "name": "review_items_queue",
4296
+ "columns": [
4297
+ {
4298
+ "expression": "organisation_id",
4299
+ "isExpression": false,
4300
+ "asc": true,
4301
+ "nulls": "last"
4302
+ },
4303
+ {
4304
+ "expression": "state",
4305
+ "isExpression": false,
4306
+ "asc": true,
4307
+ "nulls": "last"
4308
+ },
4309
+ {
4310
+ "expression": "money_at_risk_cents",
4311
+ "isExpression": false,
4312
+ "asc": true,
4313
+ "nulls": "last"
4314
+ }
4315
+ ],
4316
+ "isUnique": false,
4317
+ "concurrently": false,
4318
+ "method": "btree",
4319
+ "with": {}
4320
+ }
4321
+ },
4322
+ "foreignKeys": {
4323
+ "review_items_organisation_id_organisations_id_fk": {
4324
+ "name": "review_items_organisation_id_organisations_id_fk",
4325
+ "tableFrom": "review_items",
4326
+ "tableTo": "organisations",
4327
+ "columnsFrom": [
4328
+ "organisation_id"
4329
+ ],
4330
+ "columnsTo": [
4331
+ "id"
4332
+ ],
4333
+ "onDelete": "no action",
4334
+ "onUpdate": "no action"
4335
+ }
4336
+ },
4337
+ "compositePrimaryKeys": {},
4338
+ "uniqueConstraints": {
4339
+ "review_items_org_id": {
4340
+ "name": "review_items_org_id",
4341
+ "nullsNotDistinct": false,
4342
+ "columns": [
4343
+ "organisation_id",
4344
+ "id"
4345
+ ]
4346
+ }
4347
+ },
4348
+ "policies": {},
4349
+ "checkConstraints": {
4350
+ "review_items_state_valid": {
4351
+ "name": "review_items_state_valid",
4352
+ "value": "state in ('open', 'resolved', 'dismissed')"
4353
+ },
4354
+ "review_items_money_not_negative": {
4355
+ "name": "review_items_money_not_negative",
4356
+ "value": "\"review_items\".\"money_at_risk_cents\" >= 0"
4357
+ },
4358
+ "review_items_closed_has_resolution": {
4359
+ "name": "review_items_closed_has_resolution",
4360
+ "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)"
4361
+ }
4362
+ },
4363
+ "isRLSEnabled": false
4364
+ }
4365
+ },
4366
+ "enums": {},
4367
+ "schemas": {},
4368
+ "sequences": {},
4369
+ "roles": {},
4370
+ "policies": {},
4371
+ "views": {},
4372
+ "_meta": {
4373
+ "columns": {},
4374
+ "schemas": {},
4375
+ "tables": {}
4376
+ }
4377
+ }