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