@arcforgelabs/flow 2026.10.30 → 2026.10.32

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 (79) hide show
  1. package/README.md +2 -0
  2. package/npm-shrinkwrap.json +188 -2
  3. package/package.json +2 -1
  4. package/server/api/alerts.js +49 -0
  5. package/server/api/invoicing.js +125 -7
  6. package/server/app.js +29 -2
  7. package/server/core/alerts.js +157 -0
  8. package/server/core/automations.js +17 -3
  9. package/server/core/history.js +65 -0
  10. package/server/core/invoice-pdf.js +266 -0
  11. package/server/core/invoices.js +2 -2
  12. package/server/core/invoicing-rules.js +26 -1
  13. package/server/core/job-board.js +25 -3
  14. package/server/core/ledger.js +3 -2
  15. package/server/core/line-mapping.js +36 -10
  16. package/server/core/pipeline.js +76 -4
  17. package/server/core/price-list.js +348 -0
  18. package/server/core/references.js +99 -0
  19. package/server/core/sending.js +11 -5
  20. package/server/db/commands.js +42 -0
  21. package/server/db/doctor.js +168 -0
  22. package/server/db/migrations/0014_price_list.sql +34 -0
  23. package/server/db/migrations/0015_alert_dismissals.sql +17 -0
  24. package/server/db/migrations/0016_invoice_reference.sql +1 -0
  25. package/server/db/migrations/meta/0014_snapshot.json +3773 -0
  26. package/server/db/migrations/meta/0015_snapshot.json +3854 -0
  27. package/server/db/migrations/meta/0016_snapshot.json +3861 -0
  28. package/server/db/migrations/meta/_journal.json +21 -0
  29. package/server/db/schema.js +46 -0
  30. package/server/flow-server.js +20 -1
  31. package/server/index.js +2 -1
  32. package/server/integrations/call-guard.js +362 -0
  33. package/server/integrations/port.js +21 -1
  34. package/server/integrations/seazona/feed.js +31 -2
  35. package/server/integrations/seazona/governor.js +50 -122
  36. package/server/integrations/seazona/history/backfill.js +208 -0
  37. package/server/integrations/seazona/history/csv.js +65 -0
  38. package/server/integrations/seazona/history/index.js +584 -0
  39. package/server/integrations/seazona/history/read.js +196 -0
  40. package/server/integrations/seazona/index.js +46 -1
  41. package/server/integrations/seazona/lanes.js +187 -51
  42. package/server/integrations/seazona/migrations/0003_call_guard.sql +2 -0
  43. package/server/integrations/seazona/migrations/0004_history_import.sql +68 -0
  44. package/server/integrations/seazona/migrations/meta/0003_snapshot.json +895 -0
  45. package/server/integrations/seazona/migrations/meta/0004_snapshot.json +1323 -0
  46. package/server/integrations/seazona/migrations/meta/_journal.json +14 -0
  47. package/server/integrations/seazona/patients.js +30 -0
  48. package/server/integrations/seazona/routes.js +145 -0
  49. package/server/integrations/seazona/schema.js +94 -0
  50. package/server/integrations/seazona/settings.js +14 -3
  51. package/server/integrations/seazona/sync-once.js +1 -1
  52. package/server/integrations/seazona/tables.js +4 -0
  53. package/server/integrations/xero/client.js +39 -7
  54. package/server/integrations/xero/drafts.js +46 -8
  55. package/server/integrations/xero/import.js +131 -17
  56. package/server/integrations/xero/index.js +38 -7
  57. package/server/integrations/xero/lookup.js +26 -0
  58. package/server/integrations/xero/migrations/0006_xero_call_guard.sql +26 -0
  59. package/server/integrations/xero/migrations/0007_xero_webhooks.sql +30 -0
  60. package/server/integrations/xero/migrations/meta/_journal.json +14 -0
  61. package/server/integrations/xero/mirror.js +27 -10
  62. package/server/integrations/xero/oauth.js +4 -1
  63. package/server/integrations/xero/reconcile.js +173 -0
  64. package/server/integrations/xero/routes.js +55 -0
  65. package/server/integrations/xero/runtime.js +45 -4
  66. package/server/integrations/xero/settings.js +3 -0
  67. package/server/integrations/xero/webhooks.js +311 -0
  68. package/server/release-channel.js +3 -3
  69. package/server/ui/alerts.js +77 -0
  70. package/server/ui/app-page.js +1 -1
  71. package/server/ui/app.js +63 -21
  72. package/server/ui/clerk-appearance.js +42 -9
  73. package/server/ui/flow.css +78 -9
  74. package/server/ui/invoice-notes.js +26 -0
  75. package/server/ui/invoicing-settings.js +4 -2
  76. package/server/ui/invoicing.js +241 -49
  77. package/server/ui/line-mappings.js +3 -2
  78. package/server/ui/price-list.js +247 -0
  79. package/server/ui/routes.js +1 -1
