@arcforgelabs/flow 2026.10.26 → 2026.10.29

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 (63) hide show
  1. package/README.md +6 -0
  2. package/npm-shrinkwrap.json +627 -2
  3. package/package.json +3 -2
  4. package/server/api/invoicing.js +313 -46
  5. package/server/app.js +30 -2
  6. package/server/core/automations.js +154 -0
  7. package/server/core/invoice-rules.js +226 -0
  8. package/server/core/invoices.js +8 -3
  9. package/server/core/invoicing-rules.js +255 -0
  10. package/server/core/job-board.js +130 -0
  11. package/server/core/ledger.js +57 -17
  12. package/server/core/line-mapping.js +337 -0
  13. package/server/core/monitoring.js +34 -0
  14. package/server/core/pipeline.js +16 -3
  15. package/server/core/sending.js +283 -0
  16. package/server/db/migrate-all.js +26 -0
  17. package/server/db/migrations/0010_invoicing_rules.sql +72 -0
  18. package/server/db/migrations/0011_invoice_rules.sql +27 -0
  19. package/server/db/migrations/0012_invoice_sending.sql +18 -0
  20. package/server/db/migrations/0013_line_mappings.sql +35 -0
  21. package/server/db/migrations/meta/0010_snapshot.json +3158 -0
  22. package/server/db/migrations/meta/0011_snapshot.json +3314 -0
  23. package/server/db/migrations/meta/0012_snapshot.json +3380 -0
  24. package/server/db/migrations/meta/0013_snapshot.json +3568 -0
  25. package/server/db/migrations/meta/_journal.json +28 -0
  26. package/server/db/schema.js +158 -0
  27. package/server/import/at-start.js +64 -2
  28. package/server/index.js +17 -5
  29. package/server/integrations/adapters.js +2 -1
  30. package/server/integrations/port.js +6 -0
  31. package/server/integrations/seazona/feed.js +62 -4
  32. package/server/integrations/seazona/index.js +7 -1
  33. package/server/integrations/seazona/lanes.js +4 -1
  34. package/server/integrations/seazona/ledger.js +2 -0
  35. package/server/integrations/seazona/migrations/0000_api_governor.sql +3 -3
  36. package/server/integrations/seazona/migrations/0001_mirror.sql +9 -9
  37. package/server/integrations/sentry/index.js +105 -0
  38. package/server/integrations/xero/client.js +5 -0
  39. package/server/integrations/xero/drafts.js +127 -17
  40. package/server/integrations/xero/index.js +11 -1
  41. package/server/integrations/xero/lookup.js +6 -2
  42. package/server/integrations/xero/migrations/0000_xero_connections.sql +1 -1
  43. package/server/integrations/xero/migrations/0001_xero_catalogue.sql +5 -5
  44. package/server/integrations/xero/migrations/0002_xero_invoice_pushes.sql +2 -2
  45. package/server/integrations/xero/migrations/0003_xero_payment_cursors.sql +1 -1
  46. package/server/integrations/xero/migrations/0004_xero_mirror.sql +7 -7
  47. package/server/integrations/xero/migrations/0005_xero_send_modes.sql +16 -0
  48. package/server/integrations/xero/migrations/meta/_journal.json +7 -0
  49. package/server/ui/app-page.js +7 -4
  50. package/server/ui/app.js +122 -6
  51. package/server/ui/automations.js +96 -0
  52. package/server/ui/clerk-appearance.js +21 -0
  53. package/server/ui/flow.css +243 -30
  54. package/server/ui/invoice-rules.js +237 -0
  55. package/server/ui/invoicing-settings.js +110 -0
  56. package/server/ui/invoicing.js +166 -20
  57. package/server/ui/job-board.js +155 -0
  58. package/server/ui/jobs.js +232 -84
  59. package/server/ui/line-mappings.js +60 -0
  60. package/server/ui/logos/sentry.svg +1 -0
  61. package/server/ui/monitoring.js +61 -0
  62. package/server/ui/routes.js +2 -2
  63. package/server/ui/search.js +145 -0
