@arcforgelabs/flow 2026.10.32 → 2026.10.34

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