@@ -0,0 +1,3773 @@
1
+ {
2
+ "id": "401fc023-725b-4679-a6df-d206a60871e5",
3
+ "prevId": "701a32a9-d9d3-468f-9473-fb28915ddf74",
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
+ "account_code": {
1247
+ "name": "account_code",
1248
+ "type": "text",
1249
+ "primaryKey": false,
1250
+ "notNull": false
1251
+ },
1252
+ "line_amount_cents": {
1253
+ "name": "line_amount_cents",
1254
+ "type": "integer",
1255
+ "primaryKey": false,
1256
+ "notNull": true
1257
+ },
1258
+ "tax_cents": {
1259
+ "name": "tax_cents",
1260
+ "type": "integer",
1261
+ "primaryKey": false,
1262
+ "notNull": true
1263
+ }
1264
+ },
1265
+ "indexes": {},
1266
+ "foreignKeys": {
1267
+ "invoice_lines_invoice_same_org": {
1268
+ "name": "invoice_lines_invoice_same_org",
1269
+ "tableFrom": "invoice_lines",
1270
+ "tableTo": "invoices",
1271
+ "columnsFrom": [
1272
+ "organisation_id",
1273
+ "invoice_id"
1274
+ ],
1275
+ "columnsTo": [
1276
+ "organisation_id",
1277
+ "id"
1278
+ ],
1279
+ "onDelete": "cascade",
1280
+ "onUpdate": "no action"
1281
+ },
1282
+ "invoice_lines_price_item_same_org": {
1283
+ "name": "invoice_lines_price_item_same_org",
1284
+ "tableFrom": "invoice_lines",
1285
+ "tableTo": "price_items",
1286
+ "columnsFrom": [
1287
+ "organisation_id",
1288
+ "price_item_id"
1289
+ ],
1290
+ "columnsTo": [
1291
+ "organisation_id",
1292
+ "id"
1293
+ ],
1294
+ "onDelete": "no action",
1295
+ "onUpdate": "no action"
1296
+ }
1297
+ },
1298
+ "compositePrimaryKeys": {},
1299
+ "uniqueConstraints": {
1300
+ "invoice_lines_invoice_position": {
1301
+ "name": "invoice_lines_invoice_position",
1302
+ "nullsNotDistinct": false,
1303
+ "columns": [
1304
+ "invoice_id",
1305
+ "position"
1306
+ ]
1307
+ }
1308
+ },
1309
+ "policies": {},
1310
+ "checkConstraints": {
1311
+ "invoice_lines_quantity_positive": {
1312
+ "name": "invoice_lines_quantity_positive",
1313
+ "value": "\"invoice_lines\".\"quantity\" > 0"
1314
+ },
1315
+ "invoice_lines_tax_code_valid": {
1316
+ "name": "invoice_lines_tax_code_valid",
1317
+ "value": "\"invoice_lines\".\"tax_code\" in ('GST', 'GST_FREE')"
1318
+ }
1319
+ },
1320
+ "isRLSEnabled": false
1321
+ },
1322
+ "public.invoice_rules": {
1323
+ "name": "invoice_rules",
1324
+ "schema": "",
1325
+ "columns": {
1326
+ "id": {
1327
+ "name": "id",
1328
+ "type": "uuid",
1329
+ "primaryKey": true,
1330
+ "notNull": true,
1331
+ "default": "gen_random_uuid()"
1332
+ },
1333
+ "organisation_id": {
1334
+ "name": "organisation_id",
1335
+ "type": "uuid",
1336
+ "primaryKey": false,
1337
+ "notNull": true
1338
+ },
1339
+ "name": {
1340
+ "name": "name",
1341
+ "type": "text",
1342
+ "primaryKey": false,
1343
+ "notNull": true
1344
+ },
1345
+ "position": {
1346
+ "name": "position",
1347
+ "type": "integer",
1348
+ "primaryKey": false,
1349
+ "notNull": true
1350
+ },
1351
+ "enabled": {
1352
+ "name": "enabled",
1353
+ "type": "boolean",
1354
+ "primaryKey": false,
1355
+ "notNull": true,
1356
+ "default": true
1357
+ },
1358
+ "trigger": {
1359
+ "name": "trigger",
1360
+ "type": "text",
1361
+ "primaryKey": false,
1362
+ "notNull": true,
1363
+ "default": "'job_ready'"
1364
+ },
1365
+ "conditions": {
1366
+ "name": "conditions",
1367
+ "type": "jsonb",
1368
+ "primaryKey": false,
1369
+ "notNull": true,
1370
+ "default": "'[]'::jsonb"
1371
+ },
1372
+ "action": {
1373
+ "name": "action",
1374
+ "type": "jsonb",
1375
+ "primaryKey": false,
1376
+ "notNull": true
1377
+ },
1378
+ "starter_key": {
1379
+ "name": "starter_key",
1380
+ "type": "text",
1381
+ "primaryKey": false,
1382
+ "notNull": false
1383
+ },
1384
+ "updated_by": {
1385
+ "name": "updated_by",
1386
+ "type": "uuid",
1387
+ "primaryKey": false,
1388
+ "notNull": false
1389
+ },
1390
+ "created_at": {
1391
+ "name": "created_at",
1392
+ "type": "timestamp with time zone",
1393
+ "primaryKey": false,
1394
+ "notNull": true,
1395
+ "default": "now()"
1396
+ },
1397
+ "updated_at": {
1398
+ "name": "updated_at",
1399
+ "type": "timestamp with time zone",
1400
+ "primaryKey": false,
1401
+ "notNull": true,
1402
+ "default": "now()"
1403
+ }
1404
+ },
1405
+ "indexes": {
1406
+ "invoice_rules_starter_key": {
1407
+ "name": "invoice_rules_starter_key",
1408
+ "columns": [
1409
+ {
1410
+ "expression": "organisation_id",
1411
+ "isExpression": false,
1412
+ "asc": true,
1413
+ "nulls": "last"
1414
+ },
1415
+ {
1416
+ "expression": "starter_key",
1417
+ "isExpression": false,
1418
+ "asc": true,
1419
+ "nulls": "last"
1420
+ }
1421
+ ],
1422
+ "isUnique": true,
1423
+ "concurrently": false,
1424
+ "method": "btree",
1425
+ "with": {}
1426
+ }
1427
+ },
1428
+ "foreignKeys": {
1429
+ "invoice_rules_organisation_id_organisations_id_fk": {
1430
+ "name": "invoice_rules_organisation_id_organisations_id_fk",
1431
+ "tableFrom": "invoice_rules",
1432
+ "tableTo": "organisations",
1433
+ "columnsFrom": [
1434
+ "organisation_id"
1435
+ ],
1436
+ "columnsTo": [
1437
+ "id"
1438
+ ],
1439
+ "onDelete": "no action",
1440
+ "onUpdate": "no action"
1441
+ },
1442
+ "invoice_rules_updated_by_people_id_fk": {
1443
+ "name": "invoice_rules_updated_by_people_id_fk",
1444
+ "tableFrom": "invoice_rules",
1445
+ "tableTo": "people",
1446
+ "columnsFrom": [
1447
+ "updated_by"
1448
+ ],
1449
+ "columnsTo": [
1450
+ "id"
1451
+ ],
1452
+ "onDelete": "set null",
1453
+ "onUpdate": "no action"
1454
+ }
1455
+ },
1456
+ "compositePrimaryKeys": {},
1457
+ "uniqueConstraints": {},
1458
+ "policies": {},
1459
+ "checkConstraints": {
1460
+ "invoice_rules_trigger_valid": {
1461
+ "name": "invoice_rules_trigger_valid",
1462
+ "value": "\"invoice_rules\".\"trigger\" in ('job_ready')"
1463
+ },
1464
+ "invoice_rules_name_valid": {
1465
+ "name": "invoice_rules_name_valid",
1466
+ "value": "length(\"invoice_rules\".\"name\") between 1 and 120"
1467
+ }
1468
+ },
1469
+ "isRLSEnabled": false
1470
+ },
1471
+ "public.invoice_versions": {
1472
+ "name": "invoice_versions",
1473
+ "schema": "",
1474
+ "columns": {
1475
+ "id": {
1476
+ "name": "id",
1477
+ "type": "uuid",
1478
+ "primaryKey": true,
1479
+ "notNull": true,
1480
+ "default": "gen_random_uuid()"
1481
+ },
1482
+ "organisation_id": {
1483
+ "name": "organisation_id",
1484
+ "type": "uuid",
1485
+ "primaryKey": false,
1486
+ "notNull": true
1487
+ },
1488
+ "invoice_id": {
1489
+ "name": "invoice_id",
1490
+ "type": "uuid",
1491
+ "primaryKey": false,
1492
+ "notNull": true
1493
+ },
1494
+ "version": {
1495
+ "name": "version",
1496
+ "type": "integer",
1497
+ "primaryKey": false,
1498
+ "notNull": true
1499
+ },
1500
+ "issued_at": {
1501
+ "name": "issued_at",
1502
+ "type": "timestamp with time zone",
1503
+ "primaryKey": false,
1504
+ "notNull": true,
1505
+ "default": "now()"
1506
+ },
1507
+ "issued_by": {
1508
+ "name": "issued_by",
1509
+ "type": "text",
1510
+ "primaryKey": false,
1511
+ "notNull": true
1512
+ },
1513
+ "document": {
1514
+ "name": "document",
1515
+ "type": "jsonb",
1516
+ "primaryKey": false,
1517
+ "notNull": true
1518
+ }
1519
+ },
1520
+ "indexes": {},
1521
+ "foreignKeys": {
1522
+ "invoice_versions_invoice_same_org": {
1523
+ "name": "invoice_versions_invoice_same_org",
1524
+ "tableFrom": "invoice_versions",
1525
+ "tableTo": "invoices",
1526
+ "columnsFrom": [
1527
+ "organisation_id",
1528
+ "invoice_id"
1529
+ ],
1530
+ "columnsTo": [
1531
+ "organisation_id",
1532
+ "id"
1533
+ ],
1534
+ "onDelete": "no action",
1535
+ "onUpdate": "no action"
1536
+ }
1537
+ },
1538
+ "compositePrimaryKeys": {},
1539
+ "uniqueConstraints": {
1540
+ "invoice_versions_invoice_version": {
1541
+ "name": "invoice_versions_invoice_version",
1542
+ "nullsNotDistinct": false,
1543
+ "columns": [
1544
+ "invoice_id",
1545
+ "version"
1546
+ ]
1547
+ }
1548
+ },
1549
+ "policies": {},
1550
+ "checkConstraints": {
1551
+ "invoice_versions_version_positive": {
1552
+ "name": "invoice_versions_version_positive",
1553
+ "value": "\"invoice_versions\".\"version\" > 0"
1554
+ }
1555
+ },
1556
+ "isRLSEnabled": false
1557
+ },
1558
+ "public.invoices": {
1559
+ "name": "invoices",
1560
+ "schema": "",
1561
+ "columns": {
1562
+ "id": {
1563
+ "name": "id",
1564
+ "type": "uuid",
1565
+ "primaryKey": true,
1566
+ "notNull": true,
1567
+ "default": "gen_random_uuid()"
1568
+ },
1569
+ "organisation_id": {
1570
+ "name": "organisation_id",
1571
+ "type": "uuid",
1572
+ "primaryKey": false,
1573
+ "notNull": true
1574
+ },
1575
+ "contact_id": {
1576
+ "name": "contact_id",
1577
+ "type": "uuid",
1578
+ "primaryKey": false,
1579
+ "notNull": true
1580
+ },
1581
+ "number": {
1582
+ "name": "number",
1583
+ "type": "text",
1584
+ "primaryKey": false,
1585
+ "notNull": false
1586
+ },
1587
+ "status": {
1588
+ "name": "status",
1589
+ "type": "text",
1590
+ "primaryKey": false,
1591
+ "notNull": true,
1592
+ "default": "'draft'"
1593
+ },
1594
+ "issued_version": {
1595
+ "name": "issued_version",
1596
+ "type": "integer",
1597
+ "primaryKey": false,
1598
+ "notNull": true,
1599
+ "default": 0
1600
+ },
1601
+ "reference": {
1602
+ "name": "reference",
1603
+ "type": "text",
1604
+ "primaryKey": false,
1605
+ "notNull": false
1606
+ },
1607
+ "currency": {
1608
+ "name": "currency",
1609
+ "type": "text",
1610
+ "primaryKey": false,
1611
+ "notNull": true,
1612
+ "default": "'AUD'"
1613
+ },
1614
+ "issue_date": {
1615
+ "name": "issue_date",
1616
+ "type": "date",
1617
+ "primaryKey": false,
1618
+ "notNull": false
1619
+ },
1620
+ "due_date": {
1621
+ "name": "due_date",
1622
+ "type": "date",
1623
+ "primaryKey": false,
1624
+ "notNull": false
1625
+ },
1626
+ "subtotal_cents": {
1627
+ "name": "subtotal_cents",
1628
+ "type": "integer",
1629
+ "primaryKey": false,
1630
+ "notNull": true,
1631
+ "default": 0
1632
+ },
1633
+ "tax_cents": {
1634
+ "name": "tax_cents",
1635
+ "type": "integer",
1636
+ "primaryKey": false,
1637
+ "notNull": true,
1638
+ "default": 0
1639
+ },
1640
+ "total_cents": {
1641
+ "name": "total_cents",
1642
+ "type": "integer",
1643
+ "primaryKey": false,
1644
+ "notNull": true,
1645
+ "default": 0
1646
+ },
1647
+ "ready_at": {
1648
+ "name": "ready_at",
1649
+ "type": "timestamp with time zone",
1650
+ "primaryKey": false,
1651
+ "notNull": false
1652
+ },
1653
+ "ready_by": {
1654
+ "name": "ready_by",
1655
+ "type": "uuid",
1656
+ "primaryKey": false,
1657
+ "notNull": false
1658
+ },
1659
+ "send_state": {
1660
+ "name": "send_state",
1661
+ "type": "text",
1662
+ "primaryKey": false,
1663
+ "notNull": false
1664
+ },
1665
+ "send_error": {
1666
+ "name": "send_error",
1667
+ "type": "jsonb",
1668
+ "primaryKey": false,
1669
+ "notNull": false
1670
+ },
1671
+ "send_requested_by": {
1672
+ "name": "send_requested_by",
1673
+ "type": "uuid",
1674
+ "primaryKey": false,
1675
+ "notNull": false
1676
+ },
1677
+ "send_updated_at": {
1678
+ "name": "send_updated_at",
1679
+ "type": "timestamp with time zone",
1680
+ "primaryKey": false,
1681
+ "notNull": false
1682
+ },
1683
+ "created_at": {
1684
+ "name": "created_at",
1685
+ "type": "timestamp with time zone",
1686
+ "primaryKey": false,
1687
+ "notNull": true,
1688
+ "default": "now()"
1689
+ },
1690
+ "updated_at": {
1691
+ "name": "updated_at",
1692
+ "type": "timestamp with time zone",
1693
+ "primaryKey": false,
1694
+ "notNull": true,
1695
+ "default": "now()"
1696
+ }
1697
+ },
1698
+ "indexes": {},
1699
+ "foreignKeys": {
1700
+ "invoices_organisation_id_organisations_id_fk": {
1701
+ "name": "invoices_organisation_id_organisations_id_fk",
1702
+ "tableFrom": "invoices",
1703
+ "tableTo": "organisations",
1704
+ "columnsFrom": [
1705
+ "organisation_id"
1706
+ ],
1707
+ "columnsTo": [
1708
+ "id"
1709
+ ],
1710
+ "onDelete": "no action",
1711
+ "onUpdate": "no action"
1712
+ },
1713
+ "invoices_ready_by_people_id_fk": {
1714
+ "name": "invoices_ready_by_people_id_fk",
1715
+ "tableFrom": "invoices",
1716
+ "tableTo": "people",
1717
+ "columnsFrom": [
1718
+ "ready_by"
1719
+ ],
1720
+ "columnsTo": [
1721
+ "id"
1722
+ ],
1723
+ "onDelete": "set null",
1724
+ "onUpdate": "no action"
1725
+ },
1726
+ "invoices_send_requested_by_people_id_fk": {
1727
+ "name": "invoices_send_requested_by_people_id_fk",
1728
+ "tableFrom": "invoices",
1729
+ "tableTo": "people",
1730
+ "columnsFrom": [
1731
+ "send_requested_by"
1732
+ ],
1733
+ "columnsTo": [
1734
+ "id"
1735
+ ],
1736
+ "onDelete": "set null",
1737
+ "onUpdate": "no action"
1738
+ },
1739
+ "invoices_contact_same_org": {
1740
+ "name": "invoices_contact_same_org",
1741
+ "tableFrom": "invoices",
1742
+ "tableTo": "contacts",
1743
+ "columnsFrom": [
1744
+ "organisation_id",
1745
+ "contact_id"
1746
+ ],
1747
+ "columnsTo": [
1748
+ "organisation_id",
1749
+ "id"
1750
+ ],
1751
+ "onDelete": "no action",
1752
+ "onUpdate": "no action"
1753
+ }
1754
+ },
1755
+ "compositePrimaryKeys": {},
1756
+ "uniqueConstraints": {
1757
+ "invoices_org_id": {
1758
+ "name": "invoices_org_id",
1759
+ "nullsNotDistinct": false,
1760
+ "columns": [
1761
+ "organisation_id",
1762
+ "id"
1763
+ ]
1764
+ },
1765
+ "invoices_org_number": {
1766
+ "name": "invoices_org_number",
1767
+ "nullsNotDistinct": false,
1768
+ "columns": [
1769
+ "organisation_id",
1770
+ "number"
1771
+ ]
1772
+ }
1773
+ },
1774
+ "policies": {},
1775
+ "checkConstraints": {
1776
+ "invoices_status_valid": {
1777
+ "name": "invoices_status_valid",
1778
+ "value": "\"invoices\".\"status\" in ('draft', 'issued', 'void')"
1779
+ },
1780
+ "invoices_issued_has_number": {
1781
+ "name": "invoices_issued_has_number",
1782
+ "value": "\"invoices\".\"status\" = 'draft' or \"invoices\".\"number\" is not null"
1783
+ },
1784
+ "invoices_send_state_valid": {
1785
+ "name": "invoices_send_state_valid",
1786
+ "value": "\"invoices\".\"send_state\" is null or \"invoices\".\"send_state\" in ('queued', 'sent', 'failed')"
1787
+ }
1788
+ },
1789
+ "isRLSEnabled": false
1790
+ },
1791
+ "public.invoicing_settings": {
1792
+ "name": "invoicing_settings",
1793
+ "schema": "",
1794
+ "columns": {
1795
+ "organisation_id": {
1796
+ "name": "organisation_id",
1797
+ "type": "uuid",
1798
+ "primaryKey": true,
1799
+ "notNull": true
1800
+ },
1801
+ "send_mode": {
1802
+ "name": "send_mode",
1803
+ "type": "text",
1804
+ "primaryKey": false,
1805
+ "notNull": true,
1806
+ "default": "'accounting_draft'"
1807
+ },
1808
+ "stale_days": {
1809
+ "name": "stale_days",
1810
+ "type": "integer",
1811
+ "primaryKey": false,
1812
+ "notNull": true,
1813
+ "default": 90
1814
+ },
1815
+ "payment_terms_days": {
1816
+ "name": "payment_terms_days",
1817
+ "type": "integer",
1818
+ "primaryKey": false,
1819
+ "notNull": true,
1820
+ "default": 30
1821
+ },
1822
+ "require_practitioner": {
1823
+ "name": "require_practitioner",
1824
+ "type": "boolean",
1825
+ "primaryKey": false,
1826
+ "notNull": true,
1827
+ "default": false
1828
+ },
1829
+ "rush_item_code": {
1830
+ "name": "rush_item_code",
1831
+ "type": "text",
1832
+ "primaryKey": false,
1833
+ "notNull": false
1834
+ },
1835
+ "rush_percent": {
1836
+ "name": "rush_percent",
1837
+ "type": "integer",
1838
+ "primaryKey": false,
1839
+ "notNull": true,
1840
+ "default": 20
1841
+ },
1842
+ "rules_seeded": {
1843
+ "name": "rules_seeded",
1844
+ "type": "boolean",
1845
+ "primaryKey": false,
1846
+ "notNull": true,
1847
+ "default": false
1848
+ },
1849
+ "updated_by": {
1850
+ "name": "updated_by",
1851
+ "type": "uuid",
1852
+ "primaryKey": false,
1853
+ "notNull": false
1854
+ },
1855
+ "updated_at": {
1856
+ "name": "updated_at",
1857
+ "type": "timestamp with time zone",
1858
+ "primaryKey": false,
1859
+ "notNull": true,
1860
+ "default": "now()"
1861
+ }
1862
+ },
1863
+ "indexes": {},
1864
+ "foreignKeys": {
1865
+ "invoicing_settings_organisation_id_organisations_id_fk": {
1866
+ "name": "invoicing_settings_organisation_id_organisations_id_fk",
1867
+ "tableFrom": "invoicing_settings",
1868
+ "tableTo": "organisations",
1869
+ "columnsFrom": [
1870
+ "organisation_id"
1871
+ ],
1872
+ "columnsTo": [
1873
+ "id"
1874
+ ],
1875
+ "onDelete": "no action",
1876
+ "onUpdate": "no action"
1877
+ },
1878
+ "invoicing_settings_updated_by_people_id_fk": {
1879
+ "name": "invoicing_settings_updated_by_people_id_fk",
1880
+ "tableFrom": "invoicing_settings",
1881
+ "tableTo": "people",
1882
+ "columnsFrom": [
1883
+ "updated_by"
1884
+ ],
1885
+ "columnsTo": [
1886
+ "id"
1887
+ ],
1888
+ "onDelete": "set null",
1889
+ "onUpdate": "no action"
1890
+ }
1891
+ },
1892
+ "compositePrimaryKeys": {},
1893
+ "uniqueConstraints": {},
1894
+ "policies": {},
1895
+ "checkConstraints": {
1896
+ "invoicing_settings_send_mode_valid": {
1897
+ "name": "invoicing_settings_send_mode_valid",
1898
+ "value": "send_mode in ('accounting_draft', 'approve_and_email')"
1899
+ },
1900
+ "invoicing_settings_stale_days_valid": {
1901
+ "name": "invoicing_settings_stale_days_valid",
1902
+ "value": "\"invoicing_settings\".\"stale_days\" between 1 and 3650"
1903
+ },
1904
+ "invoicing_settings_terms_valid": {
1905
+ "name": "invoicing_settings_terms_valid",
1906
+ "value": "\"invoicing_settings\".\"payment_terms_days\" between 0 and 365"
1907
+ },
1908
+ "invoicing_settings_rush_valid": {
1909
+ "name": "invoicing_settings_rush_valid",
1910
+ "value": "\"invoicing_settings\".\"rush_percent\" between 0 and 100"
1911
+ }
1912
+ },
1913
+ "isRLSEnabled": false
1914
+ },
1915
+ "public.line_mappings": {
1916
+ "name": "line_mappings",
1917
+ "schema": "",
1918
+ "columns": {
1919
+ "id": {
1920
+ "name": "id",
1921
+ "type": "uuid",
1922
+ "primaryKey": true,
1923
+ "notNull": true,
1924
+ "default": "gen_random_uuid()"
1925
+ },
1926
+ "organisation_id": {
1927
+ "name": "organisation_id",
1928
+ "type": "uuid",
1929
+ "primaryKey": false,
1930
+ "notNull": true
1931
+ },
1932
+ "kind": {
1933
+ "name": "kind",
1934
+ "type": "text",
1935
+ "primaryKey": false,
1936
+ "notNull": true
1937
+ },
1938
+ "match": {
1939
+ "name": "match",
1940
+ "type": "text",
1941
+ "primaryKey": false,
1942
+ "notNull": true,
1943
+ "default": "'exact'"
1944
+ },
1945
+ "label": {
1946
+ "name": "label",
1947
+ "type": "text",
1948
+ "primaryKey": false,
1949
+ "notNull": true
1950
+ },
1951
+ "unit_amount_cents": {
1952
+ "name": "unit_amount_cents",
1953
+ "type": "integer",
1954
+ "primaryKey": false,
1955
+ "notNull": false
1956
+ },
1957
+ "item_code": {
1958
+ "name": "item_code",
1959
+ "type": "text",
1960
+ "primaryKey": false,
1961
+ "notNull": false
1962
+ },
1963
+ "account_code": {
1964
+ "name": "account_code",
1965
+ "type": "text",
1966
+ "primaryKey": false,
1967
+ "notNull": false
1968
+ },
1969
+ "tax_code": {
1970
+ "name": "tax_code",
1971
+ "type": "text",
1972
+ "primaryKey": false,
1973
+ "notNull": false
1974
+ },
1975
+ "description": {
1976
+ "name": "description",
1977
+ "type": "text",
1978
+ "primaryKey": false,
1979
+ "notNull": false
1980
+ },
1981
+ "enabled": {
1982
+ "name": "enabled",
1983
+ "type": "boolean",
1984
+ "primaryKey": false,
1985
+ "notNull": true,
1986
+ "default": true
1987
+ },
1988
+ "origin": {
1989
+ "name": "origin",
1990
+ "type": "text",
1991
+ "primaryKey": false,
1992
+ "notNull": true,
1993
+ "default": "'person'"
1994
+ },
1995
+ "updated_by": {
1996
+ "name": "updated_by",
1997
+ "type": "uuid",
1998
+ "primaryKey": false,
1999
+ "notNull": false
2000
+ },
2001
+ "created_at": {
2002
+ "name": "created_at",
2003
+ "type": "timestamp with time zone",
2004
+ "primaryKey": false,
2005
+ "notNull": true,
2006
+ "default": "now()"
2007
+ },
2008
+ "updated_at": {
2009
+ "name": "updated_at",
2010
+ "type": "timestamp with time zone",
2011
+ "primaryKey": false,
2012
+ "notNull": true,
2013
+ "default": "now()"
2014
+ }
2015
+ },
2016
+ "indexes": {
2017
+ "line_mappings_unique": {
2018
+ "name": "line_mappings_unique",
2019
+ "columns": [
2020
+ {
2021
+ "expression": "organisation_id",
2022
+ "isExpression": false,
2023
+ "asc": true,
2024
+ "nulls": "last"
2025
+ },
2026
+ {
2027
+ "expression": "kind",
2028
+ "isExpression": false,
2029
+ "asc": true,
2030
+ "nulls": "last"
2031
+ },
2032
+ {
2033
+ "expression": "match",
2034
+ "isExpression": false,
2035
+ "asc": true,
2036
+ "nulls": "last"
2037
+ },
2038
+ {
2039
+ "expression": "label",
2040
+ "isExpression": false,
2041
+ "asc": true,
2042
+ "nulls": "last"
2043
+ },
2044
+ {
2045
+ "expression": "coalesce(\"unit_amount_cents\", -1)",
2046
+ "asc": true,
2047
+ "isExpression": true,
2048
+ "nulls": "last"
2049
+ }
2050
+ ],
2051
+ "isUnique": true,
2052
+ "concurrently": false,
2053
+ "method": "btree",
2054
+ "with": {}
2055
+ }
2056
+ },
2057
+ "foreignKeys": {
2058
+ "line_mappings_organisation_id_organisations_id_fk": {
2059
+ "name": "line_mappings_organisation_id_organisations_id_fk",
2060
+ "tableFrom": "line_mappings",
2061
+ "tableTo": "organisations",
2062
+ "columnsFrom": [
2063
+ "organisation_id"
2064
+ ],
2065
+ "columnsTo": [
2066
+ "id"
2067
+ ],
2068
+ "onDelete": "no action",
2069
+ "onUpdate": "no action"
2070
+ },
2071
+ "line_mappings_updated_by_people_id_fk": {
2072
+ "name": "line_mappings_updated_by_people_id_fk",
2073
+ "tableFrom": "line_mappings",
2074
+ "tableTo": "people",
2075
+ "columnsFrom": [
2076
+ "updated_by"
2077
+ ],
2078
+ "columnsTo": [
2079
+ "id"
2080
+ ],
2081
+ "onDelete": "set null",
2082
+ "onUpdate": "no action"
2083
+ }
2084
+ },
2085
+ "compositePrimaryKeys": {},
2086
+ "uniqueConstraints": {},
2087
+ "policies": {},
2088
+ "checkConstraints": {
2089
+ "line_mappings_kind_valid": {
2090
+ "name": "line_mappings_kind_valid",
2091
+ "value": "\"line_mappings\".\"kind\" in ('alias', 'price_alias', 'saved', 'account')"
2092
+ },
2093
+ "line_mappings_match_valid": {
2094
+ "name": "line_mappings_match_valid",
2095
+ "value": "\"line_mappings\".\"match\" in ('exact', 'starts_with')"
2096
+ },
2097
+ "line_mappings_tax_code_valid": {
2098
+ "name": "line_mappings_tax_code_valid",
2099
+ "value": "\"line_mappings\".\"tax_code\" is null or \"line_mappings\".\"tax_code\" in ('GST', 'GST_FREE')"
2100
+ },
2101
+ "line_mappings_target": {
2102
+ "name": "line_mappings_target",
2103
+ "value": "(\"line_mappings\".\"kind\" = 'account' and \"line_mappings\".\"account_code\" is not null) or (\"line_mappings\".\"kind\" <> 'account' and \"line_mappings\".\"item_code\" is not null)"
2104
+ },
2105
+ "line_mappings_price": {
2106
+ "name": "line_mappings_price",
2107
+ "value": "\"line_mappings\".\"kind\" not in ('price_alias', 'saved') or \"line_mappings\".\"unit_amount_cents\" is not null"
2108
+ },
2109
+ "line_mappings_label_valid": {
2110
+ "name": "line_mappings_label_valid",
2111
+ "value": "length(\"line_mappings\".\"label\") between 1 and 200"
2112
+ }
2113
+ },
2114
+ "isRLSEnabled": false
2115
+ },
2116
+ "public.link_rejections": {
2117
+ "name": "link_rejections",
2118
+ "schema": "",
2119
+ "columns": {
2120
+ "organisation_id": {
2121
+ "name": "organisation_id",
2122
+ "type": "uuid",
2123
+ "primaryKey": false,
2124
+ "notNull": true
2125
+ },
2126
+ "obligation_id": {
2127
+ "name": "obligation_id",
2128
+ "type": "uuid",
2129
+ "primaryKey": false,
2130
+ "notNull": true
2131
+ },
2132
+ "system": {
2133
+ "name": "system",
2134
+ "type": "text",
2135
+ "primaryKey": false,
2136
+ "notNull": true
2137
+ },
2138
+ "external_id": {
2139
+ "name": "external_id",
2140
+ "type": "text",
2141
+ "primaryKey": false,
2142
+ "notNull": true
2143
+ },
2144
+ "actor": {
2145
+ "name": "actor",
2146
+ "type": "text",
2147
+ "primaryKey": false,
2148
+ "notNull": true
2149
+ },
2150
+ "created_at": {
2151
+ "name": "created_at",
2152
+ "type": "timestamp with time zone",
2153
+ "primaryKey": false,
2154
+ "notNull": true,
2155
+ "default": "now()"
2156
+ }
2157
+ },
2158
+ "indexes": {},
2159
+ "foreignKeys": {
2160
+ "link_rejections_organisation_id_organisations_id_fk": {
2161
+ "name": "link_rejections_organisation_id_organisations_id_fk",
2162
+ "tableFrom": "link_rejections",
2163
+ "tableTo": "organisations",
2164
+ "columnsFrom": [
2165
+ "organisation_id"
2166
+ ],
2167
+ "columnsTo": [
2168
+ "id"
2169
+ ],
2170
+ "onDelete": "no action",
2171
+ "onUpdate": "no action"
2172
+ },
2173
+ "link_rejections_obligation_same_org": {
2174
+ "name": "link_rejections_obligation_same_org",
2175
+ "tableFrom": "link_rejections",
2176
+ "tableTo": "billing_obligations",
2177
+ "columnsFrom": [
2178
+ "organisation_id",
2179
+ "obligation_id"
2180
+ ],
2181
+ "columnsTo": [
2182
+ "organisation_id",
2183
+ "id"
2184
+ ],
2185
+ "onDelete": "no action",
2186
+ "onUpdate": "no action"
2187
+ }
2188
+ },
2189
+ "compositePrimaryKeys": {
2190
+ "link_rejections_pk": {
2191
+ "name": "link_rejections_pk",
2192
+ "columns": [
2193
+ "organisation_id",
2194
+ "obligation_id",
2195
+ "system",
2196
+ "external_id"
2197
+ ]
2198
+ }
2199
+ },
2200
+ "uniqueConstraints": {},
2201
+ "policies": {},
2202
+ "checkConstraints": {},
2203
+ "isRLSEnabled": false
2204
+ },
2205
+ "public.link_suggestions": {
2206
+ "name": "link_suggestions",
2207
+ "schema": "",
2208
+ "columns": {
2209
+ "id": {
2210
+ "name": "id",
2211
+ "type": "uuid",
2212
+ "primaryKey": true,
2213
+ "notNull": true,
2214
+ "default": "gen_random_uuid()"
2215
+ },
2216
+ "organisation_id": {
2217
+ "name": "organisation_id",
2218
+ "type": "uuid",
2219
+ "primaryKey": false,
2220
+ "notNull": true
2221
+ },
2222
+ "obligation_id": {
2223
+ "name": "obligation_id",
2224
+ "type": "uuid",
2225
+ "primaryKey": false,
2226
+ "notNull": true
2227
+ },
2228
+ "system": {
2229
+ "name": "system",
2230
+ "type": "text",
2231
+ "primaryKey": false,
2232
+ "notNull": true
2233
+ },
2234
+ "external_id": {
2235
+ "name": "external_id",
2236
+ "type": "text",
2237
+ "primaryKey": false,
2238
+ "notNull": true
2239
+ },
2240
+ "external_number": {
2241
+ "name": "external_number",
2242
+ "type": "text",
2243
+ "primaryKey": false,
2244
+ "notNull": false
2245
+ },
2246
+ "score": {
2247
+ "name": "score",
2248
+ "type": "integer",
2249
+ "primaryKey": false,
2250
+ "notNull": true
2251
+ },
2252
+ "rank": {
2253
+ "name": "rank",
2254
+ "type": "integer",
2255
+ "primaryKey": false,
2256
+ "notNull": true
2257
+ },
2258
+ "signals": {
2259
+ "name": "signals",
2260
+ "type": "jsonb",
2261
+ "primaryKey": false,
2262
+ "notNull": true,
2263
+ "default": "'[]'::jsonb"
2264
+ },
2265
+ "state": {
2266
+ "name": "state",
2267
+ "type": "text",
2268
+ "primaryKey": false,
2269
+ "notNull": true,
2270
+ "default": "'open'"
2271
+ },
2272
+ "decided_by": {
2273
+ "name": "decided_by",
2274
+ "type": "text",
2275
+ "primaryKey": false,
2276
+ "notNull": false
2277
+ },
2278
+ "decided_at": {
2279
+ "name": "decided_at",
2280
+ "type": "timestamp with time zone",
2281
+ "primaryKey": false,
2282
+ "notNull": false
2283
+ },
2284
+ "created_at": {
2285
+ "name": "created_at",
2286
+ "type": "timestamp with time zone",
2287
+ "primaryKey": false,
2288
+ "notNull": true,
2289
+ "default": "now()"
2290
+ },
2291
+ "updated_at": {
2292
+ "name": "updated_at",
2293
+ "type": "timestamp with time zone",
2294
+ "primaryKey": false,
2295
+ "notNull": true,
2296
+ "default": "now()"
2297
+ }
2298
+ },
2299
+ "indexes": {
2300
+ "link_suggestions_open": {
2301
+ "name": "link_suggestions_open",
2302
+ "columns": [
2303
+ {
2304
+ "expression": "organisation_id",
2305
+ "isExpression": false,
2306
+ "asc": true,
2307
+ "nulls": "last"
2308
+ },
2309
+ {
2310
+ "expression": "state",
2311
+ "isExpression": false,
2312
+ "asc": true,
2313
+ "nulls": "last"
2314
+ },
2315
+ {
2316
+ "expression": "obligation_id",
2317
+ "isExpression": false,
2318
+ "asc": true,
2319
+ "nulls": "last"
2320
+ }
2321
+ ],
2322
+ "isUnique": false,
2323
+ "concurrently": false,
2324
+ "method": "btree",
2325
+ "with": {}
2326
+ }
2327
+ },
2328
+ "foreignKeys": {
2329
+ "link_suggestions_organisation_id_organisations_id_fk": {
2330
+ "name": "link_suggestions_organisation_id_organisations_id_fk",
2331
+ "tableFrom": "link_suggestions",
2332
+ "tableTo": "organisations",
2333
+ "columnsFrom": [
2334
+ "organisation_id"
2335
+ ],
2336
+ "columnsTo": [
2337
+ "id"
2338
+ ],
2339
+ "onDelete": "no action",
2340
+ "onUpdate": "no action"
2341
+ },
2342
+ "link_suggestions_obligation_same_org": {
2343
+ "name": "link_suggestions_obligation_same_org",
2344
+ "tableFrom": "link_suggestions",
2345
+ "tableTo": "billing_obligations",
2346
+ "columnsFrom": [
2347
+ "organisation_id",
2348
+ "obligation_id"
2349
+ ],
2350
+ "columnsTo": [
2351
+ "organisation_id",
2352
+ "id"
2353
+ ],
2354
+ "onDelete": "no action",
2355
+ "onUpdate": "no action"
2356
+ }
2357
+ },
2358
+ "compositePrimaryKeys": {},
2359
+ "uniqueConstraints": {
2360
+ "link_suggestions_pair": {
2361
+ "name": "link_suggestions_pair",
2362
+ "nullsNotDistinct": false,
2363
+ "columns": [
2364
+ "organisation_id",
2365
+ "obligation_id",
2366
+ "system",
2367
+ "external_id"
2368
+ ]
2369
+ }
2370
+ },
2371
+ "policies": {},
2372
+ "checkConstraints": {
2373
+ "link_suggestions_state_valid": {
2374
+ "name": "link_suggestions_state_valid",
2375
+ "value": "state in ('open', 'accepted', 'rejected', 'stale')"
2376
+ }
2377
+ },
2378
+ "isRLSEnabled": false
2379
+ },
2380
+ "public.obligation_events": {
2381
+ "name": "obligation_events",
2382
+ "schema": "",
2383
+ "columns": {
2384
+ "id": {
2385
+ "name": "id",
2386
+ "type": "uuid",
2387
+ "primaryKey": true,
2388
+ "notNull": true,
2389
+ "default": "gen_random_uuid()"
2390
+ },
2391
+ "organisation_id": {
2392
+ "name": "organisation_id",
2393
+ "type": "uuid",
2394
+ "primaryKey": false,
2395
+ "notNull": true
2396
+ },
2397
+ "obligation_id": {
2398
+ "name": "obligation_id",
2399
+ "type": "uuid",
2400
+ "primaryKey": false,
2401
+ "notNull": true
2402
+ },
2403
+ "kind": {
2404
+ "name": "kind",
2405
+ "type": "text",
2406
+ "primaryKey": false,
2407
+ "notNull": true
2408
+ },
2409
+ "actor": {
2410
+ "name": "actor",
2411
+ "type": "text",
2412
+ "primaryKey": false,
2413
+ "notNull": true
2414
+ },
2415
+ "evidence": {
2416
+ "name": "evidence",
2417
+ "type": "jsonb",
2418
+ "primaryKey": false,
2419
+ "notNull": true,
2420
+ "default": "'{}'::jsonb"
2421
+ },
2422
+ "created_at": {
2423
+ "name": "created_at",
2424
+ "type": "timestamp with time zone",
2425
+ "primaryKey": false,
2426
+ "notNull": true,
2427
+ "default": "now()"
2428
+ }
2429
+ },
2430
+ "indexes": {},
2431
+ "foreignKeys": {
2432
+ "obligation_events_obligation_same_org": {
2433
+ "name": "obligation_events_obligation_same_org",
2434
+ "tableFrom": "obligation_events",
2435
+ "tableTo": "billing_obligations",
2436
+ "columnsFrom": [
2437
+ "organisation_id",
2438
+ "obligation_id"
2439
+ ],
2440
+ "columnsTo": [
2441
+ "organisation_id",
2442
+ "id"
2443
+ ],
2444
+ "onDelete": "no action",
2445
+ "onUpdate": "no action"
2446
+ }
2447
+ },
2448
+ "compositePrimaryKeys": {},
2449
+ "uniqueConstraints": {},
2450
+ "policies": {},
2451
+ "checkConstraints": {},
2452
+ "isRLSEnabled": false
2453
+ },
2454
+ "public.obligation_payments": {
2455
+ "name": "obligation_payments",
2456
+ "schema": "",
2457
+ "columns": {
2458
+ "id": {
2459
+ "name": "id",
2460
+ "type": "uuid",
2461
+ "primaryKey": true,
2462
+ "notNull": true,
2463
+ "default": "gen_random_uuid()"
2464
+ },
2465
+ "organisation_id": {
2466
+ "name": "organisation_id",
2467
+ "type": "uuid",
2468
+ "primaryKey": false,
2469
+ "notNull": true
2470
+ },
2471
+ "obligation_id": {
2472
+ "name": "obligation_id",
2473
+ "type": "uuid",
2474
+ "primaryKey": false,
2475
+ "notNull": true
2476
+ },
2477
+ "payment_ref": {
2478
+ "name": "payment_ref",
2479
+ "type": "text",
2480
+ "primaryKey": false,
2481
+ "notNull": true
2482
+ },
2483
+ "paid_on": {
2484
+ "name": "paid_on",
2485
+ "type": "date",
2486
+ "primaryKey": false,
2487
+ "notNull": true
2488
+ },
2489
+ "amount_cents": {
2490
+ "name": "amount_cents",
2491
+ "type": "integer",
2492
+ "primaryKey": false,
2493
+ "notNull": true
2494
+ },
2495
+ "reference": {
2496
+ "name": "reference",
2497
+ "type": "text",
2498
+ "primaryKey": false,
2499
+ "notNull": false
2500
+ },
2501
+ "reconciled": {
2502
+ "name": "reconciled",
2503
+ "type": "boolean",
2504
+ "primaryKey": false,
2505
+ "notNull": true
2506
+ },
2507
+ "accounting_url": {
2508
+ "name": "accounting_url",
2509
+ "type": "text",
2510
+ "primaryKey": false,
2511
+ "notNull": false
2512
+ },
2513
+ "observed_at": {
2514
+ "name": "observed_at",
2515
+ "type": "timestamp with time zone",
2516
+ "primaryKey": false,
2517
+ "notNull": true,
2518
+ "default": "now()"
2519
+ }
2520
+ },
2521
+ "indexes": {},
2522
+ "foreignKeys": {
2523
+ "obligation_payments_obligation_same_org": {
2524
+ "name": "obligation_payments_obligation_same_org",
2525
+ "tableFrom": "obligation_payments",
2526
+ "tableTo": "billing_obligations",
2527
+ "columnsFrom": [
2528
+ "organisation_id",
2529
+ "obligation_id"
2530
+ ],
2531
+ "columnsTo": [
2532
+ "organisation_id",
2533
+ "id"
2534
+ ],
2535
+ "onDelete": "no action",
2536
+ "onUpdate": "no action"
2537
+ }
2538
+ },
2539
+ "compositePrimaryKeys": {},
2540
+ "uniqueConstraints": {
2541
+ "obligation_payments_ref": {
2542
+ "name": "obligation_payments_ref",
2543
+ "nullsNotDistinct": false,
2544
+ "columns": [
2545
+ "organisation_id",
2546
+ "obligation_id",
2547
+ "payment_ref"
2548
+ ]
2549
+ }
2550
+ },
2551
+ "policies": {},
2552
+ "checkConstraints": {
2553
+ "obligation_payments_amount_positive": {
2554
+ "name": "obligation_payments_amount_positive",
2555
+ "value": "\"obligation_payments\".\"amount_cents\" > 0"
2556
+ }
2557
+ },
2558
+ "isRLSEnabled": false
2559
+ },
2560
+ "public.obligation_writebacks": {
2561
+ "name": "obligation_writebacks",
2562
+ "schema": "",
2563
+ "columns": {
2564
+ "id": {
2565
+ "name": "id",
2566
+ "type": "uuid",
2567
+ "primaryKey": true,
2568
+ "notNull": true,
2569
+ "default": "gen_random_uuid()"
2570
+ },
2571
+ "organisation_id": {
2572
+ "name": "organisation_id",
2573
+ "type": "uuid",
2574
+ "primaryKey": false,
2575
+ "notNull": true
2576
+ },
2577
+ "obligation_id": {
2578
+ "name": "obligation_id",
2579
+ "type": "uuid",
2580
+ "primaryKey": false,
2581
+ "notNull": true
2582
+ },
2583
+ "target_system": {
2584
+ "name": "target_system",
2585
+ "type": "text",
2586
+ "primaryKey": false,
2587
+ "notNull": true
2588
+ },
2589
+ "status": {
2590
+ "name": "status",
2591
+ "type": "text",
2592
+ "primaryKey": false,
2593
+ "notNull": true
2594
+ },
2595
+ "state": {
2596
+ "name": "state",
2597
+ "type": "text",
2598
+ "primaryKey": false,
2599
+ "notNull": true,
2600
+ "default": "'pending'"
2601
+ },
2602
+ "evidence": {
2603
+ "name": "evidence",
2604
+ "type": "jsonb",
2605
+ "primaryKey": false,
2606
+ "notNull": true
2607
+ },
2608
+ "attempts": {
2609
+ "name": "attempts",
2610
+ "type": "integer",
2611
+ "primaryKey": false,
2612
+ "notNull": true,
2613
+ "default": 0
2614
+ },
2615
+ "last_error": {
2616
+ "name": "last_error",
2617
+ "type": "text",
2618
+ "primaryKey": false,
2619
+ "notNull": false
2620
+ },
2621
+ "sent_at": {
2622
+ "name": "sent_at",
2623
+ "type": "timestamp with time zone",
2624
+ "primaryKey": false,
2625
+ "notNull": false
2626
+ },
2627
+ "created_at": {
2628
+ "name": "created_at",
2629
+ "type": "timestamp with time zone",
2630
+ "primaryKey": false,
2631
+ "notNull": true,
2632
+ "default": "now()"
2633
+ },
2634
+ "updated_at": {
2635
+ "name": "updated_at",
2636
+ "type": "timestamp with time zone",
2637
+ "primaryKey": false,
2638
+ "notNull": true,
2639
+ "default": "now()"
2640
+ }
2641
+ },
2642
+ "indexes": {},
2643
+ "foreignKeys": {
2644
+ "obligation_writebacks_obligation_same_org": {
2645
+ "name": "obligation_writebacks_obligation_same_org",
2646
+ "tableFrom": "obligation_writebacks",
2647
+ "tableTo": "billing_obligations",
2648
+ "columnsFrom": [
2649
+ "organisation_id",
2650
+ "obligation_id"
2651
+ ],
2652
+ "columnsTo": [
2653
+ "organisation_id",
2654
+ "id"
2655
+ ],
2656
+ "onDelete": "no action",
2657
+ "onUpdate": "no action"
2658
+ }
2659
+ },
2660
+ "compositePrimaryKeys": {},
2661
+ "uniqueConstraints": {
2662
+ "obligation_writebacks_status": {
2663
+ "name": "obligation_writebacks_status",
2664
+ "nullsNotDistinct": false,
2665
+ "columns": [
2666
+ "organisation_id",
2667
+ "obligation_id",
2668
+ "status"
2669
+ ]
2670
+ }
2671
+ },
2672
+ "policies": {},
2673
+ "checkConstraints": {
2674
+ "obligation_writebacks_state_valid": {
2675
+ "name": "obligation_writebacks_state_valid",
2676
+ "value": "state in ('pending', 'sent', 'failed', 'not_supported')"
2677
+ }
2678
+ },
2679
+ "isRLSEnabled": false
2680
+ },
2681
+ "public.organisations": {
2682
+ "name": "organisations",
2683
+ "schema": "",
2684
+ "columns": {
2685
+ "id": {
2686
+ "name": "id",
2687
+ "type": "uuid",
2688
+ "primaryKey": true,
2689
+ "notNull": true,
2690
+ "default": "gen_random_uuid()"
2691
+ },
2692
+ "name": {
2693
+ "name": "name",
2694
+ "type": "text",
2695
+ "primaryKey": false,
2696
+ "notNull": true
2697
+ },
2698
+ "invoice_prefix": {
2699
+ "name": "invoice_prefix",
2700
+ "type": "text",
2701
+ "primaryKey": false,
2702
+ "notNull": true,
2703
+ "default": "'INV-'"
2704
+ },
2705
+ "next_invoice_number": {
2706
+ "name": "next_invoice_number",
2707
+ "type": "integer",
2708
+ "primaryKey": false,
2709
+ "notNull": true,
2710
+ "default": 1
2711
+ },
2712
+ "created_at": {
2713
+ "name": "created_at",
2714
+ "type": "timestamp with time zone",
2715
+ "primaryKey": false,
2716
+ "notNull": true,
2717
+ "default": "now()"
2718
+ }
2719
+ },
2720
+ "indexes": {},
2721
+ "foreignKeys": {},
2722
+ "compositePrimaryKeys": {},
2723
+ "uniqueConstraints": {},
2724
+ "policies": {},
2725
+ "checkConstraints": {
2726
+ "organisations_next_invoice_number_positive": {
2727
+ "name": "organisations_next_invoice_number_positive",
2728
+ "value": "\"organisations\".\"next_invoice_number\" > 0"
2729
+ }
2730
+ },
2731
+ "isRLSEnabled": false
2732
+ },
2733
+ "public.outbox": {
2734
+ "name": "outbox",
2735
+ "schema": "",
2736
+ "columns": {
2737
+ "id": {
2738
+ "name": "id",
2739
+ "type": "uuid",
2740
+ "primaryKey": true,
2741
+ "notNull": true,
2742
+ "default": "gen_random_uuid()"
2743
+ },
2744
+ "organisation_id": {
2745
+ "name": "organisation_id",
2746
+ "type": "uuid",
2747
+ "primaryKey": false,
2748
+ "notNull": true
2749
+ },
2750
+ "system": {
2751
+ "name": "system",
2752
+ "type": "text",
2753
+ "primaryKey": false,
2754
+ "notNull": true
2755
+ },
2756
+ "action": {
2757
+ "name": "action",
2758
+ "type": "text",
2759
+ "primaryKey": false,
2760
+ "notNull": true
2761
+ },
2762
+ "entity": {
2763
+ "name": "entity",
2764
+ "type": "text",
2765
+ "primaryKey": false,
2766
+ "notNull": true
2767
+ },
2768
+ "flow_id": {
2769
+ "name": "flow_id",
2770
+ "type": "uuid",
2771
+ "primaryKey": false,
2772
+ "notNull": true
2773
+ },
2774
+ "idempotency_key": {
2775
+ "name": "idempotency_key",
2776
+ "type": "text",
2777
+ "primaryKey": false,
2778
+ "notNull": true
2779
+ },
2780
+ "request": {
2781
+ "name": "request",
2782
+ "type": "jsonb",
2783
+ "primaryKey": false,
2784
+ "notNull": true
2785
+ },
2786
+ "state": {
2787
+ "name": "state",
2788
+ "type": "text",
2789
+ "primaryKey": false,
2790
+ "notNull": true,
2791
+ "default": "'pending'"
2792
+ },
2793
+ "external_id": {
2794
+ "name": "external_id",
2795
+ "type": "text",
2796
+ "primaryKey": false,
2797
+ "notNull": false
2798
+ },
2799
+ "attempts": {
2800
+ "name": "attempts",
2801
+ "type": "integer",
2802
+ "primaryKey": false,
2803
+ "notNull": true,
2804
+ "default": 0
2805
+ },
2806
+ "last_error": {
2807
+ "name": "last_error",
2808
+ "type": "text",
2809
+ "primaryKey": false,
2810
+ "notNull": false
2811
+ },
2812
+ "created_by": {
2813
+ "name": "created_by",
2814
+ "type": "text",
2815
+ "primaryKey": false,
2816
+ "notNull": true
2817
+ },
2818
+ "sent_at": {
2819
+ "name": "sent_at",
2820
+ "type": "timestamp with time zone",
2821
+ "primaryKey": false,
2822
+ "notNull": false
2823
+ },
2824
+ "created_at": {
2825
+ "name": "created_at",
2826
+ "type": "timestamp with time zone",
2827
+ "primaryKey": false,
2828
+ "notNull": true,
2829
+ "default": "now()"
2830
+ },
2831
+ "updated_at": {
2832
+ "name": "updated_at",
2833
+ "type": "timestamp with time zone",
2834
+ "primaryKey": false,
2835
+ "notNull": true,
2836
+ "default": "now()"
2837
+ }
2838
+ },
2839
+ "indexes": {
2840
+ "outbox_pending": {
2841
+ "name": "outbox_pending",
2842
+ "columns": [
2843
+ {
2844
+ "expression": "system",
2845
+ "isExpression": false,
2846
+ "asc": true,
2847
+ "nulls": "last"
2848
+ },
2849
+ {
2850
+ "expression": "state",
2851
+ "isExpression": false,
2852
+ "asc": true,
2853
+ "nulls": "last"
2854
+ },
2855
+ {
2856
+ "expression": "created_at",
2857
+ "isExpression": false,
2858
+ "asc": true,
2859
+ "nulls": "last"
2860
+ }
2861
+ ],
2862
+ "isUnique": false,
2863
+ "concurrently": false,
2864
+ "method": "btree",
2865
+ "with": {}
2866
+ }
2867
+ },
2868
+ "foreignKeys": {
2869
+ "outbox_organisation_id_organisations_id_fk": {
2870
+ "name": "outbox_organisation_id_organisations_id_fk",
2871
+ "tableFrom": "outbox",
2872
+ "tableTo": "organisations",
2873
+ "columnsFrom": [
2874
+ "organisation_id"
2875
+ ],
2876
+ "columnsTo": [
2877
+ "id"
2878
+ ],
2879
+ "onDelete": "no action",
2880
+ "onUpdate": "no action"
2881
+ }
2882
+ },
2883
+ "compositePrimaryKeys": {},
2884
+ "uniqueConstraints": {
2885
+ "outbox_org_id": {
2886
+ "name": "outbox_org_id",
2887
+ "nullsNotDistinct": false,
2888
+ "columns": [
2889
+ "organisation_id",
2890
+ "id"
2891
+ ]
2892
+ },
2893
+ "outbox_idempotency_key": {
2894
+ "name": "outbox_idempotency_key",
2895
+ "nullsNotDistinct": false,
2896
+ "columns": [
2897
+ "idempotency_key"
2898
+ ]
2899
+ }
2900
+ },
2901
+ "policies": {},
2902
+ "checkConstraints": {
2903
+ "outbox_state_valid": {
2904
+ "name": "outbox_state_valid",
2905
+ "value": "state in ('pending', 'sending', 'ambiguous', 'sent', 'failed', 'cancelled')"
2906
+ },
2907
+ "outbox_sent_has_id": {
2908
+ "name": "outbox_sent_has_id",
2909
+ "value": "\"outbox\".\"state\" <> 'sent' or \"outbox\".\"external_id\" is not null"
2910
+ }
2911
+ },
2912
+ "isRLSEnabled": false
2913
+ },
2914
+ "public.people": {
2915
+ "name": "people",
2916
+ "schema": "",
2917
+ "columns": {
2918
+ "id": {
2919
+ "name": "id",
2920
+ "type": "uuid",
2921
+ "primaryKey": true,
2922
+ "notNull": true,
2923
+ "default": "gen_random_uuid()"
2924
+ },
2925
+ "email": {
2926
+ "name": "email",
2927
+ "type": "text",
2928
+ "primaryKey": false,
2929
+ "notNull": true
2930
+ },
2931
+ "name": {
2932
+ "name": "name",
2933
+ "type": "text",
2934
+ "primaryKey": false,
2935
+ "notNull": false
2936
+ },
2937
+ "role": {
2938
+ "name": "role",
2939
+ "type": "text",
2940
+ "primaryKey": false,
2941
+ "notNull": true
2942
+ },
2943
+ "status": {
2944
+ "name": "status",
2945
+ "type": "text",
2946
+ "primaryKey": false,
2947
+ "notNull": true,
2948
+ "default": "'active'"
2949
+ },
2950
+ "clerk_user_id": {
2951
+ "name": "clerk_user_id",
2952
+ "type": "text",
2953
+ "primaryKey": false,
2954
+ "notNull": false
2955
+ },
2956
+ "invited_by": {
2957
+ "name": "invited_by",
2958
+ "type": "uuid",
2959
+ "primaryKey": false,
2960
+ "notNull": false
2961
+ },
2962
+ "linked_at": {
2963
+ "name": "linked_at",
2964
+ "type": "timestamp with time zone",
2965
+ "primaryKey": false,
2966
+ "notNull": false
2967
+ },
2968
+ "appearance": {
2969
+ "name": "appearance",
2970
+ "type": "jsonb",
2971
+ "primaryKey": false,
2972
+ "notNull": false
2973
+ },
2974
+ "created_at": {
2975
+ "name": "created_at",
2976
+ "type": "timestamp with time zone",
2977
+ "primaryKey": false,
2978
+ "notNull": true,
2979
+ "default": "now()"
2980
+ },
2981
+ "updated_at": {
2982
+ "name": "updated_at",
2983
+ "type": "timestamp with time zone",
2984
+ "primaryKey": false,
2985
+ "notNull": true,
2986
+ "default": "now()"
2987
+ }
2988
+ },
2989
+ "indexes": {},
2990
+ "foreignKeys": {
2991
+ "people_invited_by_people_id_fk": {
2992
+ "name": "people_invited_by_people_id_fk",
2993
+ "tableFrom": "people",
2994
+ "tableTo": "people",
2995
+ "columnsFrom": [
2996
+ "invited_by"
2997
+ ],
2998
+ "columnsTo": [
2999
+ "id"
3000
+ ],
3001
+ "onDelete": "set null",
3002
+ "onUpdate": "no action"
3003
+ }
3004
+ },
3005
+ "compositePrimaryKeys": {},
3006
+ "uniqueConstraints": {
3007
+ "people_email": {
3008
+ "name": "people_email",
3009
+ "nullsNotDistinct": false,
3010
+ "columns": [
3011
+ "email"
3012
+ ]
3013
+ },
3014
+ "people_clerk_user_id": {
3015
+ "name": "people_clerk_user_id",
3016
+ "nullsNotDistinct": false,
3017
+ "columns": [
3018
+ "clerk_user_id"
3019
+ ]
3020
+ }
3021
+ },
3022
+ "policies": {},
3023
+ "checkConstraints": {
3024
+ "people_email_lower": {
3025
+ "name": "people_email_lower",
3026
+ "value": "\"people\".\"email\" = lower(\"people\".\"email\")"
3027
+ },
3028
+ "people_role_valid": {
3029
+ "name": "people_role_valid",
3030
+ "value": "\"people\".\"role\" in ('owner', 'admin', 'staff')"
3031
+ },
3032
+ "people_status_valid": {
3033
+ "name": "people_status_valid",
3034
+ "value": "\"people\".\"status\" in ('active', 'pending', 'disabled')"
3035
+ }
3036
+ },
3037
+ "isRLSEnabled": false
3038
+ },
3039
+ "public.pipeline_cursors": {
3040
+ "name": "pipeline_cursors",
3041
+ "schema": "",
3042
+ "columns": {
3043
+ "organisation_id": {
3044
+ "name": "organisation_id",
3045
+ "type": "uuid",
3046
+ "primaryKey": false,
3047
+ "notNull": true
3048
+ },
3049
+ "name": {
3050
+ "name": "name",
3051
+ "type": "text",
3052
+ "primaryKey": false,
3053
+ "notNull": true
3054
+ },
3055
+ "cursor": {
3056
+ "name": "cursor",
3057
+ "type": "text",
3058
+ "primaryKey": false,
3059
+ "notNull": false
3060
+ },
3061
+ "updated_at": {
3062
+ "name": "updated_at",
3063
+ "type": "timestamp with time zone",
3064
+ "primaryKey": false,
3065
+ "notNull": true,
3066
+ "default": "now()"
3067
+ }
3068
+ },
3069
+ "indexes": {},
3070
+ "foreignKeys": {
3071
+ "pipeline_cursors_organisation_id_organisations_id_fk": {
3072
+ "name": "pipeline_cursors_organisation_id_organisations_id_fk",
3073
+ "tableFrom": "pipeline_cursors",
3074
+ "tableTo": "organisations",
3075
+ "columnsFrom": [
3076
+ "organisation_id"
3077
+ ],
3078
+ "columnsTo": [
3079
+ "id"
3080
+ ],
3081
+ "onDelete": "no action",
3082
+ "onUpdate": "no action"
3083
+ }
3084
+ },
3085
+ "compositePrimaryKeys": {
3086
+ "pipeline_cursors_pk": {
3087
+ "name": "pipeline_cursors_pk",
3088
+ "columns": [
3089
+ "organisation_id",
3090
+ "name"
3091
+ ]
3092
+ }
3093
+ },
3094
+ "uniqueConstraints": {},
3095
+ "policies": {},
3096
+ "checkConstraints": {},
3097
+ "isRLSEnabled": false
3098
+ },
3099
+ "public.price_item_links": {
3100
+ "name": "price_item_links",
3101
+ "schema": "",
3102
+ "columns": {
3103
+ "id": {
3104
+ "name": "id",
3105
+ "type": "uuid",
3106
+ "primaryKey": true,
3107
+ "notNull": true,
3108
+ "default": "gen_random_uuid()"
3109
+ },
3110
+ "organisation_id": {
3111
+ "name": "organisation_id",
3112
+ "type": "uuid",
3113
+ "primaryKey": false,
3114
+ "notNull": true
3115
+ },
3116
+ "price_item_id": {
3117
+ "name": "price_item_id",
3118
+ "type": "uuid",
3119
+ "primaryKey": false,
3120
+ "notNull": true
3121
+ },
3122
+ "system": {
3123
+ "name": "system",
3124
+ "type": "text",
3125
+ "primaryKey": false,
3126
+ "notNull": true
3127
+ },
3128
+ "external_id": {
3129
+ "name": "external_id",
3130
+ "type": "text",
3131
+ "primaryKey": false,
3132
+ "notNull": true
3133
+ },
3134
+ "external_code": {
3135
+ "name": "external_code",
3136
+ "type": "text",
3137
+ "primaryKey": false,
3138
+ "notNull": false
3139
+ },
3140
+ "matched_by": {
3141
+ "name": "matched_by",
3142
+ "type": "text",
3143
+ "primaryKey": false,
3144
+ "notNull": true
3145
+ },
3146
+ "created_by": {
3147
+ "name": "created_by",
3148
+ "type": "uuid",
3149
+ "primaryKey": false,
3150
+ "notNull": false
3151
+ },
3152
+ "created_at": {
3153
+ "name": "created_at",
3154
+ "type": "timestamp with time zone",
3155
+ "primaryKey": false,
3156
+ "notNull": true,
3157
+ "default": "now()"
3158
+ }
3159
+ },
3160
+ "indexes": {
3161
+ "price_item_links_external": {
3162
+ "name": "price_item_links_external",
3163
+ "columns": [
3164
+ {
3165
+ "expression": "organisation_id",
3166
+ "isExpression": false,
3167
+ "asc": true,
3168
+ "nulls": "last"
3169
+ },
3170
+ {
3171
+ "expression": "system",
3172
+ "isExpression": false,
3173
+ "asc": true,
3174
+ "nulls": "last"
3175
+ },
3176
+ {
3177
+ "expression": "external_id",
3178
+ "isExpression": false,
3179
+ "asc": true,
3180
+ "nulls": "last"
3181
+ }
3182
+ ],
3183
+ "isUnique": true,
3184
+ "concurrently": false,
3185
+ "method": "btree",
3186
+ "with": {}
3187
+ }
3188
+ },
3189
+ "foreignKeys": {
3190
+ "price_item_links_organisation_id_organisations_id_fk": {
3191
+ "name": "price_item_links_organisation_id_organisations_id_fk",
3192
+ "tableFrom": "price_item_links",
3193
+ "tableTo": "organisations",
3194
+ "columnsFrom": [
3195
+ "organisation_id"
3196
+ ],
3197
+ "columnsTo": [
3198
+ "id"
3199
+ ],
3200
+ "onDelete": "no action",
3201
+ "onUpdate": "no action"
3202
+ },
3203
+ "price_item_links_created_by_people_id_fk": {
3204
+ "name": "price_item_links_created_by_people_id_fk",
3205
+ "tableFrom": "price_item_links",
3206
+ "tableTo": "people",
3207
+ "columnsFrom": [
3208
+ "created_by"
3209
+ ],
3210
+ "columnsTo": [
3211
+ "id"
3212
+ ],
3213
+ "onDelete": "set null",
3214
+ "onUpdate": "no action"
3215
+ },
3216
+ "price_item_links_item_same_org": {
3217
+ "name": "price_item_links_item_same_org",
3218
+ "tableFrom": "price_item_links",
3219
+ "tableTo": "price_items",
3220
+ "columnsFrom": [
3221
+ "organisation_id",
3222
+ "price_item_id"
3223
+ ],
3224
+ "columnsTo": [
3225
+ "organisation_id",
3226
+ "id"
3227
+ ],
3228
+ "onDelete": "cascade",
3229
+ "onUpdate": "no action"
3230
+ }
3231
+ },
3232
+ "compositePrimaryKeys": {},
3233
+ "uniqueConstraints": {},
3234
+ "policies": {},
3235
+ "checkConstraints": {
3236
+ "price_item_links_matched_by_valid": {
3237
+ "name": "price_item_links_matched_by_valid",
3238
+ "value": "\"price_item_links\".\"matched_by\" in ('code', 'person')"
3239
+ },
3240
+ "price_item_links_system_valid": {
3241
+ "name": "price_item_links_system_valid",
3242
+ "value": "\"price_item_links\".\"system\" ~ '^[a-z][a-z0-9-]{1,31}$'"
3243
+ }
3244
+ },
3245
+ "isRLSEnabled": false
3246
+ },
3247
+ "public.price_items": {
3248
+ "name": "price_items",
3249
+ "schema": "",
3250
+ "columns": {
3251
+ "id": {
3252
+ "name": "id",
3253
+ "type": "uuid",
3254
+ "primaryKey": true,
3255
+ "notNull": true,
3256
+ "default": "gen_random_uuid()"
3257
+ },
3258
+ "organisation_id": {
3259
+ "name": "organisation_id",
3260
+ "type": "uuid",
3261
+ "primaryKey": false,
3262
+ "notNull": true
3263
+ },
3264
+ "code": {
3265
+ "name": "code",
3266
+ "type": "text",
3267
+ "primaryKey": false,
3268
+ "notNull": true
3269
+ },
3270
+ "name": {
3271
+ "name": "name",
3272
+ "type": "text",
3273
+ "primaryKey": false,
3274
+ "notNull": true
3275
+ },
3276
+ "description": {
3277
+ "name": "description",
3278
+ "type": "text",
3279
+ "primaryKey": false,
3280
+ "notNull": false
3281
+ },
3282
+ "unit_amount_cents": {
3283
+ "name": "unit_amount_cents",
3284
+ "type": "integer",
3285
+ "primaryKey": false,
3286
+ "notNull": true
3287
+ },
3288
+ "tax_code": {
3289
+ "name": "tax_code",
3290
+ "type": "text",
3291
+ "primaryKey": false,
3292
+ "notNull": true,
3293
+ "default": "'GST'"
3294
+ },
3295
+ "account_code": {
3296
+ "name": "account_code",
3297
+ "type": "text",
3298
+ "primaryKey": false,
3299
+ "notNull": false
3300
+ },
3301
+ "archived_at": {
3302
+ "name": "archived_at",
3303
+ "type": "timestamp with time zone",
3304
+ "primaryKey": false,
3305
+ "notNull": false
3306
+ },
3307
+ "updated_by": {
3308
+ "name": "updated_by",
3309
+ "type": "uuid",
3310
+ "primaryKey": false,
3311
+ "notNull": false
3312
+ },
3313
+ "created_at": {
3314
+ "name": "created_at",
3315
+ "type": "timestamp with time zone",
3316
+ "primaryKey": false,
3317
+ "notNull": true,
3318
+ "default": "now()"
3319
+ },
3320
+ "updated_at": {
3321
+ "name": "updated_at",
3322
+ "type": "timestamp with time zone",
3323
+ "primaryKey": false,
3324
+ "notNull": true,
3325
+ "default": "now()"
3326
+ }
3327
+ },
3328
+ "indexes": {},
3329
+ "foreignKeys": {
3330
+ "price_items_organisation_id_organisations_id_fk": {
3331
+ "name": "price_items_organisation_id_organisations_id_fk",
3332
+ "tableFrom": "price_items",
3333
+ "tableTo": "organisations",
3334
+ "columnsFrom": [
3335
+ "organisation_id"
3336
+ ],
3337
+ "columnsTo": [
3338
+ "id"
3339
+ ],
3340
+ "onDelete": "no action",
3341
+ "onUpdate": "no action"
3342
+ },
3343
+ "price_items_updated_by_people_id_fk": {
3344
+ "name": "price_items_updated_by_people_id_fk",
3345
+ "tableFrom": "price_items",
3346
+ "tableTo": "people",
3347
+ "columnsFrom": [
3348
+ "updated_by"
3349
+ ],
3350
+ "columnsTo": [
3351
+ "id"
3352
+ ],
3353
+ "onDelete": "set null",
3354
+ "onUpdate": "no action"
3355
+ }
3356
+ },
3357
+ "compositePrimaryKeys": {},
3358
+ "uniqueConstraints": {
3359
+ "price_items_org_id": {
3360
+ "name": "price_items_org_id",
3361
+ "nullsNotDistinct": false,
3362
+ "columns": [
3363
+ "organisation_id",
3364
+ "id"
3365
+ ]
3366
+ },
3367
+ "price_items_org_code": {
3368
+ "name": "price_items_org_code",
3369
+ "nullsNotDistinct": false,
3370
+ "columns": [
3371
+ "organisation_id",
3372
+ "code"
3373
+ ]
3374
+ }
3375
+ },
3376
+ "policies": {},
3377
+ "checkConstraints": {
3378
+ "price_items_tax_code_valid": {
3379
+ "name": "price_items_tax_code_valid",
3380
+ "value": "\"price_items\".\"tax_code\" in ('GST', 'GST_FREE')"
3381
+ }
3382
+ },
3383
+ "isRLSEnabled": false
3384
+ },
3385
+ "public.prior_links": {
3386
+ "name": "prior_links",
3387
+ "schema": "",
3388
+ "columns": {
3389
+ "id": {
3390
+ "name": "id",
3391
+ "type": "uuid",
3392
+ "primaryKey": true,
3393
+ "notNull": true,
3394
+ "default": "gen_random_uuid()"
3395
+ },
3396
+ "organisation_id": {
3397
+ "name": "organisation_id",
3398
+ "type": "uuid",
3399
+ "primaryKey": false,
3400
+ "notNull": true
3401
+ },
3402
+ "source_system": {
3403
+ "name": "source_system",
3404
+ "type": "text",
3405
+ "primaryKey": false,
3406
+ "notNull": true
3407
+ },
3408
+ "source_job_ref": {
3409
+ "name": "source_job_ref",
3410
+ "type": "text",
3411
+ "primaryKey": false,
3412
+ "notNull": true
3413
+ },
3414
+ "system": {
3415
+ "name": "system",
3416
+ "type": "text",
3417
+ "primaryKey": false,
3418
+ "notNull": true
3419
+ },
3420
+ "external_id": {
3421
+ "name": "external_id",
3422
+ "type": "text",
3423
+ "primaryKey": false,
3424
+ "notNull": true
3425
+ },
3426
+ "external_number": {
3427
+ "name": "external_number",
3428
+ "type": "text",
3429
+ "primaryKey": false,
3430
+ "notNull": false
3431
+ },
3432
+ "matched_by": {
3433
+ "name": "matched_by",
3434
+ "type": "text",
3435
+ "primaryKey": false,
3436
+ "notNull": true
3437
+ },
3438
+ "matched_at": {
3439
+ "name": "matched_at",
3440
+ "type": "timestamp with time zone",
3441
+ "primaryKey": false,
3442
+ "notNull": false
3443
+ },
3444
+ "origin": {
3445
+ "name": "origin",
3446
+ "type": "text",
3447
+ "primaryKey": false,
3448
+ "notNull": true
3449
+ },
3450
+ "created_at": {
3451
+ "name": "created_at",
3452
+ "type": "timestamp with time zone",
3453
+ "primaryKey": false,
3454
+ "notNull": true,
3455
+ "default": "now()"
3456
+ }
3457
+ },
3458
+ "indexes": {
3459
+ "prior_links_job": {
3460
+ "name": "prior_links_job",
3461
+ "columns": [
3462
+ {
3463
+ "expression": "organisation_id",
3464
+ "isExpression": false,
3465
+ "asc": true,
3466
+ "nulls": "last"
3467
+ },
3468
+ {
3469
+ "expression": "source_system",
3470
+ "isExpression": false,
3471
+ "asc": true,
3472
+ "nulls": "last"
3473
+ },
3474
+ {
3475
+ "expression": "source_job_ref",
3476
+ "isExpression": false,
3477
+ "asc": true,
3478
+ "nulls": "last"
3479
+ },
3480
+ {
3481
+ "expression": "system",
3482
+ "isExpression": false,
3483
+ "asc": true,
3484
+ "nulls": "last"
3485
+ }
3486
+ ],
3487
+ "isUnique": true,
3488
+ "concurrently": false,
3489
+ "method": "btree",
3490
+ "with": {}
3491
+ },
3492
+ "prior_links_external": {
3493
+ "name": "prior_links_external",
3494
+ "columns": [
3495
+ {
3496
+ "expression": "organisation_id",
3497
+ "isExpression": false,
3498
+ "asc": true,
3499
+ "nulls": "last"
3500
+ },
3501
+ {
3502
+ "expression": "system",
3503
+ "isExpression": false,
3504
+ "asc": true,
3505
+ "nulls": "last"
3506
+ },
3507
+ {
3508
+ "expression": "external_id",
3509
+ "isExpression": false,
3510
+ "asc": true,
3511
+ "nulls": "last"
3512
+ }
3513
+ ],
3514
+ "isUnique": false,
3515
+ "concurrently": false,
3516
+ "method": "btree",
3517
+ "with": {}
3518
+ }
3519
+ },
3520
+ "foreignKeys": {
3521
+ "prior_links_organisation_id_organisations_id_fk": {
3522
+ "name": "prior_links_organisation_id_organisations_id_fk",
3523
+ "tableFrom": "prior_links",
3524
+ "tableTo": "organisations",
3525
+ "columnsFrom": [
3526
+ "organisation_id"
3527
+ ],
3528
+ "columnsTo": [
3529
+ "id"
3530
+ ],
3531
+ "onDelete": "no action",
3532
+ "onUpdate": "no action"
3533
+ }
3534
+ },
3535
+ "compositePrimaryKeys": {},
3536
+ "uniqueConstraints": {},
3537
+ "policies": {},
3538
+ "checkConstraints": {
3539
+ "prior_links_matched_by_valid": {
3540
+ "name": "prior_links_matched_by_valid",
3541
+ "value": "matched_by in ('person', 'imported')"
3542
+ }
3543
+ },
3544
+ "isRLSEnabled": false
3545
+ },
3546
+ "public.review_items": {
3547
+ "name": "review_items",
3548
+ "schema": "",
3549
+ "columns": {
3550
+ "id": {
3551
+ "name": "id",
3552
+ "type": "uuid",
3553
+ "primaryKey": true,
3554
+ "notNull": true,
3555
+ "default": "gen_random_uuid()"
3556
+ },
3557
+ "organisation_id": {
3558
+ "name": "organisation_id",
3559
+ "type": "uuid",
3560
+ "primaryKey": false,
3561
+ "notNull": true
3562
+ },
3563
+ "kind": {
3564
+ "name": "kind",
3565
+ "type": "text",
3566
+ "primaryKey": false,
3567
+ "notNull": true
3568
+ },
3569
+ "entity": {
3570
+ "name": "entity",
3571
+ "type": "text",
3572
+ "primaryKey": false,
3573
+ "notNull": true
3574
+ },
3575
+ "flow_id": {
3576
+ "name": "flow_id",
3577
+ "type": "uuid",
3578
+ "primaryKey": false,
3579
+ "notNull": true
3580
+ },
3581
+ "systems": {
3582
+ "name": "systems",
3583
+ "type": "text[]",
3584
+ "primaryKey": false,
3585
+ "notNull": true,
3586
+ "default": "'{}'::text[]"
3587
+ },
3588
+ "evidence": {
3589
+ "name": "evidence",
3590
+ "type": "jsonb",
3591
+ "primaryKey": false,
3592
+ "notNull": true,
3593
+ "default": "'{}'::jsonb"
3594
+ },
3595
+ "money_at_risk_cents": {
3596
+ "name": "money_at_risk_cents",
3597
+ "type": "bigint",
3598
+ "primaryKey": false,
3599
+ "notNull": true,
3600
+ "default": 0
3601
+ },
3602
+ "state": {
3603
+ "name": "state",
3604
+ "type": "text",
3605
+ "primaryKey": false,
3606
+ "notNull": true,
3607
+ "default": "'open'"
3608
+ },
3609
+ "seen_count": {
3610
+ "name": "seen_count",
3611
+ "type": "integer",
3612
+ "primaryKey": false,
3613
+ "notNull": true,
3614
+ "default": 1
3615
+ },
3616
+ "resolution": {
3617
+ "name": "resolution",
3618
+ "type": "text",
3619
+ "primaryKey": false,
3620
+ "notNull": false
3621
+ },
3622
+ "note": {
3623
+ "name": "note",
3624
+ "type": "text",
3625
+ "primaryKey": false,
3626
+ "notNull": false
3627
+ },
3628
+ "resolved_by": {
3629
+ "name": "resolved_by",
3630
+ "type": "text",
3631
+ "primaryKey": false,
3632
+ "notNull": false
3633
+ },
3634
+ "resolved_at": {
3635
+ "name": "resolved_at",
3636
+ "type": "timestamp with time zone",
3637
+ "primaryKey": false,
3638
+ "notNull": false
3639
+ },
3640
+ "created_at": {
3641
+ "name": "created_at",
3642
+ "type": "timestamp with time zone",
3643
+ "primaryKey": false,
3644
+ "notNull": true,
3645
+ "default": "now()"
3646
+ },
3647
+ "updated_at": {
3648
+ "name": "updated_at",
3649
+ "type": "timestamp with time zone",
3650
+ "primaryKey": false,
3651
+ "notNull": true,
3652
+ "default": "now()"
3653
+ }
3654
+ },
3655
+ "indexes": {
3656
+ "review_items_one_open": {
3657
+ "name": "review_items_one_open",
3658
+ "columns": [
3659
+ {
3660
+ "expression": "organisation_id",
3661
+ "isExpression": false,
3662
+ "asc": true,
3663
+ "nulls": "last"
3664
+ },
3665
+ {
3666
+ "expression": "kind",
3667
+ "isExpression": false,
3668
+ "asc": true,
3669
+ "nulls": "last"
3670
+ },
3671
+ {
3672
+ "expression": "entity",
3673
+ "isExpression": false,
3674
+ "asc": true,
3675
+ "nulls": "last"
3676
+ },
3677
+ {
3678
+ "expression": "flow_id",
3679
+ "isExpression": false,
3680
+ "asc": true,
3681
+ "nulls": "last"
3682
+ }
3683
+ ],
3684
+ "isUnique": true,
3685
+ "where": "state = 'open'",
3686
+ "concurrently": false,
3687
+ "method": "btree",
3688
+ "with": {}
3689
+ },
3690
+ "review_items_queue": {
3691
+ "name": "review_items_queue",
3692
+ "columns": [
3693
+ {
3694
+ "expression": "organisation_id",
3695
+ "isExpression": false,
3696
+ "asc": true,
3697
+ "nulls": "last"
3698
+ },
3699
+ {
3700
+ "expression": "state",
3701
+ "isExpression": false,
3702
+ "asc": true,
3703
+ "nulls": "last"
3704
+ },
3705
+ {
3706
+ "expression": "money_at_risk_cents",
3707
+ "isExpression": false,
3708
+ "asc": true,
3709
+ "nulls": "last"
3710
+ }
3711
+ ],
3712
+ "isUnique": false,
3713
+ "concurrently": false,
3714
+ "method": "btree",
3715
+ "with": {}
3716
+ }
3717
+ },
3718
+ "foreignKeys": {
3719
+ "review_items_organisation_id_organisations_id_fk": {
3720
+ "name": "review_items_organisation_id_organisations_id_fk",
3721
+ "tableFrom": "review_items",
3722
+ "tableTo": "organisations",
3723
+ "columnsFrom": [
3724
+ "organisation_id"
3725
+ ],
3726
+ "columnsTo": [
3727
+ "id"
3728
+ ],
3729
+ "onDelete": "no action",
3730
+ "onUpdate": "no action"
3731
+ }
3732
+ },
3733
+ "compositePrimaryKeys": {},
3734
+ "uniqueConstraints": {
3735
+ "review_items_org_id": {
3736
+ "name": "review_items_org_id",
3737
+ "nullsNotDistinct": false,
3738
+ "columns": [
3739
+ "organisation_id",
3740
+ "id"
3741
+ ]
3742
+ }
3743
+ },
3744
+ "policies": {},
3745
+ "checkConstraints": {
3746
+ "review_items_state_valid": {
3747
+ "name": "review_items_state_valid",
3748
+ "value": "state in ('open', 'resolved', 'dismissed')"
3749
+ },
3750
+ "review_items_money_not_negative": {
3751
+ "name": "review_items_money_not_negative",
3752
+ "value": "\"review_items\".\"money_at_risk_cents\" >= 0"
3753
+ },
3754
+ "review_items_closed_has_resolution": {
3755
+ "name": "review_items_closed_has_resolution",
3756
+ "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)"
3757
+ }
3758
+ },
3759
+ "isRLSEnabled": false
3760
+ }
3761
+ },
3762
+ "enums": {},
3763
+ "schemas": {},
3764
+ "sequences": {},
3765
+ "roles": {},
3766
+ "policies": {},
3767
+ "views": {},
3768
+ "_meta": {
3769
+ "columns": {},
3770
+ "schemas": {},
3771
+ "tables": {}
3772
+ }
3773
+ }