@@ -0,0 +1,3314 @@
1
+ {
2
+ "id": "08b87727-b323-4b65-88f9-13c7780db019",
3
+ "prevId": "706f24fe-fe15-45d7-8400-a6a5f9c66b49",
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_rules": {
1317
+ "name": "invoice_rules",
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
+ "name": {
1334
+ "name": "name",
1335
+ "type": "text",
1336
+ "primaryKey": false,
1337
+ "notNull": true
1338
+ },
1339
+ "position": {
1340
+ "name": "position",
1341
+ "type": "integer",
1342
+ "primaryKey": false,
1343
+ "notNull": true
1344
+ },
1345
+ "enabled": {
1346
+ "name": "enabled",
1347
+ "type": "boolean",
1348
+ "primaryKey": false,
1349
+ "notNull": true,
1350
+ "default": true
1351
+ },
1352
+ "trigger": {
1353
+ "name": "trigger",
1354
+ "type": "text",
1355
+ "primaryKey": false,
1356
+ "notNull": true,
1357
+ "default": "'job_ready'"
1358
+ },
1359
+ "conditions": {
1360
+ "name": "conditions",
1361
+ "type": "jsonb",
1362
+ "primaryKey": false,
1363
+ "notNull": true,
1364
+ "default": "'[]'::jsonb"
1365
+ },
1366
+ "action": {
1367
+ "name": "action",
1368
+ "type": "jsonb",
1369
+ "primaryKey": false,
1370
+ "notNull": true
1371
+ },
1372
+ "starter_key": {
1373
+ "name": "starter_key",
1374
+ "type": "text",
1375
+ "primaryKey": false,
1376
+ "notNull": false
1377
+ },
1378
+ "updated_by": {
1379
+ "name": "updated_by",
1380
+ "type": "uuid",
1381
+ "primaryKey": false,
1382
+ "notNull": false
1383
+ },
1384
+ "created_at": {
1385
+ "name": "created_at",
1386
+ "type": "timestamp with time zone",
1387
+ "primaryKey": false,
1388
+ "notNull": true,
1389
+ "default": "now()"
1390
+ },
1391
+ "updated_at": {
1392
+ "name": "updated_at",
1393
+ "type": "timestamp with time zone",
1394
+ "primaryKey": false,
1395
+ "notNull": true,
1396
+ "default": "now()"
1397
+ }
1398
+ },
1399
+ "indexes": {
1400
+ "invoice_rules_starter_key": {
1401
+ "name": "invoice_rules_starter_key",
1402
+ "columns": [
1403
+ {
1404
+ "expression": "organisation_id",
1405
+ "isExpression": false,
1406
+ "asc": true,
1407
+ "nulls": "last"
1408
+ },
1409
+ {
1410
+ "expression": "starter_key",
1411
+ "isExpression": false,
1412
+ "asc": true,
1413
+ "nulls": "last"
1414
+ }
1415
+ ],
1416
+ "isUnique": true,
1417
+ "concurrently": false,
1418
+ "method": "btree",
1419
+ "with": {}
1420
+ }
1421
+ },
1422
+ "foreignKeys": {
1423
+ "invoice_rules_organisation_id_organisations_id_fk": {
1424
+ "name": "invoice_rules_organisation_id_organisations_id_fk",
1425
+ "tableFrom": "invoice_rules",
1426
+ "tableTo": "organisations",
1427
+ "columnsFrom": [
1428
+ "organisation_id"
1429
+ ],
1430
+ "columnsTo": [
1431
+ "id"
1432
+ ],
1433
+ "onDelete": "no action",
1434
+ "onUpdate": "no action"
1435
+ },
1436
+ "invoice_rules_updated_by_people_id_fk": {
1437
+ "name": "invoice_rules_updated_by_people_id_fk",
1438
+ "tableFrom": "invoice_rules",
1439
+ "tableTo": "people",
1440
+ "columnsFrom": [
1441
+ "updated_by"
1442
+ ],
1443
+ "columnsTo": [
1444
+ "id"
1445
+ ],
1446
+ "onDelete": "set null",
1447
+ "onUpdate": "no action"
1448
+ }
1449
+ },
1450
+ "compositePrimaryKeys": {},
1451
+ "uniqueConstraints": {},
1452
+ "policies": {},
1453
+ "checkConstraints": {
1454
+ "invoice_rules_trigger_valid": {
1455
+ "name": "invoice_rules_trigger_valid",
1456
+ "value": "\"invoice_rules\".\"trigger\" in ('job_ready')"
1457
+ },
1458
+ "invoice_rules_name_valid": {
1459
+ "name": "invoice_rules_name_valid",
1460
+ "value": "length(\"invoice_rules\".\"name\") between 1 and 120"
1461
+ }
1462
+ },
1463
+ "isRLSEnabled": false
1464
+ },
1465
+ "public.invoice_versions": {
1466
+ "name": "invoice_versions",
1467
+ "schema": "",
1468
+ "columns": {
1469
+ "id": {
1470
+ "name": "id",
1471
+ "type": "uuid",
1472
+ "primaryKey": true,
1473
+ "notNull": true,
1474
+ "default": "gen_random_uuid()"
1475
+ },
1476
+ "organisation_id": {
1477
+ "name": "organisation_id",
1478
+ "type": "uuid",
1479
+ "primaryKey": false,
1480
+ "notNull": true
1481
+ },
1482
+ "invoice_id": {
1483
+ "name": "invoice_id",
1484
+ "type": "uuid",
1485
+ "primaryKey": false,
1486
+ "notNull": true
1487
+ },
1488
+ "version": {
1489
+ "name": "version",
1490
+ "type": "integer",
1491
+ "primaryKey": false,
1492
+ "notNull": true
1493
+ },
1494
+ "issued_at": {
1495
+ "name": "issued_at",
1496
+ "type": "timestamp with time zone",
1497
+ "primaryKey": false,
1498
+ "notNull": true,
1499
+ "default": "now()"
1500
+ },
1501
+ "issued_by": {
1502
+ "name": "issued_by",
1503
+ "type": "text",
1504
+ "primaryKey": false,
1505
+ "notNull": true
1506
+ },
1507
+ "document": {
1508
+ "name": "document",
1509
+ "type": "jsonb",
1510
+ "primaryKey": false,
1511
+ "notNull": true
1512
+ }
1513
+ },
1514
+ "indexes": {},
1515
+ "foreignKeys": {
1516
+ "invoice_versions_invoice_same_org": {
1517
+ "name": "invoice_versions_invoice_same_org",
1518
+ "tableFrom": "invoice_versions",
1519
+ "tableTo": "invoices",
1520
+ "columnsFrom": [
1521
+ "organisation_id",
1522
+ "invoice_id"
1523
+ ],
1524
+ "columnsTo": [
1525
+ "organisation_id",
1526
+ "id"
1527
+ ],
1528
+ "onDelete": "no action",
1529
+ "onUpdate": "no action"
1530
+ }
1531
+ },
1532
+ "compositePrimaryKeys": {},
1533
+ "uniqueConstraints": {
1534
+ "invoice_versions_invoice_version": {
1535
+ "name": "invoice_versions_invoice_version",
1536
+ "nullsNotDistinct": false,
1537
+ "columns": [
1538
+ "invoice_id",
1539
+ "version"
1540
+ ]
1541
+ }
1542
+ },
1543
+ "policies": {},
1544
+ "checkConstraints": {
1545
+ "invoice_versions_version_positive": {
1546
+ "name": "invoice_versions_version_positive",
1547
+ "value": "\"invoice_versions\".\"version\" > 0"
1548
+ }
1549
+ },
1550
+ "isRLSEnabled": false
1551
+ },
1552
+ "public.invoices": {
1553
+ "name": "invoices",
1554
+ "schema": "",
1555
+ "columns": {
1556
+ "id": {
1557
+ "name": "id",
1558
+ "type": "uuid",
1559
+ "primaryKey": true,
1560
+ "notNull": true,
1561
+ "default": "gen_random_uuid()"
1562
+ },
1563
+ "organisation_id": {
1564
+ "name": "organisation_id",
1565
+ "type": "uuid",
1566
+ "primaryKey": false,
1567
+ "notNull": true
1568
+ },
1569
+ "contact_id": {
1570
+ "name": "contact_id",
1571
+ "type": "uuid",
1572
+ "primaryKey": false,
1573
+ "notNull": true
1574
+ },
1575
+ "number": {
1576
+ "name": "number",
1577
+ "type": "text",
1578
+ "primaryKey": false,
1579
+ "notNull": false
1580
+ },
1581
+ "status": {
1582
+ "name": "status",
1583
+ "type": "text",
1584
+ "primaryKey": false,
1585
+ "notNull": true,
1586
+ "default": "'draft'"
1587
+ },
1588
+ "issued_version": {
1589
+ "name": "issued_version",
1590
+ "type": "integer",
1591
+ "primaryKey": false,
1592
+ "notNull": true,
1593
+ "default": 0
1594
+ },
1595
+ "reference": {
1596
+ "name": "reference",
1597
+ "type": "text",
1598
+ "primaryKey": false,
1599
+ "notNull": false
1600
+ },
1601
+ "currency": {
1602
+ "name": "currency",
1603
+ "type": "text",
1604
+ "primaryKey": false,
1605
+ "notNull": true,
1606
+ "default": "'AUD'"
1607
+ },
1608
+ "issue_date": {
1609
+ "name": "issue_date",
1610
+ "type": "date",
1611
+ "primaryKey": false,
1612
+ "notNull": false
1613
+ },
1614
+ "due_date": {
1615
+ "name": "due_date",
1616
+ "type": "date",
1617
+ "primaryKey": false,
1618
+ "notNull": false
1619
+ },
1620
+ "subtotal_cents": {
1621
+ "name": "subtotal_cents",
1622
+ "type": "integer",
1623
+ "primaryKey": false,
1624
+ "notNull": true,
1625
+ "default": 0
1626
+ },
1627
+ "tax_cents": {
1628
+ "name": "tax_cents",
1629
+ "type": "integer",
1630
+ "primaryKey": false,
1631
+ "notNull": true,
1632
+ "default": 0
1633
+ },
1634
+ "total_cents": {
1635
+ "name": "total_cents",
1636
+ "type": "integer",
1637
+ "primaryKey": false,
1638
+ "notNull": true,
1639
+ "default": 0
1640
+ },
1641
+ "created_at": {
1642
+ "name": "created_at",
1643
+ "type": "timestamp with time zone",
1644
+ "primaryKey": false,
1645
+ "notNull": true,
1646
+ "default": "now()"
1647
+ },
1648
+ "updated_at": {
1649
+ "name": "updated_at",
1650
+ "type": "timestamp with time zone",
1651
+ "primaryKey": false,
1652
+ "notNull": true,
1653
+ "default": "now()"
1654
+ }
1655
+ },
1656
+ "indexes": {},
1657
+ "foreignKeys": {
1658
+ "invoices_organisation_id_organisations_id_fk": {
1659
+ "name": "invoices_organisation_id_organisations_id_fk",
1660
+ "tableFrom": "invoices",
1661
+ "tableTo": "organisations",
1662
+ "columnsFrom": [
1663
+ "organisation_id"
1664
+ ],
1665
+ "columnsTo": [
1666
+ "id"
1667
+ ],
1668
+ "onDelete": "no action",
1669
+ "onUpdate": "no action"
1670
+ },
1671
+ "invoices_contact_same_org": {
1672
+ "name": "invoices_contact_same_org",
1673
+ "tableFrom": "invoices",
1674
+ "tableTo": "contacts",
1675
+ "columnsFrom": [
1676
+ "organisation_id",
1677
+ "contact_id"
1678
+ ],
1679
+ "columnsTo": [
1680
+ "organisation_id",
1681
+ "id"
1682
+ ],
1683
+ "onDelete": "no action",
1684
+ "onUpdate": "no action"
1685
+ }
1686
+ },
1687
+ "compositePrimaryKeys": {},
1688
+ "uniqueConstraints": {
1689
+ "invoices_org_id": {
1690
+ "name": "invoices_org_id",
1691
+ "nullsNotDistinct": false,
1692
+ "columns": [
1693
+ "organisation_id",
1694
+ "id"
1695
+ ]
1696
+ },
1697
+ "invoices_org_number": {
1698
+ "name": "invoices_org_number",
1699
+ "nullsNotDistinct": false,
1700
+ "columns": [
1701
+ "organisation_id",
1702
+ "number"
1703
+ ]
1704
+ }
1705
+ },
1706
+ "policies": {},
1707
+ "checkConstraints": {
1708
+ "invoices_status_valid": {
1709
+ "name": "invoices_status_valid",
1710
+ "value": "\"invoices\".\"status\" in ('draft', 'issued', 'void')"
1711
+ },
1712
+ "invoices_issued_has_number": {
1713
+ "name": "invoices_issued_has_number",
1714
+ "value": "\"invoices\".\"status\" = 'draft' or \"invoices\".\"number\" is not null"
1715
+ }
1716
+ },
1717
+ "isRLSEnabled": false
1718
+ },
1719
+ "public.invoicing_settings": {
1720
+ "name": "invoicing_settings",
1721
+ "schema": "",
1722
+ "columns": {
1723
+ "organisation_id": {
1724
+ "name": "organisation_id",
1725
+ "type": "uuid",
1726
+ "primaryKey": true,
1727
+ "notNull": true
1728
+ },
1729
+ "send_mode": {
1730
+ "name": "send_mode",
1731
+ "type": "text",
1732
+ "primaryKey": false,
1733
+ "notNull": true,
1734
+ "default": "'accounting_draft'"
1735
+ },
1736
+ "stale_days": {
1737
+ "name": "stale_days",
1738
+ "type": "integer",
1739
+ "primaryKey": false,
1740
+ "notNull": true,
1741
+ "default": 90
1742
+ },
1743
+ "payment_terms_days": {
1744
+ "name": "payment_terms_days",
1745
+ "type": "integer",
1746
+ "primaryKey": false,
1747
+ "notNull": true,
1748
+ "default": 30
1749
+ },
1750
+ "require_practitioner": {
1751
+ "name": "require_practitioner",
1752
+ "type": "boolean",
1753
+ "primaryKey": false,
1754
+ "notNull": true,
1755
+ "default": false
1756
+ },
1757
+ "rush_item_code": {
1758
+ "name": "rush_item_code",
1759
+ "type": "text",
1760
+ "primaryKey": false,
1761
+ "notNull": false
1762
+ },
1763
+ "rush_percent": {
1764
+ "name": "rush_percent",
1765
+ "type": "integer",
1766
+ "primaryKey": false,
1767
+ "notNull": true,
1768
+ "default": 20
1769
+ },
1770
+ "rules_seeded": {
1771
+ "name": "rules_seeded",
1772
+ "type": "boolean",
1773
+ "primaryKey": false,
1774
+ "notNull": true,
1775
+ "default": false
1776
+ },
1777
+ "updated_by": {
1778
+ "name": "updated_by",
1779
+ "type": "uuid",
1780
+ "primaryKey": false,
1781
+ "notNull": false
1782
+ },
1783
+ "updated_at": {
1784
+ "name": "updated_at",
1785
+ "type": "timestamp with time zone",
1786
+ "primaryKey": false,
1787
+ "notNull": true,
1788
+ "default": "now()"
1789
+ }
1790
+ },
1791
+ "indexes": {},
1792
+ "foreignKeys": {
1793
+ "invoicing_settings_organisation_id_organisations_id_fk": {
1794
+ "name": "invoicing_settings_organisation_id_organisations_id_fk",
1795
+ "tableFrom": "invoicing_settings",
1796
+ "tableTo": "organisations",
1797
+ "columnsFrom": [
1798
+ "organisation_id"
1799
+ ],
1800
+ "columnsTo": [
1801
+ "id"
1802
+ ],
1803
+ "onDelete": "no action",
1804
+ "onUpdate": "no action"
1805
+ },
1806
+ "invoicing_settings_updated_by_people_id_fk": {
1807
+ "name": "invoicing_settings_updated_by_people_id_fk",
1808
+ "tableFrom": "invoicing_settings",
1809
+ "tableTo": "people",
1810
+ "columnsFrom": [
1811
+ "updated_by"
1812
+ ],
1813
+ "columnsTo": [
1814
+ "id"
1815
+ ],
1816
+ "onDelete": "set null",
1817
+ "onUpdate": "no action"
1818
+ }
1819
+ },
1820
+ "compositePrimaryKeys": {},
1821
+ "uniqueConstraints": {},
1822
+ "policies": {},
1823
+ "checkConstraints": {
1824
+ "invoicing_settings_send_mode_valid": {
1825
+ "name": "invoicing_settings_send_mode_valid",
1826
+ "value": "send_mode in ('accounting_draft', 'approve_and_email')"
1827
+ },
1828
+ "invoicing_settings_stale_days_valid": {
1829
+ "name": "invoicing_settings_stale_days_valid",
1830
+ "value": "\"invoicing_settings\".\"stale_days\" between 1 and 3650"
1831
+ },
1832
+ "invoicing_settings_terms_valid": {
1833
+ "name": "invoicing_settings_terms_valid",
1834
+ "value": "\"invoicing_settings\".\"payment_terms_days\" between 0 and 365"
1835
+ },
1836
+ "invoicing_settings_rush_valid": {
1837
+ "name": "invoicing_settings_rush_valid",
1838
+ "value": "\"invoicing_settings\".\"rush_percent\" between 0 and 100"
1839
+ }
1840
+ },
1841
+ "isRLSEnabled": false
1842
+ },
1843
+ "public.link_rejections": {
1844
+ "name": "link_rejections",
1845
+ "schema": "",
1846
+ "columns": {
1847
+ "organisation_id": {
1848
+ "name": "organisation_id",
1849
+ "type": "uuid",
1850
+ "primaryKey": false,
1851
+ "notNull": true
1852
+ },
1853
+ "obligation_id": {
1854
+ "name": "obligation_id",
1855
+ "type": "uuid",
1856
+ "primaryKey": false,
1857
+ "notNull": true
1858
+ },
1859
+ "system": {
1860
+ "name": "system",
1861
+ "type": "text",
1862
+ "primaryKey": false,
1863
+ "notNull": true
1864
+ },
1865
+ "external_id": {
1866
+ "name": "external_id",
1867
+ "type": "text",
1868
+ "primaryKey": false,
1869
+ "notNull": true
1870
+ },
1871
+ "actor": {
1872
+ "name": "actor",
1873
+ "type": "text",
1874
+ "primaryKey": false,
1875
+ "notNull": true
1876
+ },
1877
+ "created_at": {
1878
+ "name": "created_at",
1879
+ "type": "timestamp with time zone",
1880
+ "primaryKey": false,
1881
+ "notNull": true,
1882
+ "default": "now()"
1883
+ }
1884
+ },
1885
+ "indexes": {},
1886
+ "foreignKeys": {
1887
+ "link_rejections_organisation_id_organisations_id_fk": {
1888
+ "name": "link_rejections_organisation_id_organisations_id_fk",
1889
+ "tableFrom": "link_rejections",
1890
+ "tableTo": "organisations",
1891
+ "columnsFrom": [
1892
+ "organisation_id"
1893
+ ],
1894
+ "columnsTo": [
1895
+ "id"
1896
+ ],
1897
+ "onDelete": "no action",
1898
+ "onUpdate": "no action"
1899
+ },
1900
+ "link_rejections_obligation_same_org": {
1901
+ "name": "link_rejections_obligation_same_org",
1902
+ "tableFrom": "link_rejections",
1903
+ "tableTo": "billing_obligations",
1904
+ "columnsFrom": [
1905
+ "organisation_id",
1906
+ "obligation_id"
1907
+ ],
1908
+ "columnsTo": [
1909
+ "organisation_id",
1910
+ "id"
1911
+ ],
1912
+ "onDelete": "no action",
1913
+ "onUpdate": "no action"
1914
+ }
1915
+ },
1916
+ "compositePrimaryKeys": {
1917
+ "link_rejections_pk": {
1918
+ "name": "link_rejections_pk",
1919
+ "columns": [
1920
+ "organisation_id",
1921
+ "obligation_id",
1922
+ "system",
1923
+ "external_id"
1924
+ ]
1925
+ }
1926
+ },
1927
+ "uniqueConstraints": {},
1928
+ "policies": {},
1929
+ "checkConstraints": {},
1930
+ "isRLSEnabled": false
1931
+ },
1932
+ "public.link_suggestions": {
1933
+ "name": "link_suggestions",
1934
+ "schema": "",
1935
+ "columns": {
1936
+ "id": {
1937
+ "name": "id",
1938
+ "type": "uuid",
1939
+ "primaryKey": true,
1940
+ "notNull": true,
1941
+ "default": "gen_random_uuid()"
1942
+ },
1943
+ "organisation_id": {
1944
+ "name": "organisation_id",
1945
+ "type": "uuid",
1946
+ "primaryKey": false,
1947
+ "notNull": true
1948
+ },
1949
+ "obligation_id": {
1950
+ "name": "obligation_id",
1951
+ "type": "uuid",
1952
+ "primaryKey": false,
1953
+ "notNull": true
1954
+ },
1955
+ "system": {
1956
+ "name": "system",
1957
+ "type": "text",
1958
+ "primaryKey": false,
1959
+ "notNull": true
1960
+ },
1961
+ "external_id": {
1962
+ "name": "external_id",
1963
+ "type": "text",
1964
+ "primaryKey": false,
1965
+ "notNull": true
1966
+ },
1967
+ "external_number": {
1968
+ "name": "external_number",
1969
+ "type": "text",
1970
+ "primaryKey": false,
1971
+ "notNull": false
1972
+ },
1973
+ "score": {
1974
+ "name": "score",
1975
+ "type": "integer",
1976
+ "primaryKey": false,
1977
+ "notNull": true
1978
+ },
1979
+ "rank": {
1980
+ "name": "rank",
1981
+ "type": "integer",
1982
+ "primaryKey": false,
1983
+ "notNull": true
1984
+ },
1985
+ "signals": {
1986
+ "name": "signals",
1987
+ "type": "jsonb",
1988
+ "primaryKey": false,
1989
+ "notNull": true,
1990
+ "default": "'[]'::jsonb"
1991
+ },
1992
+ "state": {
1993
+ "name": "state",
1994
+ "type": "text",
1995
+ "primaryKey": false,
1996
+ "notNull": true,
1997
+ "default": "'open'"
1998
+ },
1999
+ "decided_by": {
2000
+ "name": "decided_by",
2001
+ "type": "text",
2002
+ "primaryKey": false,
2003
+ "notNull": false
2004
+ },
2005
+ "decided_at": {
2006
+ "name": "decided_at",
2007
+ "type": "timestamp with time zone",
2008
+ "primaryKey": false,
2009
+ "notNull": false
2010
+ },
2011
+ "created_at": {
2012
+ "name": "created_at",
2013
+ "type": "timestamp with time zone",
2014
+ "primaryKey": false,
2015
+ "notNull": true,
2016
+ "default": "now()"
2017
+ },
2018
+ "updated_at": {
2019
+ "name": "updated_at",
2020
+ "type": "timestamp with time zone",
2021
+ "primaryKey": false,
2022
+ "notNull": true,
2023
+ "default": "now()"
2024
+ }
2025
+ },
2026
+ "indexes": {
2027
+ "link_suggestions_open": {
2028
+ "name": "link_suggestions_open",
2029
+ "columns": [
2030
+ {
2031
+ "expression": "organisation_id",
2032
+ "isExpression": false,
2033
+ "asc": true,
2034
+ "nulls": "last"
2035
+ },
2036
+ {
2037
+ "expression": "state",
2038
+ "isExpression": false,
2039
+ "asc": true,
2040
+ "nulls": "last"
2041
+ },
2042
+ {
2043
+ "expression": "obligation_id",
2044
+ "isExpression": false,
2045
+ "asc": true,
2046
+ "nulls": "last"
2047
+ }
2048
+ ],
2049
+ "isUnique": false,
2050
+ "concurrently": false,
2051
+ "method": "btree",
2052
+ "with": {}
2053
+ }
2054
+ },
2055
+ "foreignKeys": {
2056
+ "link_suggestions_organisation_id_organisations_id_fk": {
2057
+ "name": "link_suggestions_organisation_id_organisations_id_fk",
2058
+ "tableFrom": "link_suggestions",
2059
+ "tableTo": "organisations",
2060
+ "columnsFrom": [
2061
+ "organisation_id"
2062
+ ],
2063
+ "columnsTo": [
2064
+ "id"
2065
+ ],
2066
+ "onDelete": "no action",
2067
+ "onUpdate": "no action"
2068
+ },
2069
+ "link_suggestions_obligation_same_org": {
2070
+ "name": "link_suggestions_obligation_same_org",
2071
+ "tableFrom": "link_suggestions",
2072
+ "tableTo": "billing_obligations",
2073
+ "columnsFrom": [
2074
+ "organisation_id",
2075
+ "obligation_id"
2076
+ ],
2077
+ "columnsTo": [
2078
+ "organisation_id",
2079
+ "id"
2080
+ ],
2081
+ "onDelete": "no action",
2082
+ "onUpdate": "no action"
2083
+ }
2084
+ },
2085
+ "compositePrimaryKeys": {},
2086
+ "uniqueConstraints": {
2087
+ "link_suggestions_pair": {
2088
+ "name": "link_suggestions_pair",
2089
+ "nullsNotDistinct": false,
2090
+ "columns": [
2091
+ "organisation_id",
2092
+ "obligation_id",
2093
+ "system",
2094
+ "external_id"
2095
+ ]
2096
+ }
2097
+ },
2098
+ "policies": {},
2099
+ "checkConstraints": {
2100
+ "link_suggestions_state_valid": {
2101
+ "name": "link_suggestions_state_valid",
2102
+ "value": "state in ('open', 'accepted', 'rejected', 'stale')"
2103
+ }
2104
+ },
2105
+ "isRLSEnabled": false
2106
+ },
2107
+ "public.obligation_events": {
2108
+ "name": "obligation_events",
2109
+ "schema": "",
2110
+ "columns": {
2111
+ "id": {
2112
+ "name": "id",
2113
+ "type": "uuid",
2114
+ "primaryKey": true,
2115
+ "notNull": true,
2116
+ "default": "gen_random_uuid()"
2117
+ },
2118
+ "organisation_id": {
2119
+ "name": "organisation_id",
2120
+ "type": "uuid",
2121
+ "primaryKey": false,
2122
+ "notNull": true
2123
+ },
2124
+ "obligation_id": {
2125
+ "name": "obligation_id",
2126
+ "type": "uuid",
2127
+ "primaryKey": false,
2128
+ "notNull": true
2129
+ },
2130
+ "kind": {
2131
+ "name": "kind",
2132
+ "type": "text",
2133
+ "primaryKey": false,
2134
+ "notNull": true
2135
+ },
2136
+ "actor": {
2137
+ "name": "actor",
2138
+ "type": "text",
2139
+ "primaryKey": false,
2140
+ "notNull": true
2141
+ },
2142
+ "evidence": {
2143
+ "name": "evidence",
2144
+ "type": "jsonb",
2145
+ "primaryKey": false,
2146
+ "notNull": true,
2147
+ "default": "'{}'::jsonb"
2148
+ },
2149
+ "created_at": {
2150
+ "name": "created_at",
2151
+ "type": "timestamp with time zone",
2152
+ "primaryKey": false,
2153
+ "notNull": true,
2154
+ "default": "now()"
2155
+ }
2156
+ },
2157
+ "indexes": {},
2158
+ "foreignKeys": {
2159
+ "obligation_events_obligation_same_org": {
2160
+ "name": "obligation_events_obligation_same_org",
2161
+ "tableFrom": "obligation_events",
2162
+ "tableTo": "billing_obligations",
2163
+ "columnsFrom": [
2164
+ "organisation_id",
2165
+ "obligation_id"
2166
+ ],
2167
+ "columnsTo": [
2168
+ "organisation_id",
2169
+ "id"
2170
+ ],
2171
+ "onDelete": "no action",
2172
+ "onUpdate": "no action"
2173
+ }
2174
+ },
2175
+ "compositePrimaryKeys": {},
2176
+ "uniqueConstraints": {},
2177
+ "policies": {},
2178
+ "checkConstraints": {},
2179
+ "isRLSEnabled": false
2180
+ },
2181
+ "public.obligation_payments": {
2182
+ "name": "obligation_payments",
2183
+ "schema": "",
2184
+ "columns": {
2185
+ "id": {
2186
+ "name": "id",
2187
+ "type": "uuid",
2188
+ "primaryKey": true,
2189
+ "notNull": true,
2190
+ "default": "gen_random_uuid()"
2191
+ },
2192
+ "organisation_id": {
2193
+ "name": "organisation_id",
2194
+ "type": "uuid",
2195
+ "primaryKey": false,
2196
+ "notNull": true
2197
+ },
2198
+ "obligation_id": {
2199
+ "name": "obligation_id",
2200
+ "type": "uuid",
2201
+ "primaryKey": false,
2202
+ "notNull": true
2203
+ },
2204
+ "payment_ref": {
2205
+ "name": "payment_ref",
2206
+ "type": "text",
2207
+ "primaryKey": false,
2208
+ "notNull": true
2209
+ },
2210
+ "paid_on": {
2211
+ "name": "paid_on",
2212
+ "type": "date",
2213
+ "primaryKey": false,
2214
+ "notNull": true
2215
+ },
2216
+ "amount_cents": {
2217
+ "name": "amount_cents",
2218
+ "type": "integer",
2219
+ "primaryKey": false,
2220
+ "notNull": true
2221
+ },
2222
+ "reference": {
2223
+ "name": "reference",
2224
+ "type": "text",
2225
+ "primaryKey": false,
2226
+ "notNull": false
2227
+ },
2228
+ "reconciled": {
2229
+ "name": "reconciled",
2230
+ "type": "boolean",
2231
+ "primaryKey": false,
2232
+ "notNull": true
2233
+ },
2234
+ "accounting_url": {
2235
+ "name": "accounting_url",
2236
+ "type": "text",
2237
+ "primaryKey": false,
2238
+ "notNull": false
2239
+ },
2240
+ "observed_at": {
2241
+ "name": "observed_at",
2242
+ "type": "timestamp with time zone",
2243
+ "primaryKey": false,
2244
+ "notNull": true,
2245
+ "default": "now()"
2246
+ }
2247
+ },
2248
+ "indexes": {},
2249
+ "foreignKeys": {
2250
+ "obligation_payments_obligation_same_org": {
2251
+ "name": "obligation_payments_obligation_same_org",
2252
+ "tableFrom": "obligation_payments",
2253
+ "tableTo": "billing_obligations",
2254
+ "columnsFrom": [
2255
+ "organisation_id",
2256
+ "obligation_id"
2257
+ ],
2258
+ "columnsTo": [
2259
+ "organisation_id",
2260
+ "id"
2261
+ ],
2262
+ "onDelete": "no action",
2263
+ "onUpdate": "no action"
2264
+ }
2265
+ },
2266
+ "compositePrimaryKeys": {},
2267
+ "uniqueConstraints": {
2268
+ "obligation_payments_ref": {
2269
+ "name": "obligation_payments_ref",
2270
+ "nullsNotDistinct": false,
2271
+ "columns": [
2272
+ "organisation_id",
2273
+ "obligation_id",
2274
+ "payment_ref"
2275
+ ]
2276
+ }
2277
+ },
2278
+ "policies": {},
2279
+ "checkConstraints": {
2280
+ "obligation_payments_amount_positive": {
2281
+ "name": "obligation_payments_amount_positive",
2282
+ "value": "\"obligation_payments\".\"amount_cents\" > 0"
2283
+ }
2284
+ },
2285
+ "isRLSEnabled": false
2286
+ },
2287
+ "public.obligation_writebacks": {
2288
+ "name": "obligation_writebacks",
2289
+ "schema": "",
2290
+ "columns": {
2291
+ "id": {
2292
+ "name": "id",
2293
+ "type": "uuid",
2294
+ "primaryKey": true,
2295
+ "notNull": true,
2296
+ "default": "gen_random_uuid()"
2297
+ },
2298
+ "organisation_id": {
2299
+ "name": "organisation_id",
2300
+ "type": "uuid",
2301
+ "primaryKey": false,
2302
+ "notNull": true
2303
+ },
2304
+ "obligation_id": {
2305
+ "name": "obligation_id",
2306
+ "type": "uuid",
2307
+ "primaryKey": false,
2308
+ "notNull": true
2309
+ },
2310
+ "target_system": {
2311
+ "name": "target_system",
2312
+ "type": "text",
2313
+ "primaryKey": false,
2314
+ "notNull": true
2315
+ },
2316
+ "status": {
2317
+ "name": "status",
2318
+ "type": "text",
2319
+ "primaryKey": false,
2320
+ "notNull": true
2321
+ },
2322
+ "state": {
2323
+ "name": "state",
2324
+ "type": "text",
2325
+ "primaryKey": false,
2326
+ "notNull": true,
2327
+ "default": "'pending'"
2328
+ },
2329
+ "evidence": {
2330
+ "name": "evidence",
2331
+ "type": "jsonb",
2332
+ "primaryKey": false,
2333
+ "notNull": true
2334
+ },
2335
+ "attempts": {
2336
+ "name": "attempts",
2337
+ "type": "integer",
2338
+ "primaryKey": false,
2339
+ "notNull": true,
2340
+ "default": 0
2341
+ },
2342
+ "last_error": {
2343
+ "name": "last_error",
2344
+ "type": "text",
2345
+ "primaryKey": false,
2346
+ "notNull": false
2347
+ },
2348
+ "sent_at": {
2349
+ "name": "sent_at",
2350
+ "type": "timestamp with time zone",
2351
+ "primaryKey": false,
2352
+ "notNull": false
2353
+ },
2354
+ "created_at": {
2355
+ "name": "created_at",
2356
+ "type": "timestamp with time zone",
2357
+ "primaryKey": false,
2358
+ "notNull": true,
2359
+ "default": "now()"
2360
+ },
2361
+ "updated_at": {
2362
+ "name": "updated_at",
2363
+ "type": "timestamp with time zone",
2364
+ "primaryKey": false,
2365
+ "notNull": true,
2366
+ "default": "now()"
2367
+ }
2368
+ },
2369
+ "indexes": {},
2370
+ "foreignKeys": {
2371
+ "obligation_writebacks_obligation_same_org": {
2372
+ "name": "obligation_writebacks_obligation_same_org",
2373
+ "tableFrom": "obligation_writebacks",
2374
+ "tableTo": "billing_obligations",
2375
+ "columnsFrom": [
2376
+ "organisation_id",
2377
+ "obligation_id"
2378
+ ],
2379
+ "columnsTo": [
2380
+ "organisation_id",
2381
+ "id"
2382
+ ],
2383
+ "onDelete": "no action",
2384
+ "onUpdate": "no action"
2385
+ }
2386
+ },
2387
+ "compositePrimaryKeys": {},
2388
+ "uniqueConstraints": {
2389
+ "obligation_writebacks_status": {
2390
+ "name": "obligation_writebacks_status",
2391
+ "nullsNotDistinct": false,
2392
+ "columns": [
2393
+ "organisation_id",
2394
+ "obligation_id",
2395
+ "status"
2396
+ ]
2397
+ }
2398
+ },
2399
+ "policies": {},
2400
+ "checkConstraints": {
2401
+ "obligation_writebacks_state_valid": {
2402
+ "name": "obligation_writebacks_state_valid",
2403
+ "value": "state in ('pending', 'sent', 'failed', 'not_supported')"
2404
+ }
2405
+ },
2406
+ "isRLSEnabled": false
2407
+ },
2408
+ "public.organisations": {
2409
+ "name": "organisations",
2410
+ "schema": "",
2411
+ "columns": {
2412
+ "id": {
2413
+ "name": "id",
2414
+ "type": "uuid",
2415
+ "primaryKey": true,
2416
+ "notNull": true,
2417
+ "default": "gen_random_uuid()"
2418
+ },
2419
+ "name": {
2420
+ "name": "name",
2421
+ "type": "text",
2422
+ "primaryKey": false,
2423
+ "notNull": true
2424
+ },
2425
+ "invoice_prefix": {
2426
+ "name": "invoice_prefix",
2427
+ "type": "text",
2428
+ "primaryKey": false,
2429
+ "notNull": true,
2430
+ "default": "'INV-'"
2431
+ },
2432
+ "next_invoice_number": {
2433
+ "name": "next_invoice_number",
2434
+ "type": "integer",
2435
+ "primaryKey": false,
2436
+ "notNull": true,
2437
+ "default": 1
2438
+ },
2439
+ "created_at": {
2440
+ "name": "created_at",
2441
+ "type": "timestamp with time zone",
2442
+ "primaryKey": false,
2443
+ "notNull": true,
2444
+ "default": "now()"
2445
+ }
2446
+ },
2447
+ "indexes": {},
2448
+ "foreignKeys": {},
2449
+ "compositePrimaryKeys": {},
2450
+ "uniqueConstraints": {},
2451
+ "policies": {},
2452
+ "checkConstraints": {
2453
+ "organisations_next_invoice_number_positive": {
2454
+ "name": "organisations_next_invoice_number_positive",
2455
+ "value": "\"organisations\".\"next_invoice_number\" > 0"
2456
+ }
2457
+ },
2458
+ "isRLSEnabled": false
2459
+ },
2460
+ "public.outbox": {
2461
+ "name": "outbox",
2462
+ "schema": "",
2463
+ "columns": {
2464
+ "id": {
2465
+ "name": "id",
2466
+ "type": "uuid",
2467
+ "primaryKey": true,
2468
+ "notNull": true,
2469
+ "default": "gen_random_uuid()"
2470
+ },
2471
+ "organisation_id": {
2472
+ "name": "organisation_id",
2473
+ "type": "uuid",
2474
+ "primaryKey": false,
2475
+ "notNull": true
2476
+ },
2477
+ "system": {
2478
+ "name": "system",
2479
+ "type": "text",
2480
+ "primaryKey": false,
2481
+ "notNull": true
2482
+ },
2483
+ "action": {
2484
+ "name": "action",
2485
+ "type": "text",
2486
+ "primaryKey": false,
2487
+ "notNull": true
2488
+ },
2489
+ "entity": {
2490
+ "name": "entity",
2491
+ "type": "text",
2492
+ "primaryKey": false,
2493
+ "notNull": true
2494
+ },
2495
+ "flow_id": {
2496
+ "name": "flow_id",
2497
+ "type": "uuid",
2498
+ "primaryKey": false,
2499
+ "notNull": true
2500
+ },
2501
+ "idempotency_key": {
2502
+ "name": "idempotency_key",
2503
+ "type": "text",
2504
+ "primaryKey": false,
2505
+ "notNull": true
2506
+ },
2507
+ "request": {
2508
+ "name": "request",
2509
+ "type": "jsonb",
2510
+ "primaryKey": false,
2511
+ "notNull": true
2512
+ },
2513
+ "state": {
2514
+ "name": "state",
2515
+ "type": "text",
2516
+ "primaryKey": false,
2517
+ "notNull": true,
2518
+ "default": "'pending'"
2519
+ },
2520
+ "external_id": {
2521
+ "name": "external_id",
2522
+ "type": "text",
2523
+ "primaryKey": false,
2524
+ "notNull": false
2525
+ },
2526
+ "attempts": {
2527
+ "name": "attempts",
2528
+ "type": "integer",
2529
+ "primaryKey": false,
2530
+ "notNull": true,
2531
+ "default": 0
2532
+ },
2533
+ "last_error": {
2534
+ "name": "last_error",
2535
+ "type": "text",
2536
+ "primaryKey": false,
2537
+ "notNull": false
2538
+ },
2539
+ "created_by": {
2540
+ "name": "created_by",
2541
+ "type": "text",
2542
+ "primaryKey": false,
2543
+ "notNull": true
2544
+ },
2545
+ "sent_at": {
2546
+ "name": "sent_at",
2547
+ "type": "timestamp with time zone",
2548
+ "primaryKey": false,
2549
+ "notNull": false
2550
+ },
2551
+ "created_at": {
2552
+ "name": "created_at",
2553
+ "type": "timestamp with time zone",
2554
+ "primaryKey": false,
2555
+ "notNull": true,
2556
+ "default": "now()"
2557
+ },
2558
+ "updated_at": {
2559
+ "name": "updated_at",
2560
+ "type": "timestamp with time zone",
2561
+ "primaryKey": false,
2562
+ "notNull": true,
2563
+ "default": "now()"
2564
+ }
2565
+ },
2566
+ "indexes": {
2567
+ "outbox_pending": {
2568
+ "name": "outbox_pending",
2569
+ "columns": [
2570
+ {
2571
+ "expression": "system",
2572
+ "isExpression": false,
2573
+ "asc": true,
2574
+ "nulls": "last"
2575
+ },
2576
+ {
2577
+ "expression": "state",
2578
+ "isExpression": false,
2579
+ "asc": true,
2580
+ "nulls": "last"
2581
+ },
2582
+ {
2583
+ "expression": "created_at",
2584
+ "isExpression": false,
2585
+ "asc": true,
2586
+ "nulls": "last"
2587
+ }
2588
+ ],
2589
+ "isUnique": false,
2590
+ "concurrently": false,
2591
+ "method": "btree",
2592
+ "with": {}
2593
+ }
2594
+ },
2595
+ "foreignKeys": {
2596
+ "outbox_organisation_id_organisations_id_fk": {
2597
+ "name": "outbox_organisation_id_organisations_id_fk",
2598
+ "tableFrom": "outbox",
2599
+ "tableTo": "organisations",
2600
+ "columnsFrom": [
2601
+ "organisation_id"
2602
+ ],
2603
+ "columnsTo": [
2604
+ "id"
2605
+ ],
2606
+ "onDelete": "no action",
2607
+ "onUpdate": "no action"
2608
+ }
2609
+ },
2610
+ "compositePrimaryKeys": {},
2611
+ "uniqueConstraints": {
2612
+ "outbox_org_id": {
2613
+ "name": "outbox_org_id",
2614
+ "nullsNotDistinct": false,
2615
+ "columns": [
2616
+ "organisation_id",
2617
+ "id"
2618
+ ]
2619
+ },
2620
+ "outbox_idempotency_key": {
2621
+ "name": "outbox_idempotency_key",
2622
+ "nullsNotDistinct": false,
2623
+ "columns": [
2624
+ "idempotency_key"
2625
+ ]
2626
+ }
2627
+ },
2628
+ "policies": {},
2629
+ "checkConstraints": {
2630
+ "outbox_state_valid": {
2631
+ "name": "outbox_state_valid",
2632
+ "value": "state in ('pending', 'sending', 'ambiguous', 'sent', 'failed', 'cancelled')"
2633
+ },
2634
+ "outbox_sent_has_id": {
2635
+ "name": "outbox_sent_has_id",
2636
+ "value": "\"outbox\".\"state\" <> 'sent' or \"outbox\".\"external_id\" is not null"
2637
+ }
2638
+ },
2639
+ "isRLSEnabled": false
2640
+ },
2641
+ "public.people": {
2642
+ "name": "people",
2643
+ "schema": "",
2644
+ "columns": {
2645
+ "id": {
2646
+ "name": "id",
2647
+ "type": "uuid",
2648
+ "primaryKey": true,
2649
+ "notNull": true,
2650
+ "default": "gen_random_uuid()"
2651
+ },
2652
+ "email": {
2653
+ "name": "email",
2654
+ "type": "text",
2655
+ "primaryKey": false,
2656
+ "notNull": true
2657
+ },
2658
+ "name": {
2659
+ "name": "name",
2660
+ "type": "text",
2661
+ "primaryKey": false,
2662
+ "notNull": false
2663
+ },
2664
+ "role": {
2665
+ "name": "role",
2666
+ "type": "text",
2667
+ "primaryKey": false,
2668
+ "notNull": true
2669
+ },
2670
+ "status": {
2671
+ "name": "status",
2672
+ "type": "text",
2673
+ "primaryKey": false,
2674
+ "notNull": true,
2675
+ "default": "'active'"
2676
+ },
2677
+ "clerk_user_id": {
2678
+ "name": "clerk_user_id",
2679
+ "type": "text",
2680
+ "primaryKey": false,
2681
+ "notNull": false
2682
+ },
2683
+ "invited_by": {
2684
+ "name": "invited_by",
2685
+ "type": "uuid",
2686
+ "primaryKey": false,
2687
+ "notNull": false
2688
+ },
2689
+ "linked_at": {
2690
+ "name": "linked_at",
2691
+ "type": "timestamp with time zone",
2692
+ "primaryKey": false,
2693
+ "notNull": false
2694
+ },
2695
+ "appearance": {
2696
+ "name": "appearance",
2697
+ "type": "jsonb",
2698
+ "primaryKey": false,
2699
+ "notNull": false
2700
+ },
2701
+ "created_at": {
2702
+ "name": "created_at",
2703
+ "type": "timestamp with time zone",
2704
+ "primaryKey": false,
2705
+ "notNull": true,
2706
+ "default": "now()"
2707
+ },
2708
+ "updated_at": {
2709
+ "name": "updated_at",
2710
+ "type": "timestamp with time zone",
2711
+ "primaryKey": false,
2712
+ "notNull": true,
2713
+ "default": "now()"
2714
+ }
2715
+ },
2716
+ "indexes": {},
2717
+ "foreignKeys": {
2718
+ "people_invited_by_people_id_fk": {
2719
+ "name": "people_invited_by_people_id_fk",
2720
+ "tableFrom": "people",
2721
+ "tableTo": "people",
2722
+ "columnsFrom": [
2723
+ "invited_by"
2724
+ ],
2725
+ "columnsTo": [
2726
+ "id"
2727
+ ],
2728
+ "onDelete": "set null",
2729
+ "onUpdate": "no action"
2730
+ }
2731
+ },
2732
+ "compositePrimaryKeys": {},
2733
+ "uniqueConstraints": {
2734
+ "people_email": {
2735
+ "name": "people_email",
2736
+ "nullsNotDistinct": false,
2737
+ "columns": [
2738
+ "email"
2739
+ ]
2740
+ },
2741
+ "people_clerk_user_id": {
2742
+ "name": "people_clerk_user_id",
2743
+ "nullsNotDistinct": false,
2744
+ "columns": [
2745
+ "clerk_user_id"
2746
+ ]
2747
+ }
2748
+ },
2749
+ "policies": {},
2750
+ "checkConstraints": {
2751
+ "people_email_lower": {
2752
+ "name": "people_email_lower",
2753
+ "value": "\"people\".\"email\" = lower(\"people\".\"email\")"
2754
+ },
2755
+ "people_role_valid": {
2756
+ "name": "people_role_valid",
2757
+ "value": "\"people\".\"role\" in ('owner', 'admin', 'staff')"
2758
+ },
2759
+ "people_status_valid": {
2760
+ "name": "people_status_valid",
2761
+ "value": "\"people\".\"status\" in ('active', 'pending', 'disabled')"
2762
+ }
2763
+ },
2764
+ "isRLSEnabled": false
2765
+ },
2766
+ "public.pipeline_cursors": {
2767
+ "name": "pipeline_cursors",
2768
+ "schema": "",
2769
+ "columns": {
2770
+ "organisation_id": {
2771
+ "name": "organisation_id",
2772
+ "type": "uuid",
2773
+ "primaryKey": false,
2774
+ "notNull": true
2775
+ },
2776
+ "name": {
2777
+ "name": "name",
2778
+ "type": "text",
2779
+ "primaryKey": false,
2780
+ "notNull": true
2781
+ },
2782
+ "cursor": {
2783
+ "name": "cursor",
2784
+ "type": "text",
2785
+ "primaryKey": false,
2786
+ "notNull": false
2787
+ },
2788
+ "updated_at": {
2789
+ "name": "updated_at",
2790
+ "type": "timestamp with time zone",
2791
+ "primaryKey": false,
2792
+ "notNull": true,
2793
+ "default": "now()"
2794
+ }
2795
+ },
2796
+ "indexes": {},
2797
+ "foreignKeys": {
2798
+ "pipeline_cursors_organisation_id_organisations_id_fk": {
2799
+ "name": "pipeline_cursors_organisation_id_organisations_id_fk",
2800
+ "tableFrom": "pipeline_cursors",
2801
+ "tableTo": "organisations",
2802
+ "columnsFrom": [
2803
+ "organisation_id"
2804
+ ],
2805
+ "columnsTo": [
2806
+ "id"
2807
+ ],
2808
+ "onDelete": "no action",
2809
+ "onUpdate": "no action"
2810
+ }
2811
+ },
2812
+ "compositePrimaryKeys": {
2813
+ "pipeline_cursors_pk": {
2814
+ "name": "pipeline_cursors_pk",
2815
+ "columns": [
2816
+ "organisation_id",
2817
+ "name"
2818
+ ]
2819
+ }
2820
+ },
2821
+ "uniqueConstraints": {},
2822
+ "policies": {},
2823
+ "checkConstraints": {},
2824
+ "isRLSEnabled": false
2825
+ },
2826
+ "public.price_items": {
2827
+ "name": "price_items",
2828
+ "schema": "",
2829
+ "columns": {
2830
+ "id": {
2831
+ "name": "id",
2832
+ "type": "uuid",
2833
+ "primaryKey": true,
2834
+ "notNull": true,
2835
+ "default": "gen_random_uuid()"
2836
+ },
2837
+ "organisation_id": {
2838
+ "name": "organisation_id",
2839
+ "type": "uuid",
2840
+ "primaryKey": false,
2841
+ "notNull": true
2842
+ },
2843
+ "code": {
2844
+ "name": "code",
2845
+ "type": "text",
2846
+ "primaryKey": false,
2847
+ "notNull": true
2848
+ },
2849
+ "name": {
2850
+ "name": "name",
2851
+ "type": "text",
2852
+ "primaryKey": false,
2853
+ "notNull": true
2854
+ },
2855
+ "unit_amount_cents": {
2856
+ "name": "unit_amount_cents",
2857
+ "type": "integer",
2858
+ "primaryKey": false,
2859
+ "notNull": true
2860
+ },
2861
+ "tax_code": {
2862
+ "name": "tax_code",
2863
+ "type": "text",
2864
+ "primaryKey": false,
2865
+ "notNull": true,
2866
+ "default": "'GST'"
2867
+ },
2868
+ "archived_at": {
2869
+ "name": "archived_at",
2870
+ "type": "timestamp with time zone",
2871
+ "primaryKey": false,
2872
+ "notNull": false
2873
+ },
2874
+ "created_at": {
2875
+ "name": "created_at",
2876
+ "type": "timestamp with time zone",
2877
+ "primaryKey": false,
2878
+ "notNull": true,
2879
+ "default": "now()"
2880
+ }
2881
+ },
2882
+ "indexes": {},
2883
+ "foreignKeys": {
2884
+ "price_items_organisation_id_organisations_id_fk": {
2885
+ "name": "price_items_organisation_id_organisations_id_fk",
2886
+ "tableFrom": "price_items",
2887
+ "tableTo": "organisations",
2888
+ "columnsFrom": [
2889
+ "organisation_id"
2890
+ ],
2891
+ "columnsTo": [
2892
+ "id"
2893
+ ],
2894
+ "onDelete": "no action",
2895
+ "onUpdate": "no action"
2896
+ }
2897
+ },
2898
+ "compositePrimaryKeys": {},
2899
+ "uniqueConstraints": {
2900
+ "price_items_org_id": {
2901
+ "name": "price_items_org_id",
2902
+ "nullsNotDistinct": false,
2903
+ "columns": [
2904
+ "organisation_id",
2905
+ "id"
2906
+ ]
2907
+ },
2908
+ "price_items_org_code": {
2909
+ "name": "price_items_org_code",
2910
+ "nullsNotDistinct": false,
2911
+ "columns": [
2912
+ "organisation_id",
2913
+ "code"
2914
+ ]
2915
+ }
2916
+ },
2917
+ "policies": {},
2918
+ "checkConstraints": {
2919
+ "price_items_tax_code_valid": {
2920
+ "name": "price_items_tax_code_valid",
2921
+ "value": "\"price_items\".\"tax_code\" in ('GST', 'GST_FREE')"
2922
+ }
2923
+ },
2924
+ "isRLSEnabled": false
2925
+ },
2926
+ "public.prior_links": {
2927
+ "name": "prior_links",
2928
+ "schema": "",
2929
+ "columns": {
2930
+ "id": {
2931
+ "name": "id",
2932
+ "type": "uuid",
2933
+ "primaryKey": true,
2934
+ "notNull": true,
2935
+ "default": "gen_random_uuid()"
2936
+ },
2937
+ "organisation_id": {
2938
+ "name": "organisation_id",
2939
+ "type": "uuid",
2940
+ "primaryKey": false,
2941
+ "notNull": true
2942
+ },
2943
+ "source_system": {
2944
+ "name": "source_system",
2945
+ "type": "text",
2946
+ "primaryKey": false,
2947
+ "notNull": true
2948
+ },
2949
+ "source_job_ref": {
2950
+ "name": "source_job_ref",
2951
+ "type": "text",
2952
+ "primaryKey": false,
2953
+ "notNull": true
2954
+ },
2955
+ "system": {
2956
+ "name": "system",
2957
+ "type": "text",
2958
+ "primaryKey": false,
2959
+ "notNull": true
2960
+ },
2961
+ "external_id": {
2962
+ "name": "external_id",
2963
+ "type": "text",
2964
+ "primaryKey": false,
2965
+ "notNull": true
2966
+ },
2967
+ "external_number": {
2968
+ "name": "external_number",
2969
+ "type": "text",
2970
+ "primaryKey": false,
2971
+ "notNull": false
2972
+ },
2973
+ "matched_by": {
2974
+ "name": "matched_by",
2975
+ "type": "text",
2976
+ "primaryKey": false,
2977
+ "notNull": true
2978
+ },
2979
+ "matched_at": {
2980
+ "name": "matched_at",
2981
+ "type": "timestamp with time zone",
2982
+ "primaryKey": false,
2983
+ "notNull": false
2984
+ },
2985
+ "origin": {
2986
+ "name": "origin",
2987
+ "type": "text",
2988
+ "primaryKey": false,
2989
+ "notNull": true
2990
+ },
2991
+ "created_at": {
2992
+ "name": "created_at",
2993
+ "type": "timestamp with time zone",
2994
+ "primaryKey": false,
2995
+ "notNull": true,
2996
+ "default": "now()"
2997
+ }
2998
+ },
2999
+ "indexes": {
3000
+ "prior_links_job": {
3001
+ "name": "prior_links_job",
3002
+ "columns": [
3003
+ {
3004
+ "expression": "organisation_id",
3005
+ "isExpression": false,
3006
+ "asc": true,
3007
+ "nulls": "last"
3008
+ },
3009
+ {
3010
+ "expression": "source_system",
3011
+ "isExpression": false,
3012
+ "asc": true,
3013
+ "nulls": "last"
3014
+ },
3015
+ {
3016
+ "expression": "source_job_ref",
3017
+ "isExpression": false,
3018
+ "asc": true,
3019
+ "nulls": "last"
3020
+ },
3021
+ {
3022
+ "expression": "system",
3023
+ "isExpression": false,
3024
+ "asc": true,
3025
+ "nulls": "last"
3026
+ }
3027
+ ],
3028
+ "isUnique": true,
3029
+ "concurrently": false,
3030
+ "method": "btree",
3031
+ "with": {}
3032
+ },
3033
+ "prior_links_external": {
3034
+ "name": "prior_links_external",
3035
+ "columns": [
3036
+ {
3037
+ "expression": "organisation_id",
3038
+ "isExpression": false,
3039
+ "asc": true,
3040
+ "nulls": "last"
3041
+ },
3042
+ {
3043
+ "expression": "system",
3044
+ "isExpression": false,
3045
+ "asc": true,
3046
+ "nulls": "last"
3047
+ },
3048
+ {
3049
+ "expression": "external_id",
3050
+ "isExpression": false,
3051
+ "asc": true,
3052
+ "nulls": "last"
3053
+ }
3054
+ ],
3055
+ "isUnique": false,
3056
+ "concurrently": false,
3057
+ "method": "btree",
3058
+ "with": {}
3059
+ }
3060
+ },
3061
+ "foreignKeys": {
3062
+ "prior_links_organisation_id_organisations_id_fk": {
3063
+ "name": "prior_links_organisation_id_organisations_id_fk",
3064
+ "tableFrom": "prior_links",
3065
+ "tableTo": "organisations",
3066
+ "columnsFrom": [
3067
+ "organisation_id"
3068
+ ],
3069
+ "columnsTo": [
3070
+ "id"
3071
+ ],
3072
+ "onDelete": "no action",
3073
+ "onUpdate": "no action"
3074
+ }
3075
+ },
3076
+ "compositePrimaryKeys": {},
3077
+ "uniqueConstraints": {},
3078
+ "policies": {},
3079
+ "checkConstraints": {
3080
+ "prior_links_matched_by_valid": {
3081
+ "name": "prior_links_matched_by_valid",
3082
+ "value": "matched_by in ('person', 'imported')"
3083
+ }
3084
+ },
3085
+ "isRLSEnabled": false
3086
+ },
3087
+ "public.review_items": {
3088
+ "name": "review_items",
3089
+ "schema": "",
3090
+ "columns": {
3091
+ "id": {
3092
+ "name": "id",
3093
+ "type": "uuid",
3094
+ "primaryKey": true,
3095
+ "notNull": true,
3096
+ "default": "gen_random_uuid()"
3097
+ },
3098
+ "organisation_id": {
3099
+ "name": "organisation_id",
3100
+ "type": "uuid",
3101
+ "primaryKey": false,
3102
+ "notNull": true
3103
+ },
3104
+ "kind": {
3105
+ "name": "kind",
3106
+ "type": "text",
3107
+ "primaryKey": false,
3108
+ "notNull": true
3109
+ },
3110
+ "entity": {
3111
+ "name": "entity",
3112
+ "type": "text",
3113
+ "primaryKey": false,
3114
+ "notNull": true
3115
+ },
3116
+ "flow_id": {
3117
+ "name": "flow_id",
3118
+ "type": "uuid",
3119
+ "primaryKey": false,
3120
+ "notNull": true
3121
+ },
3122
+ "systems": {
3123
+ "name": "systems",
3124
+ "type": "text[]",
3125
+ "primaryKey": false,
3126
+ "notNull": true,
3127
+ "default": "'{}'::text[]"
3128
+ },
3129
+ "evidence": {
3130
+ "name": "evidence",
3131
+ "type": "jsonb",
3132
+ "primaryKey": false,
3133
+ "notNull": true,
3134
+ "default": "'{}'::jsonb"
3135
+ },
3136
+ "money_at_risk_cents": {
3137
+ "name": "money_at_risk_cents",
3138
+ "type": "bigint",
3139
+ "primaryKey": false,
3140
+ "notNull": true,
3141
+ "default": 0
3142
+ },
3143
+ "state": {
3144
+ "name": "state",
3145
+ "type": "text",
3146
+ "primaryKey": false,
3147
+ "notNull": true,
3148
+ "default": "'open'"
3149
+ },
3150
+ "seen_count": {
3151
+ "name": "seen_count",
3152
+ "type": "integer",
3153
+ "primaryKey": false,
3154
+ "notNull": true,
3155
+ "default": 1
3156
+ },
3157
+ "resolution": {
3158
+ "name": "resolution",
3159
+ "type": "text",
3160
+ "primaryKey": false,
3161
+ "notNull": false
3162
+ },
3163
+ "note": {
3164
+ "name": "note",
3165
+ "type": "text",
3166
+ "primaryKey": false,
3167
+ "notNull": false
3168
+ },
3169
+ "resolved_by": {
3170
+ "name": "resolved_by",
3171
+ "type": "text",
3172
+ "primaryKey": false,
3173
+ "notNull": false
3174
+ },
3175
+ "resolved_at": {
3176
+ "name": "resolved_at",
3177
+ "type": "timestamp with time zone",
3178
+ "primaryKey": false,
3179
+ "notNull": false
3180
+ },
3181
+ "created_at": {
3182
+ "name": "created_at",
3183
+ "type": "timestamp with time zone",
3184
+ "primaryKey": false,
3185
+ "notNull": true,
3186
+ "default": "now()"
3187
+ },
3188
+ "updated_at": {
3189
+ "name": "updated_at",
3190
+ "type": "timestamp with time zone",
3191
+ "primaryKey": false,
3192
+ "notNull": true,
3193
+ "default": "now()"
3194
+ }
3195
+ },
3196
+ "indexes": {
3197
+ "review_items_one_open": {
3198
+ "name": "review_items_one_open",
3199
+ "columns": [
3200
+ {
3201
+ "expression": "organisation_id",
3202
+ "isExpression": false,
3203
+ "asc": true,
3204
+ "nulls": "last"
3205
+ },
3206
+ {
3207
+ "expression": "kind",
3208
+ "isExpression": false,
3209
+ "asc": true,
3210
+ "nulls": "last"
3211
+ },
3212
+ {
3213
+ "expression": "entity",
3214
+ "isExpression": false,
3215
+ "asc": true,
3216
+ "nulls": "last"
3217
+ },
3218
+ {
3219
+ "expression": "flow_id",
3220
+ "isExpression": false,
3221
+ "asc": true,
3222
+ "nulls": "last"
3223
+ }
3224
+ ],
3225
+ "isUnique": true,
3226
+ "where": "state = 'open'",
3227
+ "concurrently": false,
3228
+ "method": "btree",
3229
+ "with": {}
3230
+ },
3231
+ "review_items_queue": {
3232
+ "name": "review_items_queue",
3233
+ "columns": [
3234
+ {
3235
+ "expression": "organisation_id",
3236
+ "isExpression": false,
3237
+ "asc": true,
3238
+ "nulls": "last"
3239
+ },
3240
+ {
3241
+ "expression": "state",
3242
+ "isExpression": false,
3243
+ "asc": true,
3244
+ "nulls": "last"
3245
+ },
3246
+ {
3247
+ "expression": "money_at_risk_cents",
3248
+ "isExpression": false,
3249
+ "asc": true,
3250
+ "nulls": "last"
3251
+ }
3252
+ ],
3253
+ "isUnique": false,
3254
+ "concurrently": false,
3255
+ "method": "btree",
3256
+ "with": {}
3257
+ }
3258
+ },
3259
+ "foreignKeys": {
3260
+ "review_items_organisation_id_organisations_id_fk": {
3261
+ "name": "review_items_organisation_id_organisations_id_fk",
3262
+ "tableFrom": "review_items",
3263
+ "tableTo": "organisations",
3264
+ "columnsFrom": [
3265
+ "organisation_id"
3266
+ ],
3267
+ "columnsTo": [
3268
+ "id"
3269
+ ],
3270
+ "onDelete": "no action",
3271
+ "onUpdate": "no action"
3272
+ }
3273
+ },
3274
+ "compositePrimaryKeys": {},
3275
+ "uniqueConstraints": {
3276
+ "review_items_org_id": {
3277
+ "name": "review_items_org_id",
3278
+ "nullsNotDistinct": false,
3279
+ "columns": [
3280
+ "organisation_id",
3281
+ "id"
3282
+ ]
3283
+ }
3284
+ },
3285
+ "policies": {},
3286
+ "checkConstraints": {
3287
+ "review_items_state_valid": {
3288
+ "name": "review_items_state_valid",
3289
+ "value": "state in ('open', 'resolved', 'dismissed')"
3290
+ },
3291
+ "review_items_money_not_negative": {
3292
+ "name": "review_items_money_not_negative",
3293
+ "value": "\"review_items\".\"money_at_risk_cents\" >= 0"
3294
+ },
3295
+ "review_items_closed_has_resolution": {
3296
+ "name": "review_items_closed_has_resolution",
3297
+ "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)"
3298
+ }
3299
+ },
3300
+ "isRLSEnabled": false
3301
+ }
3302
+ },
3303
+ "enums": {},
3304
+ "schemas": {},
3305
+ "sequences": {},
3306
+ "roles": {},
3307
+ "policies": {},
3308
+ "views": {},
3309
+ "_meta": {
3310
+ "columns": {},
3311
+ "schemas": {},
3312
+ "tables": {}
3313
+ }
3314
+ }