@arcforgelabs/flow 2026.10.30 → 2026.10.32-beta.1

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 (67) 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 +110 -3
  6. package/server/app.js +29 -2
  7. package/server/core/alerts.js +157 -0
  8. package/server/core/history.js +65 -0
  9. package/server/core/invoice-pdf.js +266 -0
  10. package/server/core/invoicing-rules.js +12 -0
  11. package/server/core/job-board.js +25 -3
  12. package/server/core/line-mapping.js +36 -10
  13. package/server/core/pipeline.js +75 -3
  14. package/server/core/price-list.js +348 -0
  15. package/server/db/commands.js +42 -0
  16. package/server/db/doctor.js +168 -0
  17. package/server/db/migrations/0014_price_list.sql +34 -0
  18. package/server/db/migrations/0015_alert_dismissals.sql +17 -0
  19. package/server/db/migrations/meta/0014_snapshot.json +3773 -0
  20. package/server/db/migrations/meta/0015_snapshot.json +3854 -0
  21. package/server/db/migrations/meta/_journal.json +14 -0
  22. package/server/db/schema.js +44 -0
  23. package/server/flow-server.js +20 -1
  24. package/server/index.js +2 -1
  25. package/server/integrations/call-guard.js +362 -0
  26. package/server/integrations/port.js +20 -1
  27. package/server/integrations/seazona/feed.js +23 -1
  28. package/server/integrations/seazona/governor.js +50 -122
  29. package/server/integrations/seazona/history/backfill.js +208 -0
  30. package/server/integrations/seazona/history/csv.js +65 -0
  31. package/server/integrations/seazona/history/index.js +584 -0
  32. package/server/integrations/seazona/history/read.js +196 -0
  33. package/server/integrations/seazona/index.js +37 -1
  34. package/server/integrations/seazona/lanes.js +186 -50
  35. package/server/integrations/seazona/migrations/0003_call_guard.sql +2 -0
  36. package/server/integrations/seazona/migrations/0004_history_import.sql +68 -0
  37. package/server/integrations/seazona/migrations/meta/0003_snapshot.json +895 -0
  38. package/server/integrations/seazona/migrations/meta/0004_snapshot.json +1323 -0
  39. package/server/integrations/seazona/migrations/meta/_journal.json +14 -0
  40. package/server/integrations/seazona/routes.js +145 -0
  41. package/server/integrations/seazona/schema.js +94 -0
  42. package/server/integrations/seazona/settings.js +14 -3
  43. package/server/integrations/seazona/sync-once.js +1 -1
  44. package/server/integrations/seazona/tables.js +4 -0
  45. package/server/integrations/xero/client.js +27 -7
  46. package/server/integrations/xero/drafts.js +46 -8
  47. package/server/integrations/xero/import.js +125 -17
  48. package/server/integrations/xero/index.js +36 -7
  49. package/server/integrations/xero/lookup.js +26 -0
  50. package/server/integrations/xero/migrations/0006_xero_call_guard.sql +26 -0
  51. package/server/integrations/xero/migrations/meta/_journal.json +7 -0
  52. package/server/integrations/xero/mirror.js +11 -2
  53. package/server/integrations/xero/oauth.js +4 -1
  54. package/server/integrations/xero/reconcile.js +173 -0
  55. package/server/integrations/xero/routes.js +35 -0
  56. package/server/integrations/xero/runtime.js +45 -4
  57. package/server/release-channel.js +3 -3
  58. package/server/ui/alerts.js +77 -0
  59. package/server/ui/app-page.js +1 -1
  60. package/server/ui/app.js +48 -14
  61. package/server/ui/clerk-appearance.js +42 -9
  62. package/server/ui/flow.css +31 -2
  63. package/server/ui/invoicing-settings.js +1 -1
  64. package/server/ui/invoicing.js +121 -8
  65. package/server/ui/line-mappings.js +3 -2
  66. package/server/ui/price-list.js +247 -0
  67. package/server/ui/routes.js +1 -1
