@arcforgelabs/flow 2026.10.50 → 2026.10.52

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