@arcforgelabs/flow 2026.10.51 → 2026.10.53

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