@arcforgelabs/flow 2026.10.27 → 2026.10.30

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