@arcforgelabs/flow 2026.10.25 → 2026.10.27

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