@arcforgelabs/flow 2026.10.53 → 2026.11.2

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