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