@@ -0,0 +1,3854 @@
1
+ {
2
+ "id": "3e6b39b2-459b-4baa-b762-8048a75d907e",
3
+ "prevId": "401fc023-725b-4679-a6df-d206a60871e5",
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
+ "rules_seeded": {
1924
+ "name": "rules_seeded",
1925
+ "type": "boolean",
1926
+ "primaryKey": false,
1927
+ "notNull": true,
1928
+ "default": false
1929
+ },
1930
+ "updated_by": {
1931
+ "name": "updated_by",
1932
+ "type": "uuid",
1933
+ "primaryKey": false,
1934
+ "notNull": false
1935
+ },
1936
+ "updated_at": {
1937
+ "name": "updated_at",
1938
+ "type": "timestamp with time zone",
1939
+ "primaryKey": false,
1940
+ "notNull": true,
1941
+ "default": "now()"
1942
+ }
1943
+ },
1944
+ "indexes": {},
1945
+ "foreignKeys": {
1946
+ "invoicing_settings_organisation_id_organisations_id_fk": {
1947
+ "name": "invoicing_settings_organisation_id_organisations_id_fk",
1948
+ "tableFrom": "invoicing_settings",
1949
+ "tableTo": "organisations",
1950
+ "columnsFrom": [
1951
+ "organisation_id"
1952
+ ],
1953
+ "columnsTo": [
1954
+ "id"
1955
+ ],
1956
+ "onDelete": "no action",
1957
+ "onUpdate": "no action"
1958
+ },
1959
+ "invoicing_settings_updated_by_people_id_fk": {
1960
+ "name": "invoicing_settings_updated_by_people_id_fk",
1961
+ "tableFrom": "invoicing_settings",
1962
+ "tableTo": "people",
1963
+ "columnsFrom": [
1964
+ "updated_by"
1965
+ ],
1966
+ "columnsTo": [
1967
+ "id"
1968
+ ],
1969
+ "onDelete": "set null",
1970
+ "onUpdate": "no action"
1971
+ }
1972
+ },
1973
+ "compositePrimaryKeys": {},
1974
+ "uniqueConstraints": {},
1975
+ "policies": {},
1976
+ "checkConstraints": {
1977
+ "invoicing_settings_send_mode_valid": {
1978
+ "name": "invoicing_settings_send_mode_valid",
1979
+ "value": "send_mode in ('accounting_draft', 'approve_and_email')"
1980
+ },
1981
+ "invoicing_settings_stale_days_valid": {
1982
+ "name": "invoicing_settings_stale_days_valid",
1983
+ "value": "\"invoicing_settings\".\"stale_days\" between 1 and 3650"
1984
+ },
1985
+ "invoicing_settings_terms_valid": {
1986
+ "name": "invoicing_settings_terms_valid",
1987
+ "value": "\"invoicing_settings\".\"payment_terms_days\" between 0 and 365"
1988
+ },
1989
+ "invoicing_settings_rush_valid": {
1990
+ "name": "invoicing_settings_rush_valid",
1991
+ "value": "\"invoicing_settings\".\"rush_percent\" between 0 and 100"
1992
+ }
1993
+ },
1994
+ "isRLSEnabled": false
1995
+ },
1996
+ "public.line_mappings": {
1997
+ "name": "line_mappings",
1998
+ "schema": "",
1999
+ "columns": {
2000
+ "id": {
2001
+ "name": "id",
2002
+ "type": "uuid",
2003
+ "primaryKey": true,
2004
+ "notNull": true,
2005
+ "default": "gen_random_uuid()"
2006
+ },
2007
+ "organisation_id": {
2008
+ "name": "organisation_id",
2009
+ "type": "uuid",
2010
+ "primaryKey": false,
2011
+ "notNull": true
2012
+ },
2013
+ "kind": {
2014
+ "name": "kind",
2015
+ "type": "text",
2016
+ "primaryKey": false,
2017
+ "notNull": true
2018
+ },
2019
+ "match": {
2020
+ "name": "match",
2021
+ "type": "text",
2022
+ "primaryKey": false,
2023
+ "notNull": true,
2024
+ "default": "'exact'"
2025
+ },
2026
+ "label": {
2027
+ "name": "label",
2028
+ "type": "text",
2029
+ "primaryKey": false,
2030
+ "notNull": true
2031
+ },
2032
+ "unit_amount_cents": {
2033
+ "name": "unit_amount_cents",
2034
+ "type": "integer",
2035
+ "primaryKey": false,
2036
+ "notNull": false
2037
+ },
2038
+ "item_code": {
2039
+ "name": "item_code",
2040
+ "type": "text",
2041
+ "primaryKey": false,
2042
+ "notNull": false
2043
+ },
2044
+ "account_code": {
2045
+ "name": "account_code",
2046
+ "type": "text",
2047
+ "primaryKey": false,
2048
+ "notNull": false
2049
+ },
2050
+ "tax_code": {
2051
+ "name": "tax_code",
2052
+ "type": "text",
2053
+ "primaryKey": false,
2054
+ "notNull": false
2055
+ },
2056
+ "description": {
2057
+ "name": "description",
2058
+ "type": "text",
2059
+ "primaryKey": false,
2060
+ "notNull": false
2061
+ },
2062
+ "enabled": {
2063
+ "name": "enabled",
2064
+ "type": "boolean",
2065
+ "primaryKey": false,
2066
+ "notNull": true,
2067
+ "default": true
2068
+ },
2069
+ "origin": {
2070
+ "name": "origin",
2071
+ "type": "text",
2072
+ "primaryKey": false,
2073
+ "notNull": true,
2074
+ "default": "'person'"
2075
+ },
2076
+ "updated_by": {
2077
+ "name": "updated_by",
2078
+ "type": "uuid",
2079
+ "primaryKey": false,
2080
+ "notNull": false
2081
+ },
2082
+ "created_at": {
2083
+ "name": "created_at",
2084
+ "type": "timestamp with time zone",
2085
+ "primaryKey": false,
2086
+ "notNull": true,
2087
+ "default": "now()"
2088
+ },
2089
+ "updated_at": {
2090
+ "name": "updated_at",
2091
+ "type": "timestamp with time zone",
2092
+ "primaryKey": false,
2093
+ "notNull": true,
2094
+ "default": "now()"
2095
+ }
2096
+ },
2097
+ "indexes": {
2098
+ "line_mappings_unique": {
2099
+ "name": "line_mappings_unique",
2100
+ "columns": [
2101
+ {
2102
+ "expression": "organisation_id",
2103
+ "isExpression": false,
2104
+ "asc": true,
2105
+ "nulls": "last"
2106
+ },
2107
+ {
2108
+ "expression": "kind",
2109
+ "isExpression": false,
2110
+ "asc": true,
2111
+ "nulls": "last"
2112
+ },
2113
+ {
2114
+ "expression": "match",
2115
+ "isExpression": false,
2116
+ "asc": true,
2117
+ "nulls": "last"
2118
+ },
2119
+ {
2120
+ "expression": "label",
2121
+ "isExpression": false,
2122
+ "asc": true,
2123
+ "nulls": "last"
2124
+ },
2125
+ {
2126
+ "expression": "coalesce(\"unit_amount_cents\", -1)",
2127
+ "asc": true,
2128
+ "isExpression": true,
2129
+ "nulls": "last"
2130
+ }
2131
+ ],
2132
+ "isUnique": true,
2133
+ "concurrently": false,
2134
+ "method": "btree",
2135
+ "with": {}
2136
+ }
2137
+ },
2138
+ "foreignKeys": {
2139
+ "line_mappings_organisation_id_organisations_id_fk": {
2140
+ "name": "line_mappings_organisation_id_organisations_id_fk",
2141
+ "tableFrom": "line_mappings",
2142
+ "tableTo": "organisations",
2143
+ "columnsFrom": [
2144
+ "organisation_id"
2145
+ ],
2146
+ "columnsTo": [
2147
+ "id"
2148
+ ],
2149
+ "onDelete": "no action",
2150
+ "onUpdate": "no action"
2151
+ },
2152
+ "line_mappings_updated_by_people_id_fk": {
2153
+ "name": "line_mappings_updated_by_people_id_fk",
2154
+ "tableFrom": "line_mappings",
2155
+ "tableTo": "people",
2156
+ "columnsFrom": [
2157
+ "updated_by"
2158
+ ],
2159
+ "columnsTo": [
2160
+ "id"
2161
+ ],
2162
+ "onDelete": "set null",
2163
+ "onUpdate": "no action"
2164
+ }
2165
+ },
2166
+ "compositePrimaryKeys": {},
2167
+ "uniqueConstraints": {},
2168
+ "policies": {},
2169
+ "checkConstraints": {
2170
+ "line_mappings_kind_valid": {
2171
+ "name": "line_mappings_kind_valid",
2172
+ "value": "\"line_mappings\".\"kind\" in ('alias', 'price_alias', 'saved', 'account')"
2173
+ },
2174
+ "line_mappings_match_valid": {
2175
+ "name": "line_mappings_match_valid",
2176
+ "value": "\"line_mappings\".\"match\" in ('exact', 'starts_with')"
2177
+ },
2178
+ "line_mappings_tax_code_valid": {
2179
+ "name": "line_mappings_tax_code_valid",
2180
+ "value": "\"line_mappings\".\"tax_code\" is null or \"line_mappings\".\"tax_code\" in ('GST', 'GST_FREE')"
2181
+ },
2182
+ "line_mappings_target": {
2183
+ "name": "line_mappings_target",
2184
+ "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)"
2185
+ },
2186
+ "line_mappings_price": {
2187
+ "name": "line_mappings_price",
2188
+ "value": "\"line_mappings\".\"kind\" not in ('price_alias', 'saved') or \"line_mappings\".\"unit_amount_cents\" is not null"
2189
+ },
2190
+ "line_mappings_label_valid": {
2191
+ "name": "line_mappings_label_valid",
2192
+ "value": "length(\"line_mappings\".\"label\") between 1 and 200"
2193
+ }
2194
+ },
2195
+ "isRLSEnabled": false
2196
+ },
2197
+ "public.link_rejections": {
2198
+ "name": "link_rejections",
2199
+ "schema": "",
2200
+ "columns": {
2201
+ "organisation_id": {
2202
+ "name": "organisation_id",
2203
+ "type": "uuid",
2204
+ "primaryKey": false,
2205
+ "notNull": true
2206
+ },
2207
+ "obligation_id": {
2208
+ "name": "obligation_id",
2209
+ "type": "uuid",
2210
+ "primaryKey": false,
2211
+ "notNull": true
2212
+ },
2213
+ "system": {
2214
+ "name": "system",
2215
+ "type": "text",
2216
+ "primaryKey": false,
2217
+ "notNull": true
2218
+ },
2219
+ "external_id": {
2220
+ "name": "external_id",
2221
+ "type": "text",
2222
+ "primaryKey": false,
2223
+ "notNull": true
2224
+ },
2225
+ "actor": {
2226
+ "name": "actor",
2227
+ "type": "text",
2228
+ "primaryKey": false,
2229
+ "notNull": true
2230
+ },
2231
+ "created_at": {
2232
+ "name": "created_at",
2233
+ "type": "timestamp with time zone",
2234
+ "primaryKey": false,
2235
+ "notNull": true,
2236
+ "default": "now()"
2237
+ }
2238
+ },
2239
+ "indexes": {},
2240
+ "foreignKeys": {
2241
+ "link_rejections_organisation_id_organisations_id_fk": {
2242
+ "name": "link_rejections_organisation_id_organisations_id_fk",
2243
+ "tableFrom": "link_rejections",
2244
+ "tableTo": "organisations",
2245
+ "columnsFrom": [
2246
+ "organisation_id"
2247
+ ],
2248
+ "columnsTo": [
2249
+ "id"
2250
+ ],
2251
+ "onDelete": "no action",
2252
+ "onUpdate": "no action"
2253
+ },
2254
+ "link_rejections_obligation_same_org": {
2255
+ "name": "link_rejections_obligation_same_org",
2256
+ "tableFrom": "link_rejections",
2257
+ "tableTo": "billing_obligations",
2258
+ "columnsFrom": [
2259
+ "organisation_id",
2260
+ "obligation_id"
2261
+ ],
2262
+ "columnsTo": [
2263
+ "organisation_id",
2264
+ "id"
2265
+ ],
2266
+ "onDelete": "no action",
2267
+ "onUpdate": "no action"
2268
+ }
2269
+ },
2270
+ "compositePrimaryKeys": {
2271
+ "link_rejections_pk": {
2272
+ "name": "link_rejections_pk",
2273
+ "columns": [
2274
+ "organisation_id",
2275
+ "obligation_id",
2276
+ "system",
2277
+ "external_id"
2278
+ ]
2279
+ }
2280
+ },
2281
+ "uniqueConstraints": {},
2282
+ "policies": {},
2283
+ "checkConstraints": {},
2284
+ "isRLSEnabled": false
2285
+ },
2286
+ "public.link_suggestions": {
2287
+ "name": "link_suggestions",
2288
+ "schema": "",
2289
+ "columns": {
2290
+ "id": {
2291
+ "name": "id",
2292
+ "type": "uuid",
2293
+ "primaryKey": true,
2294
+ "notNull": true,
2295
+ "default": "gen_random_uuid()"
2296
+ },
2297
+ "organisation_id": {
2298
+ "name": "organisation_id",
2299
+ "type": "uuid",
2300
+ "primaryKey": false,
2301
+ "notNull": true
2302
+ },
2303
+ "obligation_id": {
2304
+ "name": "obligation_id",
2305
+ "type": "uuid",
2306
+ "primaryKey": false,
2307
+ "notNull": true
2308
+ },
2309
+ "system": {
2310
+ "name": "system",
2311
+ "type": "text",
2312
+ "primaryKey": false,
2313
+ "notNull": true
2314
+ },
2315
+ "external_id": {
2316
+ "name": "external_id",
2317
+ "type": "text",
2318
+ "primaryKey": false,
2319
+ "notNull": true
2320
+ },
2321
+ "external_number": {
2322
+ "name": "external_number",
2323
+ "type": "text",
2324
+ "primaryKey": false,
2325
+ "notNull": false
2326
+ },
2327
+ "score": {
2328
+ "name": "score",
2329
+ "type": "integer",
2330
+ "primaryKey": false,
2331
+ "notNull": true
2332
+ },
2333
+ "rank": {
2334
+ "name": "rank",
2335
+ "type": "integer",
2336
+ "primaryKey": false,
2337
+ "notNull": true
2338
+ },
2339
+ "signals": {
2340
+ "name": "signals",
2341
+ "type": "jsonb",
2342
+ "primaryKey": false,
2343
+ "notNull": true,
2344
+ "default": "'[]'::jsonb"
2345
+ },
2346
+ "state": {
2347
+ "name": "state",
2348
+ "type": "text",
2349
+ "primaryKey": false,
2350
+ "notNull": true,
2351
+ "default": "'open'"
2352
+ },
2353
+ "decided_by": {
2354
+ "name": "decided_by",
2355
+ "type": "text",
2356
+ "primaryKey": false,
2357
+ "notNull": false
2358
+ },
2359
+ "decided_at": {
2360
+ "name": "decided_at",
2361
+ "type": "timestamp with time zone",
2362
+ "primaryKey": false,
2363
+ "notNull": false
2364
+ },
2365
+ "created_at": {
2366
+ "name": "created_at",
2367
+ "type": "timestamp with time zone",
2368
+ "primaryKey": false,
2369
+ "notNull": true,
2370
+ "default": "now()"
2371
+ },
2372
+ "updated_at": {
2373
+ "name": "updated_at",
2374
+ "type": "timestamp with time zone",
2375
+ "primaryKey": false,
2376
+ "notNull": true,
2377
+ "default": "now()"
2378
+ }
2379
+ },
2380
+ "indexes": {
2381
+ "link_suggestions_open": {
2382
+ "name": "link_suggestions_open",
2383
+ "columns": [
2384
+ {
2385
+ "expression": "organisation_id",
2386
+ "isExpression": false,
2387
+ "asc": true,
2388
+ "nulls": "last"
2389
+ },
2390
+ {
2391
+ "expression": "state",
2392
+ "isExpression": false,
2393
+ "asc": true,
2394
+ "nulls": "last"
2395
+ },
2396
+ {
2397
+ "expression": "obligation_id",
2398
+ "isExpression": false,
2399
+ "asc": true,
2400
+ "nulls": "last"
2401
+ }
2402
+ ],
2403
+ "isUnique": false,
2404
+ "concurrently": false,
2405
+ "method": "btree",
2406
+ "with": {}
2407
+ }
2408
+ },
2409
+ "foreignKeys": {
2410
+ "link_suggestions_organisation_id_organisations_id_fk": {
2411
+ "name": "link_suggestions_organisation_id_organisations_id_fk",
2412
+ "tableFrom": "link_suggestions",
2413
+ "tableTo": "organisations",
2414
+ "columnsFrom": [
2415
+ "organisation_id"
2416
+ ],
2417
+ "columnsTo": [
2418
+ "id"
2419
+ ],
2420
+ "onDelete": "no action",
2421
+ "onUpdate": "no action"
2422
+ },
2423
+ "link_suggestions_obligation_same_org": {
2424
+ "name": "link_suggestions_obligation_same_org",
2425
+ "tableFrom": "link_suggestions",
2426
+ "tableTo": "billing_obligations",
2427
+ "columnsFrom": [
2428
+ "organisation_id",
2429
+ "obligation_id"
2430
+ ],
2431
+ "columnsTo": [
2432
+ "organisation_id",
2433
+ "id"
2434
+ ],
2435
+ "onDelete": "no action",
2436
+ "onUpdate": "no action"
2437
+ }
2438
+ },
2439
+ "compositePrimaryKeys": {},
2440
+ "uniqueConstraints": {
2441
+ "link_suggestions_pair": {
2442
+ "name": "link_suggestions_pair",
2443
+ "nullsNotDistinct": false,
2444
+ "columns": [
2445
+ "organisation_id",
2446
+ "obligation_id",
2447
+ "system",
2448
+ "external_id"
2449
+ ]
2450
+ }
2451
+ },
2452
+ "policies": {},
2453
+ "checkConstraints": {
2454
+ "link_suggestions_state_valid": {
2455
+ "name": "link_suggestions_state_valid",
2456
+ "value": "state in ('open', 'accepted', 'rejected', 'stale')"
2457
+ }
2458
+ },
2459
+ "isRLSEnabled": false
2460
+ },
2461
+ "public.obligation_events": {
2462
+ "name": "obligation_events",
2463
+ "schema": "",
2464
+ "columns": {
2465
+ "id": {
2466
+ "name": "id",
2467
+ "type": "uuid",
2468
+ "primaryKey": true,
2469
+ "notNull": true,
2470
+ "default": "gen_random_uuid()"
2471
+ },
2472
+ "organisation_id": {
2473
+ "name": "organisation_id",
2474
+ "type": "uuid",
2475
+ "primaryKey": false,
2476
+ "notNull": true
2477
+ },
2478
+ "obligation_id": {
2479
+ "name": "obligation_id",
2480
+ "type": "uuid",
2481
+ "primaryKey": false,
2482
+ "notNull": true
2483
+ },
2484
+ "kind": {
2485
+ "name": "kind",
2486
+ "type": "text",
2487
+ "primaryKey": false,
2488
+ "notNull": true
2489
+ },
2490
+ "actor": {
2491
+ "name": "actor",
2492
+ "type": "text",
2493
+ "primaryKey": false,
2494
+ "notNull": true
2495
+ },
2496
+ "evidence": {
2497
+ "name": "evidence",
2498
+ "type": "jsonb",
2499
+ "primaryKey": false,
2500
+ "notNull": true,
2501
+ "default": "'{}'::jsonb"
2502
+ },
2503
+ "created_at": {
2504
+ "name": "created_at",
2505
+ "type": "timestamp with time zone",
2506
+ "primaryKey": false,
2507
+ "notNull": true,
2508
+ "default": "now()"
2509
+ }
2510
+ },
2511
+ "indexes": {},
2512
+ "foreignKeys": {
2513
+ "obligation_events_obligation_same_org": {
2514
+ "name": "obligation_events_obligation_same_org",
2515
+ "tableFrom": "obligation_events",
2516
+ "tableTo": "billing_obligations",
2517
+ "columnsFrom": [
2518
+ "organisation_id",
2519
+ "obligation_id"
2520
+ ],
2521
+ "columnsTo": [
2522
+ "organisation_id",
2523
+ "id"
2524
+ ],
2525
+ "onDelete": "no action",
2526
+ "onUpdate": "no action"
2527
+ }
2528
+ },
2529
+ "compositePrimaryKeys": {},
2530
+ "uniqueConstraints": {},
2531
+ "policies": {},
2532
+ "checkConstraints": {},
2533
+ "isRLSEnabled": false
2534
+ },
2535
+ "public.obligation_payments": {
2536
+ "name": "obligation_payments",
2537
+ "schema": "",
2538
+ "columns": {
2539
+ "id": {
2540
+ "name": "id",
2541
+ "type": "uuid",
2542
+ "primaryKey": true,
2543
+ "notNull": true,
2544
+ "default": "gen_random_uuid()"
2545
+ },
2546
+ "organisation_id": {
2547
+ "name": "organisation_id",
2548
+ "type": "uuid",
2549
+ "primaryKey": false,
2550
+ "notNull": true
2551
+ },
2552
+ "obligation_id": {
2553
+ "name": "obligation_id",
2554
+ "type": "uuid",
2555
+ "primaryKey": false,
2556
+ "notNull": true
2557
+ },
2558
+ "payment_ref": {
2559
+ "name": "payment_ref",
2560
+ "type": "text",
2561
+ "primaryKey": false,
2562
+ "notNull": true
2563
+ },
2564
+ "paid_on": {
2565
+ "name": "paid_on",
2566
+ "type": "date",
2567
+ "primaryKey": false,
2568
+ "notNull": true
2569
+ },
2570
+ "amount_cents": {
2571
+ "name": "amount_cents",
2572
+ "type": "integer",
2573
+ "primaryKey": false,
2574
+ "notNull": true
2575
+ },
2576
+ "reference": {
2577
+ "name": "reference",
2578
+ "type": "text",
2579
+ "primaryKey": false,
2580
+ "notNull": false
2581
+ },
2582
+ "reconciled": {
2583
+ "name": "reconciled",
2584
+ "type": "boolean",
2585
+ "primaryKey": false,
2586
+ "notNull": true
2587
+ },
2588
+ "accounting_url": {
2589
+ "name": "accounting_url",
2590
+ "type": "text",
2591
+ "primaryKey": false,
2592
+ "notNull": false
2593
+ },
2594
+ "observed_at": {
2595
+ "name": "observed_at",
2596
+ "type": "timestamp with time zone",
2597
+ "primaryKey": false,
2598
+ "notNull": true,
2599
+ "default": "now()"
2600
+ }
2601
+ },
2602
+ "indexes": {},
2603
+ "foreignKeys": {
2604
+ "obligation_payments_obligation_same_org": {
2605
+ "name": "obligation_payments_obligation_same_org",
2606
+ "tableFrom": "obligation_payments",
2607
+ "tableTo": "billing_obligations",
2608
+ "columnsFrom": [
2609
+ "organisation_id",
2610
+ "obligation_id"
2611
+ ],
2612
+ "columnsTo": [
2613
+ "organisation_id",
2614
+ "id"
2615
+ ],
2616
+ "onDelete": "no action",
2617
+ "onUpdate": "no action"
2618
+ }
2619
+ },
2620
+ "compositePrimaryKeys": {},
2621
+ "uniqueConstraints": {
2622
+ "obligation_payments_ref": {
2623
+ "name": "obligation_payments_ref",
2624
+ "nullsNotDistinct": false,
2625
+ "columns": [
2626
+ "organisation_id",
2627
+ "obligation_id",
2628
+ "payment_ref"
2629
+ ]
2630
+ }
2631
+ },
2632
+ "policies": {},
2633
+ "checkConstraints": {
2634
+ "obligation_payments_amount_positive": {
2635
+ "name": "obligation_payments_amount_positive",
2636
+ "value": "\"obligation_payments\".\"amount_cents\" > 0"
2637
+ }
2638
+ },
2639
+ "isRLSEnabled": false
2640
+ },
2641
+ "public.obligation_writebacks": {
2642
+ "name": "obligation_writebacks",
2643
+ "schema": "",
2644
+ "columns": {
2645
+ "id": {
2646
+ "name": "id",
2647
+ "type": "uuid",
2648
+ "primaryKey": true,
2649
+ "notNull": true,
2650
+ "default": "gen_random_uuid()"
2651
+ },
2652
+ "organisation_id": {
2653
+ "name": "organisation_id",
2654
+ "type": "uuid",
2655
+ "primaryKey": false,
2656
+ "notNull": true
2657
+ },
2658
+ "obligation_id": {
2659
+ "name": "obligation_id",
2660
+ "type": "uuid",
2661
+ "primaryKey": false,
2662
+ "notNull": true
2663
+ },
2664
+ "target_system": {
2665
+ "name": "target_system",
2666
+ "type": "text",
2667
+ "primaryKey": false,
2668
+ "notNull": true
2669
+ },
2670
+ "status": {
2671
+ "name": "status",
2672
+ "type": "text",
2673
+ "primaryKey": false,
2674
+ "notNull": true
2675
+ },
2676
+ "state": {
2677
+ "name": "state",
2678
+ "type": "text",
2679
+ "primaryKey": false,
2680
+ "notNull": true,
2681
+ "default": "'pending'"
2682
+ },
2683
+ "evidence": {
2684
+ "name": "evidence",
2685
+ "type": "jsonb",
2686
+ "primaryKey": false,
2687
+ "notNull": true
2688
+ },
2689
+ "attempts": {
2690
+ "name": "attempts",
2691
+ "type": "integer",
2692
+ "primaryKey": false,
2693
+ "notNull": true,
2694
+ "default": 0
2695
+ },
2696
+ "last_error": {
2697
+ "name": "last_error",
2698
+ "type": "text",
2699
+ "primaryKey": false,
2700
+ "notNull": false
2701
+ },
2702
+ "sent_at": {
2703
+ "name": "sent_at",
2704
+ "type": "timestamp with time zone",
2705
+ "primaryKey": false,
2706
+ "notNull": false
2707
+ },
2708
+ "created_at": {
2709
+ "name": "created_at",
2710
+ "type": "timestamp with time zone",
2711
+ "primaryKey": false,
2712
+ "notNull": true,
2713
+ "default": "now()"
2714
+ },
2715
+ "updated_at": {
2716
+ "name": "updated_at",
2717
+ "type": "timestamp with time zone",
2718
+ "primaryKey": false,
2719
+ "notNull": true,
2720
+ "default": "now()"
2721
+ }
2722
+ },
2723
+ "indexes": {},
2724
+ "foreignKeys": {
2725
+ "obligation_writebacks_obligation_same_org": {
2726
+ "name": "obligation_writebacks_obligation_same_org",
2727
+ "tableFrom": "obligation_writebacks",
2728
+ "tableTo": "billing_obligations",
2729
+ "columnsFrom": [
2730
+ "organisation_id",
2731
+ "obligation_id"
2732
+ ],
2733
+ "columnsTo": [
2734
+ "organisation_id",
2735
+ "id"
2736
+ ],
2737
+ "onDelete": "no action",
2738
+ "onUpdate": "no action"
2739
+ }
2740
+ },
2741
+ "compositePrimaryKeys": {},
2742
+ "uniqueConstraints": {
2743
+ "obligation_writebacks_status": {
2744
+ "name": "obligation_writebacks_status",
2745
+ "nullsNotDistinct": false,
2746
+ "columns": [
2747
+ "organisation_id",
2748
+ "obligation_id",
2749
+ "status"
2750
+ ]
2751
+ }
2752
+ },
2753
+ "policies": {},
2754
+ "checkConstraints": {
2755
+ "obligation_writebacks_state_valid": {
2756
+ "name": "obligation_writebacks_state_valid",
2757
+ "value": "state in ('pending', 'sent', 'failed', 'not_supported')"
2758
+ }
2759
+ },
2760
+ "isRLSEnabled": false
2761
+ },
2762
+ "public.organisations": {
2763
+ "name": "organisations",
2764
+ "schema": "",
2765
+ "columns": {
2766
+ "id": {
2767
+ "name": "id",
2768
+ "type": "uuid",
2769
+ "primaryKey": true,
2770
+ "notNull": true,
2771
+ "default": "gen_random_uuid()"
2772
+ },
2773
+ "name": {
2774
+ "name": "name",
2775
+ "type": "text",
2776
+ "primaryKey": false,
2777
+ "notNull": true
2778
+ },
2779
+ "invoice_prefix": {
2780
+ "name": "invoice_prefix",
2781
+ "type": "text",
2782
+ "primaryKey": false,
2783
+ "notNull": true,
2784
+ "default": "'INV-'"
2785
+ },
2786
+ "next_invoice_number": {
2787
+ "name": "next_invoice_number",
2788
+ "type": "integer",
2789
+ "primaryKey": false,
2790
+ "notNull": true,
2791
+ "default": 1
2792
+ },
2793
+ "created_at": {
2794
+ "name": "created_at",
2795
+ "type": "timestamp with time zone",
2796
+ "primaryKey": false,
2797
+ "notNull": true,
2798
+ "default": "now()"
2799
+ }
2800
+ },
2801
+ "indexes": {},
2802
+ "foreignKeys": {},
2803
+ "compositePrimaryKeys": {},
2804
+ "uniqueConstraints": {},
2805
+ "policies": {},
2806
+ "checkConstraints": {
2807
+ "organisations_next_invoice_number_positive": {
2808
+ "name": "organisations_next_invoice_number_positive",
2809
+ "value": "\"organisations\".\"next_invoice_number\" > 0"
2810
+ }
2811
+ },
2812
+ "isRLSEnabled": false
2813
+ },
2814
+ "public.outbox": {
2815
+ "name": "outbox",
2816
+ "schema": "",
2817
+ "columns": {
2818
+ "id": {
2819
+ "name": "id",
2820
+ "type": "uuid",
2821
+ "primaryKey": true,
2822
+ "notNull": true,
2823
+ "default": "gen_random_uuid()"
2824
+ },
2825
+ "organisation_id": {
2826
+ "name": "organisation_id",
2827
+ "type": "uuid",
2828
+ "primaryKey": false,
2829
+ "notNull": true
2830
+ },
2831
+ "system": {
2832
+ "name": "system",
2833
+ "type": "text",
2834
+ "primaryKey": false,
2835
+ "notNull": true
2836
+ },
2837
+ "action": {
2838
+ "name": "action",
2839
+ "type": "text",
2840
+ "primaryKey": false,
2841
+ "notNull": true
2842
+ },
2843
+ "entity": {
2844
+ "name": "entity",
2845
+ "type": "text",
2846
+ "primaryKey": false,
2847
+ "notNull": true
2848
+ },
2849
+ "flow_id": {
2850
+ "name": "flow_id",
2851
+ "type": "uuid",
2852
+ "primaryKey": false,
2853
+ "notNull": true
2854
+ },
2855
+ "idempotency_key": {
2856
+ "name": "idempotency_key",
2857
+ "type": "text",
2858
+ "primaryKey": false,
2859
+ "notNull": true
2860
+ },
2861
+ "request": {
2862
+ "name": "request",
2863
+ "type": "jsonb",
2864
+ "primaryKey": false,
2865
+ "notNull": true
2866
+ },
2867
+ "state": {
2868
+ "name": "state",
2869
+ "type": "text",
2870
+ "primaryKey": false,
2871
+ "notNull": true,
2872
+ "default": "'pending'"
2873
+ },
2874
+ "external_id": {
2875
+ "name": "external_id",
2876
+ "type": "text",
2877
+ "primaryKey": false,
2878
+ "notNull": false
2879
+ },
2880
+ "attempts": {
2881
+ "name": "attempts",
2882
+ "type": "integer",
2883
+ "primaryKey": false,
2884
+ "notNull": true,
2885
+ "default": 0
2886
+ },
2887
+ "last_error": {
2888
+ "name": "last_error",
2889
+ "type": "text",
2890
+ "primaryKey": false,
2891
+ "notNull": false
2892
+ },
2893
+ "created_by": {
2894
+ "name": "created_by",
2895
+ "type": "text",
2896
+ "primaryKey": false,
2897
+ "notNull": true
2898
+ },
2899
+ "sent_at": {
2900
+ "name": "sent_at",
2901
+ "type": "timestamp with time zone",
2902
+ "primaryKey": false,
2903
+ "notNull": false
2904
+ },
2905
+ "created_at": {
2906
+ "name": "created_at",
2907
+ "type": "timestamp with time zone",
2908
+ "primaryKey": false,
2909
+ "notNull": true,
2910
+ "default": "now()"
2911
+ },
2912
+ "updated_at": {
2913
+ "name": "updated_at",
2914
+ "type": "timestamp with time zone",
2915
+ "primaryKey": false,
2916
+ "notNull": true,
2917
+ "default": "now()"
2918
+ }
2919
+ },
2920
+ "indexes": {
2921
+ "outbox_pending": {
2922
+ "name": "outbox_pending",
2923
+ "columns": [
2924
+ {
2925
+ "expression": "system",
2926
+ "isExpression": false,
2927
+ "asc": true,
2928
+ "nulls": "last"
2929
+ },
2930
+ {
2931
+ "expression": "state",
2932
+ "isExpression": false,
2933
+ "asc": true,
2934
+ "nulls": "last"
2935
+ },
2936
+ {
2937
+ "expression": "created_at",
2938
+ "isExpression": false,
2939
+ "asc": true,
2940
+ "nulls": "last"
2941
+ }
2942
+ ],
2943
+ "isUnique": false,
2944
+ "concurrently": false,
2945
+ "method": "btree",
2946
+ "with": {}
2947
+ }
2948
+ },
2949
+ "foreignKeys": {
2950
+ "outbox_organisation_id_organisations_id_fk": {
2951
+ "name": "outbox_organisation_id_organisations_id_fk",
2952
+ "tableFrom": "outbox",
2953
+ "tableTo": "organisations",
2954
+ "columnsFrom": [
2955
+ "organisation_id"
2956
+ ],
2957
+ "columnsTo": [
2958
+ "id"
2959
+ ],
2960
+ "onDelete": "no action",
2961
+ "onUpdate": "no action"
2962
+ }
2963
+ },
2964
+ "compositePrimaryKeys": {},
2965
+ "uniqueConstraints": {
2966
+ "outbox_org_id": {
2967
+ "name": "outbox_org_id",
2968
+ "nullsNotDistinct": false,
2969
+ "columns": [
2970
+ "organisation_id",
2971
+ "id"
2972
+ ]
2973
+ },
2974
+ "outbox_idempotency_key": {
2975
+ "name": "outbox_idempotency_key",
2976
+ "nullsNotDistinct": false,
2977
+ "columns": [
2978
+ "idempotency_key"
2979
+ ]
2980
+ }
2981
+ },
2982
+ "policies": {},
2983
+ "checkConstraints": {
2984
+ "outbox_state_valid": {
2985
+ "name": "outbox_state_valid",
2986
+ "value": "state in ('pending', 'sending', 'ambiguous', 'sent', 'failed', 'cancelled')"
2987
+ },
2988
+ "outbox_sent_has_id": {
2989
+ "name": "outbox_sent_has_id",
2990
+ "value": "\"outbox\".\"state\" <> 'sent' or \"outbox\".\"external_id\" is not null"
2991
+ }
2992
+ },
2993
+ "isRLSEnabled": false
2994
+ },
2995
+ "public.people": {
2996
+ "name": "people",
2997
+ "schema": "",
2998
+ "columns": {
2999
+ "id": {
3000
+ "name": "id",
3001
+ "type": "uuid",
3002
+ "primaryKey": true,
3003
+ "notNull": true,
3004
+ "default": "gen_random_uuid()"
3005
+ },
3006
+ "email": {
3007
+ "name": "email",
3008
+ "type": "text",
3009
+ "primaryKey": false,
3010
+ "notNull": true
3011
+ },
3012
+ "name": {
3013
+ "name": "name",
3014
+ "type": "text",
3015
+ "primaryKey": false,
3016
+ "notNull": false
3017
+ },
3018
+ "role": {
3019
+ "name": "role",
3020
+ "type": "text",
3021
+ "primaryKey": false,
3022
+ "notNull": true
3023
+ },
3024
+ "status": {
3025
+ "name": "status",
3026
+ "type": "text",
3027
+ "primaryKey": false,
3028
+ "notNull": true,
3029
+ "default": "'active'"
3030
+ },
3031
+ "clerk_user_id": {
3032
+ "name": "clerk_user_id",
3033
+ "type": "text",
3034
+ "primaryKey": false,
3035
+ "notNull": false
3036
+ },
3037
+ "invited_by": {
3038
+ "name": "invited_by",
3039
+ "type": "uuid",
3040
+ "primaryKey": false,
3041
+ "notNull": false
3042
+ },
3043
+ "linked_at": {
3044
+ "name": "linked_at",
3045
+ "type": "timestamp with time zone",
3046
+ "primaryKey": false,
3047
+ "notNull": false
3048
+ },
3049
+ "appearance": {
3050
+ "name": "appearance",
3051
+ "type": "jsonb",
3052
+ "primaryKey": false,
3053
+ "notNull": false
3054
+ },
3055
+ "created_at": {
3056
+ "name": "created_at",
3057
+ "type": "timestamp with time zone",
3058
+ "primaryKey": false,
3059
+ "notNull": true,
3060
+ "default": "now()"
3061
+ },
3062
+ "updated_at": {
3063
+ "name": "updated_at",
3064
+ "type": "timestamp with time zone",
3065
+ "primaryKey": false,
3066
+ "notNull": true,
3067
+ "default": "now()"
3068
+ }
3069
+ },
3070
+ "indexes": {},
3071
+ "foreignKeys": {
3072
+ "people_invited_by_people_id_fk": {
3073
+ "name": "people_invited_by_people_id_fk",
3074
+ "tableFrom": "people",
3075
+ "tableTo": "people",
3076
+ "columnsFrom": [
3077
+ "invited_by"
3078
+ ],
3079
+ "columnsTo": [
3080
+ "id"
3081
+ ],
3082
+ "onDelete": "set null",
3083
+ "onUpdate": "no action"
3084
+ }
3085
+ },
3086
+ "compositePrimaryKeys": {},
3087
+ "uniqueConstraints": {
3088
+ "people_email": {
3089
+ "name": "people_email",
3090
+ "nullsNotDistinct": false,
3091
+ "columns": [
3092
+ "email"
3093
+ ]
3094
+ },
3095
+ "people_clerk_user_id": {
3096
+ "name": "people_clerk_user_id",
3097
+ "nullsNotDistinct": false,
3098
+ "columns": [
3099
+ "clerk_user_id"
3100
+ ]
3101
+ }
3102
+ },
3103
+ "policies": {},
3104
+ "checkConstraints": {
3105
+ "people_email_lower": {
3106
+ "name": "people_email_lower",
3107
+ "value": "\"people\".\"email\" = lower(\"people\".\"email\")"
3108
+ },
3109
+ "people_role_valid": {
3110
+ "name": "people_role_valid",
3111
+ "value": "\"people\".\"role\" in ('owner', 'admin', 'staff')"
3112
+ },
3113
+ "people_status_valid": {
3114
+ "name": "people_status_valid",
3115
+ "value": "\"people\".\"status\" in ('active', 'pending', 'disabled')"
3116
+ }
3117
+ },
3118
+ "isRLSEnabled": false
3119
+ },
3120
+ "public.pipeline_cursors": {
3121
+ "name": "pipeline_cursors",
3122
+ "schema": "",
3123
+ "columns": {
3124
+ "organisation_id": {
3125
+ "name": "organisation_id",
3126
+ "type": "uuid",
3127
+ "primaryKey": false,
3128
+ "notNull": true
3129
+ },
3130
+ "name": {
3131
+ "name": "name",
3132
+ "type": "text",
3133
+ "primaryKey": false,
3134
+ "notNull": true
3135
+ },
3136
+ "cursor": {
3137
+ "name": "cursor",
3138
+ "type": "text",
3139
+ "primaryKey": false,
3140
+ "notNull": false
3141
+ },
3142
+ "updated_at": {
3143
+ "name": "updated_at",
3144
+ "type": "timestamp with time zone",
3145
+ "primaryKey": false,
3146
+ "notNull": true,
3147
+ "default": "now()"
3148
+ }
3149
+ },
3150
+ "indexes": {},
3151
+ "foreignKeys": {
3152
+ "pipeline_cursors_organisation_id_organisations_id_fk": {
3153
+ "name": "pipeline_cursors_organisation_id_organisations_id_fk",
3154
+ "tableFrom": "pipeline_cursors",
3155
+ "tableTo": "organisations",
3156
+ "columnsFrom": [
3157
+ "organisation_id"
3158
+ ],
3159
+ "columnsTo": [
3160
+ "id"
3161
+ ],
3162
+ "onDelete": "no action",
3163
+ "onUpdate": "no action"
3164
+ }
3165
+ },
3166
+ "compositePrimaryKeys": {
3167
+ "pipeline_cursors_pk": {
3168
+ "name": "pipeline_cursors_pk",
3169
+ "columns": [
3170
+ "organisation_id",
3171
+ "name"
3172
+ ]
3173
+ }
3174
+ },
3175
+ "uniqueConstraints": {},
3176
+ "policies": {},
3177
+ "checkConstraints": {},
3178
+ "isRLSEnabled": false
3179
+ },
3180
+ "public.price_item_links": {
3181
+ "name": "price_item_links",
3182
+ "schema": "",
3183
+ "columns": {
3184
+ "id": {
3185
+ "name": "id",
3186
+ "type": "uuid",
3187
+ "primaryKey": true,
3188
+ "notNull": true,
3189
+ "default": "gen_random_uuid()"
3190
+ },
3191
+ "organisation_id": {
3192
+ "name": "organisation_id",
3193
+ "type": "uuid",
3194
+ "primaryKey": false,
3195
+ "notNull": true
3196
+ },
3197
+ "price_item_id": {
3198
+ "name": "price_item_id",
3199
+ "type": "uuid",
3200
+ "primaryKey": false,
3201
+ "notNull": true
3202
+ },
3203
+ "system": {
3204
+ "name": "system",
3205
+ "type": "text",
3206
+ "primaryKey": false,
3207
+ "notNull": true
3208
+ },
3209
+ "external_id": {
3210
+ "name": "external_id",
3211
+ "type": "text",
3212
+ "primaryKey": false,
3213
+ "notNull": true
3214
+ },
3215
+ "external_code": {
3216
+ "name": "external_code",
3217
+ "type": "text",
3218
+ "primaryKey": false,
3219
+ "notNull": false
3220
+ },
3221
+ "matched_by": {
3222
+ "name": "matched_by",
3223
+ "type": "text",
3224
+ "primaryKey": false,
3225
+ "notNull": true
3226
+ },
3227
+ "created_by": {
3228
+ "name": "created_by",
3229
+ "type": "uuid",
3230
+ "primaryKey": false,
3231
+ "notNull": false
3232
+ },
3233
+ "created_at": {
3234
+ "name": "created_at",
3235
+ "type": "timestamp with time zone",
3236
+ "primaryKey": false,
3237
+ "notNull": true,
3238
+ "default": "now()"
3239
+ }
3240
+ },
3241
+ "indexes": {
3242
+ "price_item_links_external": {
3243
+ "name": "price_item_links_external",
3244
+ "columns": [
3245
+ {
3246
+ "expression": "organisation_id",
3247
+ "isExpression": false,
3248
+ "asc": true,
3249
+ "nulls": "last"
3250
+ },
3251
+ {
3252
+ "expression": "system",
3253
+ "isExpression": false,
3254
+ "asc": true,
3255
+ "nulls": "last"
3256
+ },
3257
+ {
3258
+ "expression": "external_id",
3259
+ "isExpression": false,
3260
+ "asc": true,
3261
+ "nulls": "last"
3262
+ }
3263
+ ],
3264
+ "isUnique": true,
3265
+ "concurrently": false,
3266
+ "method": "btree",
3267
+ "with": {}
3268
+ }
3269
+ },
3270
+ "foreignKeys": {
3271
+ "price_item_links_organisation_id_organisations_id_fk": {
3272
+ "name": "price_item_links_organisation_id_organisations_id_fk",
3273
+ "tableFrom": "price_item_links",
3274
+ "tableTo": "organisations",
3275
+ "columnsFrom": [
3276
+ "organisation_id"
3277
+ ],
3278
+ "columnsTo": [
3279
+ "id"
3280
+ ],
3281
+ "onDelete": "no action",
3282
+ "onUpdate": "no action"
3283
+ },
3284
+ "price_item_links_created_by_people_id_fk": {
3285
+ "name": "price_item_links_created_by_people_id_fk",
3286
+ "tableFrom": "price_item_links",
3287
+ "tableTo": "people",
3288
+ "columnsFrom": [
3289
+ "created_by"
3290
+ ],
3291
+ "columnsTo": [
3292
+ "id"
3293
+ ],
3294
+ "onDelete": "set null",
3295
+ "onUpdate": "no action"
3296
+ },
3297
+ "price_item_links_item_same_org": {
3298
+ "name": "price_item_links_item_same_org",
3299
+ "tableFrom": "price_item_links",
3300
+ "tableTo": "price_items",
3301
+ "columnsFrom": [
3302
+ "organisation_id",
3303
+ "price_item_id"
3304
+ ],
3305
+ "columnsTo": [
3306
+ "organisation_id",
3307
+ "id"
3308
+ ],
3309
+ "onDelete": "cascade",
3310
+ "onUpdate": "no action"
3311
+ }
3312
+ },
3313
+ "compositePrimaryKeys": {},
3314
+ "uniqueConstraints": {},
3315
+ "policies": {},
3316
+ "checkConstraints": {
3317
+ "price_item_links_matched_by_valid": {
3318
+ "name": "price_item_links_matched_by_valid",
3319
+ "value": "\"price_item_links\".\"matched_by\" in ('code', 'person')"
3320
+ },
3321
+ "price_item_links_system_valid": {
3322
+ "name": "price_item_links_system_valid",
3323
+ "value": "\"price_item_links\".\"system\" ~ '^[a-z][a-z0-9-]{1,31}$'"
3324
+ }
3325
+ },
3326
+ "isRLSEnabled": false
3327
+ },
3328
+ "public.price_items": {
3329
+ "name": "price_items",
3330
+ "schema": "",
3331
+ "columns": {
3332
+ "id": {
3333
+ "name": "id",
3334
+ "type": "uuid",
3335
+ "primaryKey": true,
3336
+ "notNull": true,
3337
+ "default": "gen_random_uuid()"
3338
+ },
3339
+ "organisation_id": {
3340
+ "name": "organisation_id",
3341
+ "type": "uuid",
3342
+ "primaryKey": false,
3343
+ "notNull": true
3344
+ },
3345
+ "code": {
3346
+ "name": "code",
3347
+ "type": "text",
3348
+ "primaryKey": false,
3349
+ "notNull": true
3350
+ },
3351
+ "name": {
3352
+ "name": "name",
3353
+ "type": "text",
3354
+ "primaryKey": false,
3355
+ "notNull": true
3356
+ },
3357
+ "description": {
3358
+ "name": "description",
3359
+ "type": "text",
3360
+ "primaryKey": false,
3361
+ "notNull": false
3362
+ },
3363
+ "unit_amount_cents": {
3364
+ "name": "unit_amount_cents",
3365
+ "type": "integer",
3366
+ "primaryKey": false,
3367
+ "notNull": true
3368
+ },
3369
+ "tax_code": {
3370
+ "name": "tax_code",
3371
+ "type": "text",
3372
+ "primaryKey": false,
3373
+ "notNull": true,
3374
+ "default": "'GST'"
3375
+ },
3376
+ "account_code": {
3377
+ "name": "account_code",
3378
+ "type": "text",
3379
+ "primaryKey": false,
3380
+ "notNull": false
3381
+ },
3382
+ "archived_at": {
3383
+ "name": "archived_at",
3384
+ "type": "timestamp with time zone",
3385
+ "primaryKey": false,
3386
+ "notNull": false
3387
+ },
3388
+ "updated_by": {
3389
+ "name": "updated_by",
3390
+ "type": "uuid",
3391
+ "primaryKey": false,
3392
+ "notNull": false
3393
+ },
3394
+ "created_at": {
3395
+ "name": "created_at",
3396
+ "type": "timestamp with time zone",
3397
+ "primaryKey": false,
3398
+ "notNull": true,
3399
+ "default": "now()"
3400
+ },
3401
+ "updated_at": {
3402
+ "name": "updated_at",
3403
+ "type": "timestamp with time zone",
3404
+ "primaryKey": false,
3405
+ "notNull": true,
3406
+ "default": "now()"
3407
+ }
3408
+ },
3409
+ "indexes": {},
3410
+ "foreignKeys": {
3411
+ "price_items_organisation_id_organisations_id_fk": {
3412
+ "name": "price_items_organisation_id_organisations_id_fk",
3413
+ "tableFrom": "price_items",
3414
+ "tableTo": "organisations",
3415
+ "columnsFrom": [
3416
+ "organisation_id"
3417
+ ],
3418
+ "columnsTo": [
3419
+ "id"
3420
+ ],
3421
+ "onDelete": "no action",
3422
+ "onUpdate": "no action"
3423
+ },
3424
+ "price_items_updated_by_people_id_fk": {
3425
+ "name": "price_items_updated_by_people_id_fk",
3426
+ "tableFrom": "price_items",
3427
+ "tableTo": "people",
3428
+ "columnsFrom": [
3429
+ "updated_by"
3430
+ ],
3431
+ "columnsTo": [
3432
+ "id"
3433
+ ],
3434
+ "onDelete": "set null",
3435
+ "onUpdate": "no action"
3436
+ }
3437
+ },
3438
+ "compositePrimaryKeys": {},
3439
+ "uniqueConstraints": {
3440
+ "price_items_org_id": {
3441
+ "name": "price_items_org_id",
3442
+ "nullsNotDistinct": false,
3443
+ "columns": [
3444
+ "organisation_id",
3445
+ "id"
3446
+ ]
3447
+ },
3448
+ "price_items_org_code": {
3449
+ "name": "price_items_org_code",
3450
+ "nullsNotDistinct": false,
3451
+ "columns": [
3452
+ "organisation_id",
3453
+ "code"
3454
+ ]
3455
+ }
3456
+ },
3457
+ "policies": {},
3458
+ "checkConstraints": {
3459
+ "price_items_tax_code_valid": {
3460
+ "name": "price_items_tax_code_valid",
3461
+ "value": "\"price_items\".\"tax_code\" in ('GST', 'GST_FREE')"
3462
+ }
3463
+ },
3464
+ "isRLSEnabled": false
3465
+ },
3466
+ "public.prior_links": {
3467
+ "name": "prior_links",
3468
+ "schema": "",
3469
+ "columns": {
3470
+ "id": {
3471
+ "name": "id",
3472
+ "type": "uuid",
3473
+ "primaryKey": true,
3474
+ "notNull": true,
3475
+ "default": "gen_random_uuid()"
3476
+ },
3477
+ "organisation_id": {
3478
+ "name": "organisation_id",
3479
+ "type": "uuid",
3480
+ "primaryKey": false,
3481
+ "notNull": true
3482
+ },
3483
+ "source_system": {
3484
+ "name": "source_system",
3485
+ "type": "text",
3486
+ "primaryKey": false,
3487
+ "notNull": true
3488
+ },
3489
+ "source_job_ref": {
3490
+ "name": "source_job_ref",
3491
+ "type": "text",
3492
+ "primaryKey": false,
3493
+ "notNull": true
3494
+ },
3495
+ "system": {
3496
+ "name": "system",
3497
+ "type": "text",
3498
+ "primaryKey": false,
3499
+ "notNull": true
3500
+ },
3501
+ "external_id": {
3502
+ "name": "external_id",
3503
+ "type": "text",
3504
+ "primaryKey": false,
3505
+ "notNull": true
3506
+ },
3507
+ "external_number": {
3508
+ "name": "external_number",
3509
+ "type": "text",
3510
+ "primaryKey": false,
3511
+ "notNull": false
3512
+ },
3513
+ "matched_by": {
3514
+ "name": "matched_by",
3515
+ "type": "text",
3516
+ "primaryKey": false,
3517
+ "notNull": true
3518
+ },
3519
+ "matched_at": {
3520
+ "name": "matched_at",
3521
+ "type": "timestamp with time zone",
3522
+ "primaryKey": false,
3523
+ "notNull": false
3524
+ },
3525
+ "origin": {
3526
+ "name": "origin",
3527
+ "type": "text",
3528
+ "primaryKey": false,
3529
+ "notNull": true
3530
+ },
3531
+ "created_at": {
3532
+ "name": "created_at",
3533
+ "type": "timestamp with time zone",
3534
+ "primaryKey": false,
3535
+ "notNull": true,
3536
+ "default": "now()"
3537
+ }
3538
+ },
3539
+ "indexes": {
3540
+ "prior_links_job": {
3541
+ "name": "prior_links_job",
3542
+ "columns": [
3543
+ {
3544
+ "expression": "organisation_id",
3545
+ "isExpression": false,
3546
+ "asc": true,
3547
+ "nulls": "last"
3548
+ },
3549
+ {
3550
+ "expression": "source_system",
3551
+ "isExpression": false,
3552
+ "asc": true,
3553
+ "nulls": "last"
3554
+ },
3555
+ {
3556
+ "expression": "source_job_ref",
3557
+ "isExpression": false,
3558
+ "asc": true,
3559
+ "nulls": "last"
3560
+ },
3561
+ {
3562
+ "expression": "system",
3563
+ "isExpression": false,
3564
+ "asc": true,
3565
+ "nulls": "last"
3566
+ }
3567
+ ],
3568
+ "isUnique": true,
3569
+ "concurrently": false,
3570
+ "method": "btree",
3571
+ "with": {}
3572
+ },
3573
+ "prior_links_external": {
3574
+ "name": "prior_links_external",
3575
+ "columns": [
3576
+ {
3577
+ "expression": "organisation_id",
3578
+ "isExpression": false,
3579
+ "asc": true,
3580
+ "nulls": "last"
3581
+ },
3582
+ {
3583
+ "expression": "system",
3584
+ "isExpression": false,
3585
+ "asc": true,
3586
+ "nulls": "last"
3587
+ },
3588
+ {
3589
+ "expression": "external_id",
3590
+ "isExpression": false,
3591
+ "asc": true,
3592
+ "nulls": "last"
3593
+ }
3594
+ ],
3595
+ "isUnique": false,
3596
+ "concurrently": false,
3597
+ "method": "btree",
3598
+ "with": {}
3599
+ }
3600
+ },
3601
+ "foreignKeys": {
3602
+ "prior_links_organisation_id_organisations_id_fk": {
3603
+ "name": "prior_links_organisation_id_organisations_id_fk",
3604
+ "tableFrom": "prior_links",
3605
+ "tableTo": "organisations",
3606
+ "columnsFrom": [
3607
+ "organisation_id"
3608
+ ],
3609
+ "columnsTo": [
3610
+ "id"
3611
+ ],
3612
+ "onDelete": "no action",
3613
+ "onUpdate": "no action"
3614
+ }
3615
+ },
3616
+ "compositePrimaryKeys": {},
3617
+ "uniqueConstraints": {},
3618
+ "policies": {},
3619
+ "checkConstraints": {
3620
+ "prior_links_matched_by_valid": {
3621
+ "name": "prior_links_matched_by_valid",
3622
+ "value": "matched_by in ('person', 'imported')"
3623
+ }
3624
+ },
3625
+ "isRLSEnabled": false
3626
+ },
3627
+ "public.review_items": {
3628
+ "name": "review_items",
3629
+ "schema": "",
3630
+ "columns": {
3631
+ "id": {
3632
+ "name": "id",
3633
+ "type": "uuid",
3634
+ "primaryKey": true,
3635
+ "notNull": true,
3636
+ "default": "gen_random_uuid()"
3637
+ },
3638
+ "organisation_id": {
3639
+ "name": "organisation_id",
3640
+ "type": "uuid",
3641
+ "primaryKey": false,
3642
+ "notNull": true
3643
+ },
3644
+ "kind": {
3645
+ "name": "kind",
3646
+ "type": "text",
3647
+ "primaryKey": false,
3648
+ "notNull": true
3649
+ },
3650
+ "entity": {
3651
+ "name": "entity",
3652
+ "type": "text",
3653
+ "primaryKey": false,
3654
+ "notNull": true
3655
+ },
3656
+ "flow_id": {
3657
+ "name": "flow_id",
3658
+ "type": "uuid",
3659
+ "primaryKey": false,
3660
+ "notNull": true
3661
+ },
3662
+ "systems": {
3663
+ "name": "systems",
3664
+ "type": "text[]",
3665
+ "primaryKey": false,
3666
+ "notNull": true,
3667
+ "default": "'{}'::text[]"
3668
+ },
3669
+ "evidence": {
3670
+ "name": "evidence",
3671
+ "type": "jsonb",
3672
+ "primaryKey": false,
3673
+ "notNull": true,
3674
+ "default": "'{}'::jsonb"
3675
+ },
3676
+ "money_at_risk_cents": {
3677
+ "name": "money_at_risk_cents",
3678
+ "type": "bigint",
3679
+ "primaryKey": false,
3680
+ "notNull": true,
3681
+ "default": 0
3682
+ },
3683
+ "state": {
3684
+ "name": "state",
3685
+ "type": "text",
3686
+ "primaryKey": false,
3687
+ "notNull": true,
3688
+ "default": "'open'"
3689
+ },
3690
+ "seen_count": {
3691
+ "name": "seen_count",
3692
+ "type": "integer",
3693
+ "primaryKey": false,
3694
+ "notNull": true,
3695
+ "default": 1
3696
+ },
3697
+ "resolution": {
3698
+ "name": "resolution",
3699
+ "type": "text",
3700
+ "primaryKey": false,
3701
+ "notNull": false
3702
+ },
3703
+ "note": {
3704
+ "name": "note",
3705
+ "type": "text",
3706
+ "primaryKey": false,
3707
+ "notNull": false
3708
+ },
3709
+ "resolved_by": {
3710
+ "name": "resolved_by",
3711
+ "type": "text",
3712
+ "primaryKey": false,
3713
+ "notNull": false
3714
+ },
3715
+ "resolved_at": {
3716
+ "name": "resolved_at",
3717
+ "type": "timestamp with time zone",
3718
+ "primaryKey": false,
3719
+ "notNull": false
3720
+ },
3721
+ "created_at": {
3722
+ "name": "created_at",
3723
+ "type": "timestamp with time zone",
3724
+ "primaryKey": false,
3725
+ "notNull": true,
3726
+ "default": "now()"
3727
+ },
3728
+ "updated_at": {
3729
+ "name": "updated_at",
3730
+ "type": "timestamp with time zone",
3731
+ "primaryKey": false,
3732
+ "notNull": true,
3733
+ "default": "now()"
3734
+ }
3735
+ },
3736
+ "indexes": {
3737
+ "review_items_one_open": {
3738
+ "name": "review_items_one_open",
3739
+ "columns": [
3740
+ {
3741
+ "expression": "organisation_id",
3742
+ "isExpression": false,
3743
+ "asc": true,
3744
+ "nulls": "last"
3745
+ },
3746
+ {
3747
+ "expression": "kind",
3748
+ "isExpression": false,
3749
+ "asc": true,
3750
+ "nulls": "last"
3751
+ },
3752
+ {
3753
+ "expression": "entity",
3754
+ "isExpression": false,
3755
+ "asc": true,
3756
+ "nulls": "last"
3757
+ },
3758
+ {
3759
+ "expression": "flow_id",
3760
+ "isExpression": false,
3761
+ "asc": true,
3762
+ "nulls": "last"
3763
+ }
3764
+ ],
3765
+ "isUnique": true,
3766
+ "where": "state = 'open'",
3767
+ "concurrently": false,
3768
+ "method": "btree",
3769
+ "with": {}
3770
+ },
3771
+ "review_items_queue": {
3772
+ "name": "review_items_queue",
3773
+ "columns": [
3774
+ {
3775
+ "expression": "organisation_id",
3776
+ "isExpression": false,
3777
+ "asc": true,
3778
+ "nulls": "last"
3779
+ },
3780
+ {
3781
+ "expression": "state",
3782
+ "isExpression": false,
3783
+ "asc": true,
3784
+ "nulls": "last"
3785
+ },
3786
+ {
3787
+ "expression": "money_at_risk_cents",
3788
+ "isExpression": false,
3789
+ "asc": true,
3790
+ "nulls": "last"
3791
+ }
3792
+ ],
3793
+ "isUnique": false,
3794
+ "concurrently": false,
3795
+ "method": "btree",
3796
+ "with": {}
3797
+ }
3798
+ },
3799
+ "foreignKeys": {
3800
+ "review_items_organisation_id_organisations_id_fk": {
3801
+ "name": "review_items_organisation_id_organisations_id_fk",
3802
+ "tableFrom": "review_items",
3803
+ "tableTo": "organisations",
3804
+ "columnsFrom": [
3805
+ "organisation_id"
3806
+ ],
3807
+ "columnsTo": [
3808
+ "id"
3809
+ ],
3810
+ "onDelete": "no action",
3811
+ "onUpdate": "no action"
3812
+ }
3813
+ },
3814
+ "compositePrimaryKeys": {},
3815
+ "uniqueConstraints": {
3816
+ "review_items_org_id": {
3817
+ "name": "review_items_org_id",
3818
+ "nullsNotDistinct": false,
3819
+ "columns": [
3820
+ "organisation_id",
3821
+ "id"
3822
+ ]
3823
+ }
3824
+ },
3825
+ "policies": {},
3826
+ "checkConstraints": {
3827
+ "review_items_state_valid": {
3828
+ "name": "review_items_state_valid",
3829
+ "value": "state in ('open', 'resolved', 'dismissed')"
3830
+ },
3831
+ "review_items_money_not_negative": {
3832
+ "name": "review_items_money_not_negative",
3833
+ "value": "\"review_items\".\"money_at_risk_cents\" >= 0"
3834
+ },
3835
+ "review_items_closed_has_resolution": {
3836
+ "name": "review_items_closed_has_resolution",
3837
+ "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)"
3838
+ }
3839
+ },
3840
+ "isRLSEnabled": false
3841
+ }
3842
+ },
3843
+ "enums": {},
3844
+ "schemas": {},
3845
+ "sequences": {},
3846
+ "roles": {},
3847
+ "policies": {},
3848
+ "views": {},
3849
+ "_meta": {
3850
+ "columns": {},
3851
+ "schemas": {},
3852
+ "tables": {}
3853
+ }
3854
+ }