@arcforgelabs/flow 2026.10.46 → 2026.10.48-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 (64) hide show
  1. package/README.md +1 -0
  2. package/VISION.md +10 -10
  3. package/npm-shrinkwrap.json +11 -11
  4. package/package.json +1 -1
  5. package/server/api/invoicing.js +89 -22
  6. package/server/auth/people.js +3 -1
  7. package/server/auth/routes.js +4 -1
  8. package/server/core/contacts.js +160 -0
  9. package/server/core/directory.js +4 -9
  10. package/server/core/invoice-rules.js +34 -4
  11. package/server/core/invoices.js +93 -1
  12. package/server/core/invoicing-rules.js +20 -3
  13. package/server/core/job-board.js +1 -1
  14. package/server/core/sending.js +141 -25
  15. package/server/db/doctor.js +1 -1
  16. package/server/db/index.js +19 -0
  17. package/server/db/migrations/0021_flow_schema.sql +68 -0
  18. package/server/db/migrations/0022_contacts.sql +11 -0
  19. package/server/db/migrations/meta/0021_snapshot.json +4377 -0
  20. package/server/db/migrations/meta/0022_snapshot.json +4446 -0
  21. package/server/db/migrations/meta/_journal.json +14 -0
  22. package/server/db/schema.js +15 -0
  23. package/server/integrations/port.js +2 -0
  24. package/server/integrations/schema.js +3 -2
  25. package/server/integrations/seazona/sweep.js +11 -8
  26. package/server/integrations/sentry/index.js +14 -7
  27. package/server/integrations/setup.js +1 -0
  28. package/server/integrations/xero/catalogue.js +82 -14
  29. package/server/integrations/xero/client.js +37 -0
  30. package/server/integrations/xero/create-contact.js +126 -0
  31. package/server/integrations/xero/delete-invoice.js +104 -0
  32. package/server/integrations/xero/drafts.js +19 -8
  33. package/server/integrations/xero/index.js +9 -0
  34. package/server/integrations/xero/migrations/0011_xero_invoice_deleted.sql +11 -0
  35. package/server/integrations/xero/migrations/0012_xero_contact_details.sql +16 -0
  36. package/server/integrations/xero/migrations/meta/_journal.json +14 -0
  37. package/server/integrations/xero/routes.js +21 -0
  38. package/server/integrations/xero/settings.js +3 -0
  39. package/server/ui/alerts.js +2 -1
  40. package/server/ui/app.js +113 -28
  41. package/server/ui/bulk-bar.js +18 -5
  42. package/server/ui/columns.js +5 -2
  43. package/server/ui/contacts.js +260 -0
  44. package/server/ui/custom-fields.js +22 -7
  45. package/server/ui/flow.css +275 -24
  46. package/server/ui/invoicing.js +374 -70
  47. package/server/ui/job-board.js +10 -0
  48. package/server/ui/job-change.js +4 -3
  49. package/server/ui/job-view.js +3 -1
  50. package/server/ui/jobs.js +150 -19
  51. package/server/ui/kit.js +220 -45
  52. package/server/ui/list-views.js +50 -10
  53. package/server/ui/mobile.js +729 -0
  54. package/server/ui/monitoring.js +51 -0
  55. package/server/ui/nav-pins.js +44 -0
  56. package/server/ui/pager.js +57 -10
  57. package/server/ui/price-list.js +1 -1
  58. package/server/ui/price-reconcile.js +12 -12
  59. package/server/ui/reconcile.js +18 -17
  60. package/server/ui/routes.js +1 -1
  61. package/server/ui/saved-views.js +2 -1
  62. package/server/ui/sidecar.js +106 -6
  63. package/server/ui/view-bar.js +22 -11
  64. package/server/ui/xero-import.js +48 -19
@@ -0,0 +1,4446 @@
1
+ {
2
+ "id": "a1705db8-9a16-40c2-9173-556668e0253a",
3
+ "prevId": "7ecc7e68-c607-4081-bc3b-860601e5b84c",
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
+ "draft_basis": {
505
+ "name": "draft_basis",
506
+ "type": "jsonb",
507
+ "primaryKey": false,
508
+ "notNull": false
509
+ },
510
+ "accounting_state": {
511
+ "name": "accounting_state",
512
+ "type": "text",
513
+ "primaryKey": false,
514
+ "notNull": true,
515
+ "default": "'unknown'"
516
+ },
517
+ "accounting_ref": {
518
+ "name": "accounting_ref",
519
+ "type": "text",
520
+ "primaryKey": false,
521
+ "notNull": false
522
+ },
523
+ "accounting_url": {
524
+ "name": "accounting_url",
525
+ "type": "text",
526
+ "primaryKey": false,
527
+ "notNull": false
528
+ },
529
+ "accounting_matched_by": {
530
+ "name": "accounting_matched_by",
531
+ "type": "text",
532
+ "primaryKey": false,
533
+ "notNull": false
534
+ },
535
+ "accounting_checked_at": {
536
+ "name": "accounting_checked_at",
537
+ "type": "timestamp with time zone",
538
+ "primaryKey": false,
539
+ "notNull": false
540
+ },
541
+ "paid_cents": {
542
+ "name": "paid_cents",
543
+ "type": "integer",
544
+ "primaryKey": false,
545
+ "notNull": true,
546
+ "default": 0
547
+ },
548
+ "created_at": {
549
+ "name": "created_at",
550
+ "type": "timestamp with time zone",
551
+ "primaryKey": false,
552
+ "notNull": true,
553
+ "default": "now()"
554
+ },
555
+ "updated_at": {
556
+ "name": "updated_at",
557
+ "type": "timestamp with time zone",
558
+ "primaryKey": false,
559
+ "notNull": true,
560
+ "default": "now()"
561
+ }
562
+ },
563
+ "indexes": {},
564
+ "foreignKeys": {
565
+ "billing_obligations_organisation_id_organisations_id_fk": {
566
+ "name": "billing_obligations_organisation_id_organisations_id_fk",
567
+ "tableFrom": "billing_obligations",
568
+ "tableTo": "organisations",
569
+ "columnsFrom": [
570
+ "organisation_id"
571
+ ],
572
+ "columnsTo": [
573
+ "id"
574
+ ],
575
+ "onDelete": "no action",
576
+ "onUpdate": "no action"
577
+ },
578
+ "billing_obligations_contact_same_org": {
579
+ "name": "billing_obligations_contact_same_org",
580
+ "tableFrom": "billing_obligations",
581
+ "tableTo": "contacts",
582
+ "columnsFrom": [
583
+ "organisation_id",
584
+ "contact_id"
585
+ ],
586
+ "columnsTo": [
587
+ "organisation_id",
588
+ "id"
589
+ ],
590
+ "onDelete": "no action",
591
+ "onUpdate": "no action"
592
+ },
593
+ "billing_obligations_invoice_same_org": {
594
+ "name": "billing_obligations_invoice_same_org",
595
+ "tableFrom": "billing_obligations",
596
+ "tableTo": "invoices",
597
+ "columnsFrom": [
598
+ "organisation_id",
599
+ "invoice_id"
600
+ ],
601
+ "columnsTo": [
602
+ "organisation_id",
603
+ "id"
604
+ ],
605
+ "onDelete": "no action",
606
+ "onUpdate": "no action"
607
+ }
608
+ },
609
+ "compositePrimaryKeys": {},
610
+ "uniqueConstraints": {
611
+ "billing_obligations_org_id": {
612
+ "name": "billing_obligations_org_id",
613
+ "nullsNotDistinct": false,
614
+ "columns": [
615
+ "organisation_id",
616
+ "id"
617
+ ]
618
+ },
619
+ "billing_obligations_source_job": {
620
+ "name": "billing_obligations_source_job",
621
+ "nullsNotDistinct": false,
622
+ "columns": [
623
+ "organisation_id",
624
+ "source_system",
625
+ "source_job_ref"
626
+ ]
627
+ },
628
+ "billing_obligations_invoice": {
629
+ "name": "billing_obligations_invoice",
630
+ "nullsNotDistinct": false,
631
+ "columns": [
632
+ "organisation_id",
633
+ "invoice_id"
634
+ ]
635
+ }
636
+ },
637
+ "policies": {},
638
+ "checkConstraints": {
639
+ "billing_obligations_hold_state_valid": {
640
+ "name": "billing_obligations_hold_state_valid",
641
+ "value": "hold_state in ('none', 'held', 'review')"
642
+ },
643
+ "billing_obligations_accounting_state_valid": {
644
+ "name": "billing_obligations_accounting_state_valid",
645
+ "value": "accounting_state in ('unknown', 'not_found', 'drafted', 'authorised', 'part_paid', 'paid', 'voided', 'deleted', 'ambiguous', 'conflict')"
646
+ },
647
+ "billing_obligations_paid_not_negative": {
648
+ "name": "billing_obligations_paid_not_negative",
649
+ "value": "\"billing_obligations\".\"paid_cents\" >= 0"
650
+ }
651
+ },
652
+ "isRLSEnabled": false
653
+ },
654
+ "public.contacts": {
655
+ "name": "contacts",
656
+ "schema": "",
657
+ "columns": {
658
+ "id": {
659
+ "name": "id",
660
+ "type": "uuid",
661
+ "primaryKey": true,
662
+ "notNull": true,
663
+ "default": "gen_random_uuid()"
664
+ },
665
+ "organisation_id": {
666
+ "name": "organisation_id",
667
+ "type": "uuid",
668
+ "primaryKey": false,
669
+ "notNull": true
670
+ },
671
+ "kind": {
672
+ "name": "kind",
673
+ "type": "text",
674
+ "primaryKey": false,
675
+ "notNull": true
676
+ },
677
+ "name": {
678
+ "name": "name",
679
+ "type": "text",
680
+ "primaryKey": false,
681
+ "notNull": true
682
+ },
683
+ "first_name": {
684
+ "name": "first_name",
685
+ "type": "text",
686
+ "primaryKey": false,
687
+ "notNull": false
688
+ },
689
+ "last_name": {
690
+ "name": "last_name",
691
+ "type": "text",
692
+ "primaryKey": false,
693
+ "notNull": false
694
+ },
695
+ "email": {
696
+ "name": "email",
697
+ "type": "text",
698
+ "primaryKey": false,
699
+ "notNull": false
700
+ },
701
+ "phone": {
702
+ "name": "phone",
703
+ "type": "text",
704
+ "primaryKey": false,
705
+ "notNull": false
706
+ },
707
+ "mobile": {
708
+ "name": "mobile",
709
+ "type": "text",
710
+ "primaryKey": false,
711
+ "notNull": false
712
+ },
713
+ "account_number": {
714
+ "name": "account_number",
715
+ "type": "text",
716
+ "primaryKey": false,
717
+ "notNull": false
718
+ },
719
+ "tax_number": {
720
+ "name": "tax_number",
721
+ "type": "text",
722
+ "primaryKey": false,
723
+ "notNull": false
724
+ },
725
+ "tax_rate": {
726
+ "name": "tax_rate",
727
+ "type": "text",
728
+ "primaryKey": false,
729
+ "notNull": false
730
+ },
731
+ "address": {
732
+ "name": "address",
733
+ "type": "jsonb",
734
+ "primaryKey": false,
735
+ "notNull": false
736
+ },
737
+ "practitioners": {
738
+ "name": "practitioners",
739
+ "type": "jsonb",
740
+ "primaryKey": false,
741
+ "notNull": true,
742
+ "default": "'[]'::jsonb"
743
+ },
744
+ "active": {
745
+ "name": "active",
746
+ "type": "boolean",
747
+ "primaryKey": false,
748
+ "notNull": true,
749
+ "default": true
750
+ },
751
+ "created_at": {
752
+ "name": "created_at",
753
+ "type": "timestamp with time zone",
754
+ "primaryKey": false,
755
+ "notNull": true,
756
+ "default": "now()"
757
+ },
758
+ "updated_at": {
759
+ "name": "updated_at",
760
+ "type": "timestamp with time zone",
761
+ "primaryKey": false,
762
+ "notNull": true,
763
+ "default": "now()"
764
+ }
765
+ },
766
+ "indexes": {},
767
+ "foreignKeys": {
768
+ "contacts_organisation_id_organisations_id_fk": {
769
+ "name": "contacts_organisation_id_organisations_id_fk",
770
+ "tableFrom": "contacts",
771
+ "tableTo": "organisations",
772
+ "columnsFrom": [
773
+ "organisation_id"
774
+ ],
775
+ "columnsTo": [
776
+ "id"
777
+ ],
778
+ "onDelete": "no action",
779
+ "onUpdate": "no action"
780
+ }
781
+ },
782
+ "compositePrimaryKeys": {},
783
+ "uniqueConstraints": {
784
+ "contacts_org_id": {
785
+ "name": "contacts_org_id",
786
+ "nullsNotDistinct": false,
787
+ "columns": [
788
+ "organisation_id",
789
+ "id"
790
+ ]
791
+ },
792
+ "contacts_org_kind_name": {
793
+ "name": "contacts_org_kind_name",
794
+ "nullsNotDistinct": false,
795
+ "columns": [
796
+ "organisation_id",
797
+ "kind",
798
+ "name"
799
+ ]
800
+ }
801
+ },
802
+ "policies": {},
803
+ "checkConstraints": {
804
+ "contacts_kind_valid": {
805
+ "name": "contacts_kind_valid",
806
+ "value": "\"contacts\".\"kind\" in ('customer', 'supplier')"
807
+ }
808
+ },
809
+ "isRLSEnabled": false
810
+ },
811
+ "public.customer_billing_settings": {
812
+ "name": "customer_billing_settings",
813
+ "schema": "",
814
+ "columns": {
815
+ "organisation_id": {
816
+ "name": "organisation_id",
817
+ "type": "uuid",
818
+ "primaryKey": false,
819
+ "notNull": true
820
+ },
821
+ "contact_id": {
822
+ "name": "contact_id",
823
+ "type": "uuid",
824
+ "primaryKey": false,
825
+ "notNull": true
826
+ },
827
+ "billable": {
828
+ "name": "billable",
829
+ "type": "boolean",
830
+ "primaryKey": false,
831
+ "notNull": true,
832
+ "default": true
833
+ },
834
+ "default_practitioner": {
835
+ "name": "default_practitioner",
836
+ "type": "text",
837
+ "primaryKey": false,
838
+ "notNull": false
839
+ },
840
+ "auto_draft": {
841
+ "name": "auto_draft",
842
+ "type": "boolean",
843
+ "primaryKey": false,
844
+ "notNull": false
845
+ },
846
+ "send_mode": {
847
+ "name": "send_mode",
848
+ "type": "text",
849
+ "primaryKey": false,
850
+ "notNull": false
851
+ },
852
+ "payment_terms_days": {
853
+ "name": "payment_terms_days",
854
+ "type": "integer",
855
+ "primaryKey": false,
856
+ "notNull": false
857
+ },
858
+ "updated_by": {
859
+ "name": "updated_by",
860
+ "type": "uuid",
861
+ "primaryKey": false,
862
+ "notNull": false
863
+ },
864
+ "updated_at": {
865
+ "name": "updated_at",
866
+ "type": "timestamp with time zone",
867
+ "primaryKey": false,
868
+ "notNull": true,
869
+ "default": "now()"
870
+ }
871
+ },
872
+ "indexes": {},
873
+ "foreignKeys": {
874
+ "customer_billing_settings_organisation_id_organisations_id_fk": {
875
+ "name": "customer_billing_settings_organisation_id_organisations_id_fk",
876
+ "tableFrom": "customer_billing_settings",
877
+ "tableTo": "organisations",
878
+ "columnsFrom": [
879
+ "organisation_id"
880
+ ],
881
+ "columnsTo": [
882
+ "id"
883
+ ],
884
+ "onDelete": "no action",
885
+ "onUpdate": "no action"
886
+ },
887
+ "customer_billing_settings_updated_by_people_id_fk": {
888
+ "name": "customer_billing_settings_updated_by_people_id_fk",
889
+ "tableFrom": "customer_billing_settings",
890
+ "tableTo": "people",
891
+ "columnsFrom": [
892
+ "updated_by"
893
+ ],
894
+ "columnsTo": [
895
+ "id"
896
+ ],
897
+ "onDelete": "set null",
898
+ "onUpdate": "no action"
899
+ },
900
+ "customer_billing_settings_contact_same_org": {
901
+ "name": "customer_billing_settings_contact_same_org",
902
+ "tableFrom": "customer_billing_settings",
903
+ "tableTo": "contacts",
904
+ "columnsFrom": [
905
+ "organisation_id",
906
+ "contact_id"
907
+ ],
908
+ "columnsTo": [
909
+ "organisation_id",
910
+ "id"
911
+ ],
912
+ "onDelete": "no action",
913
+ "onUpdate": "no action"
914
+ }
915
+ },
916
+ "compositePrimaryKeys": {
917
+ "customer_billing_settings_pk": {
918
+ "name": "customer_billing_settings_pk",
919
+ "columns": [
920
+ "organisation_id",
921
+ "contact_id"
922
+ ]
923
+ }
924
+ },
925
+ "uniqueConstraints": {},
926
+ "policies": {},
927
+ "checkConstraints": {
928
+ "customer_billing_settings_send_mode_valid": {
929
+ "name": "customer_billing_settings_send_mode_valid",
930
+ "value": "\"customer_billing_settings\".\"send_mode\" is null or \"customer_billing_settings\".\"send_mode\" in ('accounting_draft', 'approve_and_email')"
931
+ },
932
+ "customer_billing_settings_terms_valid": {
933
+ "name": "customer_billing_settings_terms_valid",
934
+ "value": "\"customer_billing_settings\".\"payment_terms_days\" is null or \"customer_billing_settings\".\"payment_terms_days\" between 0 and 365"
935
+ }
936
+ },
937
+ "isRLSEnabled": false
938
+ },
939
+ "public.external_links": {
940
+ "name": "external_links",
941
+ "schema": "",
942
+ "columns": {
943
+ "id": {
944
+ "name": "id",
945
+ "type": "uuid",
946
+ "primaryKey": true,
947
+ "notNull": true,
948
+ "default": "gen_random_uuid()"
949
+ },
950
+ "organisation_id": {
951
+ "name": "organisation_id",
952
+ "type": "uuid",
953
+ "primaryKey": false,
954
+ "notNull": true
955
+ },
956
+ "entity": {
957
+ "name": "entity",
958
+ "type": "text",
959
+ "primaryKey": false,
960
+ "notNull": true
961
+ },
962
+ "flow_id": {
963
+ "name": "flow_id",
964
+ "type": "uuid",
965
+ "primaryKey": false,
966
+ "notNull": true
967
+ },
968
+ "system": {
969
+ "name": "system",
970
+ "type": "text",
971
+ "primaryKey": false,
972
+ "notNull": true
973
+ },
974
+ "external_id": {
975
+ "name": "external_id",
976
+ "type": "text",
977
+ "primaryKey": false,
978
+ "notNull": true
979
+ },
980
+ "matched_by": {
981
+ "name": "matched_by",
982
+ "type": "text",
983
+ "primaryKey": false,
984
+ "notNull": true
985
+ },
986
+ "state": {
987
+ "name": "state",
988
+ "type": "text",
989
+ "primaryKey": false,
990
+ "notNull": true
991
+ },
992
+ "confirmed_by": {
993
+ "name": "confirmed_by",
994
+ "type": "uuid",
995
+ "primaryKey": false,
996
+ "notNull": false
997
+ },
998
+ "confirmed_at": {
999
+ "name": "confirmed_at",
1000
+ "type": "timestamp with time zone",
1001
+ "primaryKey": false,
1002
+ "notNull": false
1003
+ },
1004
+ "created_at": {
1005
+ "name": "created_at",
1006
+ "type": "timestamp with time zone",
1007
+ "primaryKey": false,
1008
+ "notNull": true,
1009
+ "default": "now()"
1010
+ },
1011
+ "updated_at": {
1012
+ "name": "updated_at",
1013
+ "type": "timestamp with time zone",
1014
+ "primaryKey": false,
1015
+ "notNull": true,
1016
+ "default": "now()"
1017
+ }
1018
+ },
1019
+ "indexes": {
1020
+ "external_links_active_external": {
1021
+ "name": "external_links_active_external",
1022
+ "columns": [
1023
+ {
1024
+ "expression": "organisation_id",
1025
+ "isExpression": false,
1026
+ "asc": true,
1027
+ "nulls": "last"
1028
+ },
1029
+ {
1030
+ "expression": "system",
1031
+ "isExpression": false,
1032
+ "asc": true,
1033
+ "nulls": "last"
1034
+ },
1035
+ {
1036
+ "expression": "entity",
1037
+ "isExpression": false,
1038
+ "asc": true,
1039
+ "nulls": "last"
1040
+ },
1041
+ {
1042
+ "expression": "external_id",
1043
+ "isExpression": false,
1044
+ "asc": true,
1045
+ "nulls": "last"
1046
+ }
1047
+ ],
1048
+ "isUnique": true,
1049
+ "where": "state = 'active'",
1050
+ "concurrently": false,
1051
+ "method": "btree",
1052
+ "with": {}
1053
+ },
1054
+ "external_links_active_flow": {
1055
+ "name": "external_links_active_flow",
1056
+ "columns": [
1057
+ {
1058
+ "expression": "organisation_id",
1059
+ "isExpression": false,
1060
+ "asc": true,
1061
+ "nulls": "last"
1062
+ },
1063
+ {
1064
+ "expression": "system",
1065
+ "isExpression": false,
1066
+ "asc": true,
1067
+ "nulls": "last"
1068
+ },
1069
+ {
1070
+ "expression": "entity",
1071
+ "isExpression": false,
1072
+ "asc": true,
1073
+ "nulls": "last"
1074
+ },
1075
+ {
1076
+ "expression": "flow_id",
1077
+ "isExpression": false,
1078
+ "asc": true,
1079
+ "nulls": "last"
1080
+ }
1081
+ ],
1082
+ "isUnique": true,
1083
+ "where": "state = 'active'",
1084
+ "concurrently": false,
1085
+ "method": "btree",
1086
+ "with": {}
1087
+ },
1088
+ "external_links_flow": {
1089
+ "name": "external_links_flow",
1090
+ "columns": [
1091
+ {
1092
+ "expression": "organisation_id",
1093
+ "isExpression": false,
1094
+ "asc": true,
1095
+ "nulls": "last"
1096
+ },
1097
+ {
1098
+ "expression": "entity",
1099
+ "isExpression": false,
1100
+ "asc": true,
1101
+ "nulls": "last"
1102
+ },
1103
+ {
1104
+ "expression": "flow_id",
1105
+ "isExpression": false,
1106
+ "asc": true,
1107
+ "nulls": "last"
1108
+ }
1109
+ ],
1110
+ "isUnique": false,
1111
+ "concurrently": false,
1112
+ "method": "btree",
1113
+ "with": {}
1114
+ }
1115
+ },
1116
+ "foreignKeys": {
1117
+ "external_links_organisation_id_organisations_id_fk": {
1118
+ "name": "external_links_organisation_id_organisations_id_fk",
1119
+ "tableFrom": "external_links",
1120
+ "tableTo": "organisations",
1121
+ "columnsFrom": [
1122
+ "organisation_id"
1123
+ ],
1124
+ "columnsTo": [
1125
+ "id"
1126
+ ],
1127
+ "onDelete": "no action",
1128
+ "onUpdate": "no action"
1129
+ },
1130
+ "external_links_confirmed_by_people_id_fk": {
1131
+ "name": "external_links_confirmed_by_people_id_fk",
1132
+ "tableFrom": "external_links",
1133
+ "tableTo": "people",
1134
+ "columnsFrom": [
1135
+ "confirmed_by"
1136
+ ],
1137
+ "columnsTo": [
1138
+ "id"
1139
+ ],
1140
+ "onDelete": "set null",
1141
+ "onUpdate": "no action"
1142
+ }
1143
+ },
1144
+ "compositePrimaryKeys": {},
1145
+ "uniqueConstraints": {
1146
+ "external_links_org_id": {
1147
+ "name": "external_links_org_id",
1148
+ "nullsNotDistinct": false,
1149
+ "columns": [
1150
+ "organisation_id",
1151
+ "id"
1152
+ ]
1153
+ }
1154
+ },
1155
+ "policies": {},
1156
+ "checkConstraints": {
1157
+ "external_links_entity_valid": {
1158
+ "name": "external_links_entity_valid",
1159
+ "value": "entity in ('contact', 'price_item', 'obligation', 'invoice', 'payment', 'credit_note')"
1160
+ },
1161
+ "external_links_matched_by_valid": {
1162
+ "name": "external_links_matched_by_valid",
1163
+ "value": "matched_by in ('created_by_flow', 'exact_id', 'exact_name', 'imported', 'name', 'person')"
1164
+ },
1165
+ "external_links_state_valid": {
1166
+ "name": "external_links_state_valid",
1167
+ "value": "state in ('active', 'proposed', 'superseded')"
1168
+ },
1169
+ "external_links_name_needs_person": {
1170
+ "name": "external_links_name_needs_person",
1171
+ "value": "\"external_links\".\"matched_by\" <> 'name' or \"external_links\".\"state\" <> 'active' or \"external_links\".\"confirmed_at\" is not null"
1172
+ }
1173
+ },
1174
+ "isRLSEnabled": false
1175
+ },
1176
+ "public.integration_setting_events": {
1177
+ "name": "integration_setting_events",
1178
+ "schema": "",
1179
+ "columns": {
1180
+ "id": {
1181
+ "name": "id",
1182
+ "type": "uuid",
1183
+ "primaryKey": true,
1184
+ "notNull": true,
1185
+ "default": "gen_random_uuid()"
1186
+ },
1187
+ "adapter_id": {
1188
+ "name": "adapter_id",
1189
+ "type": "text",
1190
+ "primaryKey": false,
1191
+ "notNull": true
1192
+ },
1193
+ "kind": {
1194
+ "name": "kind",
1195
+ "type": "text",
1196
+ "primaryKey": false,
1197
+ "notNull": true
1198
+ },
1199
+ "settings": {
1200
+ "name": "settings",
1201
+ "type": "text[]",
1202
+ "primaryKey": false,
1203
+ "notNull": true,
1204
+ "default": "'{}'::text[]"
1205
+ },
1206
+ "actor": {
1207
+ "name": "actor",
1208
+ "type": "uuid",
1209
+ "primaryKey": false,
1210
+ "notNull": false
1211
+ },
1212
+ "created_at": {
1213
+ "name": "created_at",
1214
+ "type": "timestamp with time zone",
1215
+ "primaryKey": false,
1216
+ "notNull": true,
1217
+ "default": "now()"
1218
+ }
1219
+ },
1220
+ "indexes": {
1221
+ "integration_setting_events_adapter": {
1222
+ "name": "integration_setting_events_adapter",
1223
+ "columns": [
1224
+ {
1225
+ "expression": "adapter_id",
1226
+ "isExpression": false,
1227
+ "asc": true,
1228
+ "nulls": "last"
1229
+ },
1230
+ {
1231
+ "expression": "created_at",
1232
+ "isExpression": false,
1233
+ "asc": true,
1234
+ "nulls": "last"
1235
+ }
1236
+ ],
1237
+ "isUnique": false,
1238
+ "concurrently": false,
1239
+ "method": "btree",
1240
+ "with": {}
1241
+ }
1242
+ },
1243
+ "foreignKeys": {
1244
+ "integration_setting_events_actor_people_id_fk": {
1245
+ "name": "integration_setting_events_actor_people_id_fk",
1246
+ "tableFrom": "integration_setting_events",
1247
+ "tableTo": "people",
1248
+ "columnsFrom": [
1249
+ "actor"
1250
+ ],
1251
+ "columnsTo": [
1252
+ "id"
1253
+ ],
1254
+ "onDelete": "set null",
1255
+ "onUpdate": "no action"
1256
+ }
1257
+ },
1258
+ "compositePrimaryKeys": {},
1259
+ "uniqueConstraints": {},
1260
+ "policies": {},
1261
+ "checkConstraints": {
1262
+ "integration_setting_events_kind_valid": {
1263
+ "name": "integration_setting_events_kind_valid",
1264
+ "value": "kind in ('turned_on', 'turned_off', 'setting_changed', 'secret_set', 'secret_removed')"
1265
+ }
1266
+ },
1267
+ "isRLSEnabled": false
1268
+ },
1269
+ "public.integration_settings": {
1270
+ "name": "integration_settings",
1271
+ "schema": "",
1272
+ "columns": {
1273
+ "adapter_id": {
1274
+ "name": "adapter_id",
1275
+ "type": "text",
1276
+ "primaryKey": true,
1277
+ "notNull": true
1278
+ },
1279
+ "enabled": {
1280
+ "name": "enabled",
1281
+ "type": "boolean",
1282
+ "primaryKey": false,
1283
+ "notNull": true,
1284
+ "default": false
1285
+ },
1286
+ "config": {
1287
+ "name": "config",
1288
+ "type": "jsonb",
1289
+ "primaryKey": false,
1290
+ "notNull": true,
1291
+ "default": "'{}'::jsonb"
1292
+ },
1293
+ "secrets": {
1294
+ "name": "secrets",
1295
+ "type": "jsonb",
1296
+ "primaryKey": false,
1297
+ "notNull": true,
1298
+ "default": "'{}'::jsonb"
1299
+ },
1300
+ "updated_by": {
1301
+ "name": "updated_by",
1302
+ "type": "uuid",
1303
+ "primaryKey": false,
1304
+ "notNull": false
1305
+ },
1306
+ "created_at": {
1307
+ "name": "created_at",
1308
+ "type": "timestamp with time zone",
1309
+ "primaryKey": false,
1310
+ "notNull": true,
1311
+ "default": "now()"
1312
+ },
1313
+ "updated_at": {
1314
+ "name": "updated_at",
1315
+ "type": "timestamp with time zone",
1316
+ "primaryKey": false,
1317
+ "notNull": true,
1318
+ "default": "now()"
1319
+ }
1320
+ },
1321
+ "indexes": {},
1322
+ "foreignKeys": {
1323
+ "integration_settings_updated_by_people_id_fk": {
1324
+ "name": "integration_settings_updated_by_people_id_fk",
1325
+ "tableFrom": "integration_settings",
1326
+ "tableTo": "people",
1327
+ "columnsFrom": [
1328
+ "updated_by"
1329
+ ],
1330
+ "columnsTo": [
1331
+ "id"
1332
+ ],
1333
+ "onDelete": "set null",
1334
+ "onUpdate": "no action"
1335
+ }
1336
+ },
1337
+ "compositePrimaryKeys": {},
1338
+ "uniqueConstraints": {},
1339
+ "policies": {},
1340
+ "checkConstraints": {},
1341
+ "isRLSEnabled": false
1342
+ },
1343
+ "public.invoice_lines": {
1344
+ "name": "invoice_lines",
1345
+ "schema": "",
1346
+ "columns": {
1347
+ "id": {
1348
+ "name": "id",
1349
+ "type": "uuid",
1350
+ "primaryKey": true,
1351
+ "notNull": true,
1352
+ "default": "gen_random_uuid()"
1353
+ },
1354
+ "organisation_id": {
1355
+ "name": "organisation_id",
1356
+ "type": "uuid",
1357
+ "primaryKey": false,
1358
+ "notNull": true
1359
+ },
1360
+ "invoice_id": {
1361
+ "name": "invoice_id",
1362
+ "type": "uuid",
1363
+ "primaryKey": false,
1364
+ "notNull": true
1365
+ },
1366
+ "position": {
1367
+ "name": "position",
1368
+ "type": "integer",
1369
+ "primaryKey": false,
1370
+ "notNull": true
1371
+ },
1372
+ "price_item_id": {
1373
+ "name": "price_item_id",
1374
+ "type": "uuid",
1375
+ "primaryKey": false,
1376
+ "notNull": false
1377
+ },
1378
+ "description": {
1379
+ "name": "description",
1380
+ "type": "text",
1381
+ "primaryKey": false,
1382
+ "notNull": true
1383
+ },
1384
+ "quantity": {
1385
+ "name": "quantity",
1386
+ "type": "integer",
1387
+ "primaryKey": false,
1388
+ "notNull": true
1389
+ },
1390
+ "unit_amount_cents": {
1391
+ "name": "unit_amount_cents",
1392
+ "type": "integer",
1393
+ "primaryKey": false,
1394
+ "notNull": true
1395
+ },
1396
+ "tax_code": {
1397
+ "name": "tax_code",
1398
+ "type": "text",
1399
+ "primaryKey": false,
1400
+ "notNull": true
1401
+ },
1402
+ "account_code": {
1403
+ "name": "account_code",
1404
+ "type": "text",
1405
+ "primaryKey": false,
1406
+ "notNull": false
1407
+ },
1408
+ "line_amount_cents": {
1409
+ "name": "line_amount_cents",
1410
+ "type": "integer",
1411
+ "primaryKey": false,
1412
+ "notNull": true
1413
+ },
1414
+ "tax_cents": {
1415
+ "name": "tax_cents",
1416
+ "type": "integer",
1417
+ "primaryKey": false,
1418
+ "notNull": true
1419
+ }
1420
+ },
1421
+ "indexes": {},
1422
+ "foreignKeys": {
1423
+ "invoice_lines_invoice_same_org": {
1424
+ "name": "invoice_lines_invoice_same_org",
1425
+ "tableFrom": "invoice_lines",
1426
+ "tableTo": "invoices",
1427
+ "columnsFrom": [
1428
+ "organisation_id",
1429
+ "invoice_id"
1430
+ ],
1431
+ "columnsTo": [
1432
+ "organisation_id",
1433
+ "id"
1434
+ ],
1435
+ "onDelete": "cascade",
1436
+ "onUpdate": "no action"
1437
+ },
1438
+ "invoice_lines_price_item_same_org": {
1439
+ "name": "invoice_lines_price_item_same_org",
1440
+ "tableFrom": "invoice_lines",
1441
+ "tableTo": "price_items",
1442
+ "columnsFrom": [
1443
+ "organisation_id",
1444
+ "price_item_id"
1445
+ ],
1446
+ "columnsTo": [
1447
+ "organisation_id",
1448
+ "id"
1449
+ ],
1450
+ "onDelete": "no action",
1451
+ "onUpdate": "no action"
1452
+ }
1453
+ },
1454
+ "compositePrimaryKeys": {},
1455
+ "uniqueConstraints": {
1456
+ "invoice_lines_invoice_position": {
1457
+ "name": "invoice_lines_invoice_position",
1458
+ "nullsNotDistinct": false,
1459
+ "columns": [
1460
+ "invoice_id",
1461
+ "position"
1462
+ ]
1463
+ }
1464
+ },
1465
+ "policies": {},
1466
+ "checkConstraints": {
1467
+ "invoice_lines_quantity_positive": {
1468
+ "name": "invoice_lines_quantity_positive",
1469
+ "value": "\"invoice_lines\".\"quantity\" > 0"
1470
+ },
1471
+ "invoice_lines_tax_code_valid": {
1472
+ "name": "invoice_lines_tax_code_valid",
1473
+ "value": "\"invoice_lines\".\"tax_code\" in ('GST', 'GST_FREE')"
1474
+ }
1475
+ },
1476
+ "isRLSEnabled": false
1477
+ },
1478
+ "public.invoice_rules": {
1479
+ "name": "invoice_rules",
1480
+ "schema": "",
1481
+ "columns": {
1482
+ "id": {
1483
+ "name": "id",
1484
+ "type": "uuid",
1485
+ "primaryKey": true,
1486
+ "notNull": true,
1487
+ "default": "gen_random_uuid()"
1488
+ },
1489
+ "organisation_id": {
1490
+ "name": "organisation_id",
1491
+ "type": "uuid",
1492
+ "primaryKey": false,
1493
+ "notNull": true
1494
+ },
1495
+ "name": {
1496
+ "name": "name",
1497
+ "type": "text",
1498
+ "primaryKey": false,
1499
+ "notNull": true
1500
+ },
1501
+ "position": {
1502
+ "name": "position",
1503
+ "type": "integer",
1504
+ "primaryKey": false,
1505
+ "notNull": true
1506
+ },
1507
+ "enabled": {
1508
+ "name": "enabled",
1509
+ "type": "boolean",
1510
+ "primaryKey": false,
1511
+ "notNull": true,
1512
+ "default": true
1513
+ },
1514
+ "trigger": {
1515
+ "name": "trigger",
1516
+ "type": "text",
1517
+ "primaryKey": false,
1518
+ "notNull": true,
1519
+ "default": "'job_ready'"
1520
+ },
1521
+ "conditions": {
1522
+ "name": "conditions",
1523
+ "type": "jsonb",
1524
+ "primaryKey": false,
1525
+ "notNull": true,
1526
+ "default": "'[]'::jsonb"
1527
+ },
1528
+ "action": {
1529
+ "name": "action",
1530
+ "type": "jsonb",
1531
+ "primaryKey": false,
1532
+ "notNull": true
1533
+ },
1534
+ "starter_key": {
1535
+ "name": "starter_key",
1536
+ "type": "text",
1537
+ "primaryKey": false,
1538
+ "notNull": false
1539
+ },
1540
+ "updated_by": {
1541
+ "name": "updated_by",
1542
+ "type": "uuid",
1543
+ "primaryKey": false,
1544
+ "notNull": false
1545
+ },
1546
+ "created_at": {
1547
+ "name": "created_at",
1548
+ "type": "timestamp with time zone",
1549
+ "primaryKey": false,
1550
+ "notNull": true,
1551
+ "default": "now()"
1552
+ },
1553
+ "updated_at": {
1554
+ "name": "updated_at",
1555
+ "type": "timestamp with time zone",
1556
+ "primaryKey": false,
1557
+ "notNull": true,
1558
+ "default": "now()"
1559
+ }
1560
+ },
1561
+ "indexes": {
1562
+ "invoice_rules_starter_key": {
1563
+ "name": "invoice_rules_starter_key",
1564
+ "columns": [
1565
+ {
1566
+ "expression": "organisation_id",
1567
+ "isExpression": false,
1568
+ "asc": true,
1569
+ "nulls": "last"
1570
+ },
1571
+ {
1572
+ "expression": "starter_key",
1573
+ "isExpression": false,
1574
+ "asc": true,
1575
+ "nulls": "last"
1576
+ }
1577
+ ],
1578
+ "isUnique": true,
1579
+ "concurrently": false,
1580
+ "method": "btree",
1581
+ "with": {}
1582
+ }
1583
+ },
1584
+ "foreignKeys": {
1585
+ "invoice_rules_organisation_id_organisations_id_fk": {
1586
+ "name": "invoice_rules_organisation_id_organisations_id_fk",
1587
+ "tableFrom": "invoice_rules",
1588
+ "tableTo": "organisations",
1589
+ "columnsFrom": [
1590
+ "organisation_id"
1591
+ ],
1592
+ "columnsTo": [
1593
+ "id"
1594
+ ],
1595
+ "onDelete": "no action",
1596
+ "onUpdate": "no action"
1597
+ },
1598
+ "invoice_rules_updated_by_people_id_fk": {
1599
+ "name": "invoice_rules_updated_by_people_id_fk",
1600
+ "tableFrom": "invoice_rules",
1601
+ "tableTo": "people",
1602
+ "columnsFrom": [
1603
+ "updated_by"
1604
+ ],
1605
+ "columnsTo": [
1606
+ "id"
1607
+ ],
1608
+ "onDelete": "set null",
1609
+ "onUpdate": "no action"
1610
+ }
1611
+ },
1612
+ "compositePrimaryKeys": {},
1613
+ "uniqueConstraints": {},
1614
+ "policies": {},
1615
+ "checkConstraints": {
1616
+ "invoice_rules_trigger_valid": {
1617
+ "name": "invoice_rules_trigger_valid",
1618
+ "value": "\"invoice_rules\".\"trigger\" in ('job_ready')"
1619
+ },
1620
+ "invoice_rules_name_valid": {
1621
+ "name": "invoice_rules_name_valid",
1622
+ "value": "length(\"invoice_rules\".\"name\") between 1 and 120"
1623
+ }
1624
+ },
1625
+ "isRLSEnabled": false
1626
+ },
1627
+ "public.invoice_versions": {
1628
+ "name": "invoice_versions",
1629
+ "schema": "",
1630
+ "columns": {
1631
+ "id": {
1632
+ "name": "id",
1633
+ "type": "uuid",
1634
+ "primaryKey": true,
1635
+ "notNull": true,
1636
+ "default": "gen_random_uuid()"
1637
+ },
1638
+ "organisation_id": {
1639
+ "name": "organisation_id",
1640
+ "type": "uuid",
1641
+ "primaryKey": false,
1642
+ "notNull": true
1643
+ },
1644
+ "invoice_id": {
1645
+ "name": "invoice_id",
1646
+ "type": "uuid",
1647
+ "primaryKey": false,
1648
+ "notNull": true
1649
+ },
1650
+ "version": {
1651
+ "name": "version",
1652
+ "type": "integer",
1653
+ "primaryKey": false,
1654
+ "notNull": true
1655
+ },
1656
+ "issued_at": {
1657
+ "name": "issued_at",
1658
+ "type": "timestamp with time zone",
1659
+ "primaryKey": false,
1660
+ "notNull": true,
1661
+ "default": "now()"
1662
+ },
1663
+ "issued_by": {
1664
+ "name": "issued_by",
1665
+ "type": "text",
1666
+ "primaryKey": false,
1667
+ "notNull": true
1668
+ },
1669
+ "document": {
1670
+ "name": "document",
1671
+ "type": "jsonb",
1672
+ "primaryKey": false,
1673
+ "notNull": true
1674
+ }
1675
+ },
1676
+ "indexes": {},
1677
+ "foreignKeys": {
1678
+ "invoice_versions_invoice_same_org": {
1679
+ "name": "invoice_versions_invoice_same_org",
1680
+ "tableFrom": "invoice_versions",
1681
+ "tableTo": "invoices",
1682
+ "columnsFrom": [
1683
+ "organisation_id",
1684
+ "invoice_id"
1685
+ ],
1686
+ "columnsTo": [
1687
+ "organisation_id",
1688
+ "id"
1689
+ ],
1690
+ "onDelete": "no action",
1691
+ "onUpdate": "no action"
1692
+ }
1693
+ },
1694
+ "compositePrimaryKeys": {},
1695
+ "uniqueConstraints": {
1696
+ "invoice_versions_invoice_version": {
1697
+ "name": "invoice_versions_invoice_version",
1698
+ "nullsNotDistinct": false,
1699
+ "columns": [
1700
+ "invoice_id",
1701
+ "version"
1702
+ ]
1703
+ }
1704
+ },
1705
+ "policies": {},
1706
+ "checkConstraints": {
1707
+ "invoice_versions_version_positive": {
1708
+ "name": "invoice_versions_version_positive",
1709
+ "value": "\"invoice_versions\".\"version\" > 0"
1710
+ }
1711
+ },
1712
+ "isRLSEnabled": false
1713
+ },
1714
+ "public.invoices": {
1715
+ "name": "invoices",
1716
+ "schema": "",
1717
+ "columns": {
1718
+ "id": {
1719
+ "name": "id",
1720
+ "type": "uuid",
1721
+ "primaryKey": true,
1722
+ "notNull": true,
1723
+ "default": "gen_random_uuid()"
1724
+ },
1725
+ "organisation_id": {
1726
+ "name": "organisation_id",
1727
+ "type": "uuid",
1728
+ "primaryKey": false,
1729
+ "notNull": true
1730
+ },
1731
+ "contact_id": {
1732
+ "name": "contact_id",
1733
+ "type": "uuid",
1734
+ "primaryKey": false,
1735
+ "notNull": true
1736
+ },
1737
+ "number": {
1738
+ "name": "number",
1739
+ "type": "text",
1740
+ "primaryKey": false,
1741
+ "notNull": false
1742
+ },
1743
+ "status": {
1744
+ "name": "status",
1745
+ "type": "text",
1746
+ "primaryKey": false,
1747
+ "notNull": true,
1748
+ "default": "'draft'"
1749
+ },
1750
+ "issued_version": {
1751
+ "name": "issued_version",
1752
+ "type": "integer",
1753
+ "primaryKey": false,
1754
+ "notNull": true,
1755
+ "default": 0
1756
+ },
1757
+ "reference": {
1758
+ "name": "reference",
1759
+ "type": "text",
1760
+ "primaryKey": false,
1761
+ "notNull": false
1762
+ },
1763
+ "currency": {
1764
+ "name": "currency",
1765
+ "type": "text",
1766
+ "primaryKey": false,
1767
+ "notNull": true,
1768
+ "default": "'AUD'"
1769
+ },
1770
+ "issue_date": {
1771
+ "name": "issue_date",
1772
+ "type": "date",
1773
+ "primaryKey": false,
1774
+ "notNull": false
1775
+ },
1776
+ "due_date": {
1777
+ "name": "due_date",
1778
+ "type": "date",
1779
+ "primaryKey": false,
1780
+ "notNull": false
1781
+ },
1782
+ "subtotal_cents": {
1783
+ "name": "subtotal_cents",
1784
+ "type": "integer",
1785
+ "primaryKey": false,
1786
+ "notNull": true,
1787
+ "default": 0
1788
+ },
1789
+ "tax_cents": {
1790
+ "name": "tax_cents",
1791
+ "type": "integer",
1792
+ "primaryKey": false,
1793
+ "notNull": true,
1794
+ "default": 0
1795
+ },
1796
+ "total_cents": {
1797
+ "name": "total_cents",
1798
+ "type": "integer",
1799
+ "primaryKey": false,
1800
+ "notNull": true,
1801
+ "default": 0
1802
+ },
1803
+ "ready_at": {
1804
+ "name": "ready_at",
1805
+ "type": "timestamp with time zone",
1806
+ "primaryKey": false,
1807
+ "notNull": false
1808
+ },
1809
+ "ready_by": {
1810
+ "name": "ready_by",
1811
+ "type": "uuid",
1812
+ "primaryKey": false,
1813
+ "notNull": false
1814
+ },
1815
+ "send_state": {
1816
+ "name": "send_state",
1817
+ "type": "text",
1818
+ "primaryKey": false,
1819
+ "notNull": false
1820
+ },
1821
+ "send_error": {
1822
+ "name": "send_error",
1823
+ "type": "jsonb",
1824
+ "primaryKey": false,
1825
+ "notNull": false
1826
+ },
1827
+ "send_requested_by": {
1828
+ "name": "send_requested_by",
1829
+ "type": "uuid",
1830
+ "primaryKey": false,
1831
+ "notNull": false
1832
+ },
1833
+ "send_updated_at": {
1834
+ "name": "send_updated_at",
1835
+ "type": "timestamp with time zone",
1836
+ "primaryKey": false,
1837
+ "notNull": false
1838
+ },
1839
+ "created_at": {
1840
+ "name": "created_at",
1841
+ "type": "timestamp with time zone",
1842
+ "primaryKey": false,
1843
+ "notNull": true,
1844
+ "default": "now()"
1845
+ },
1846
+ "updated_at": {
1847
+ "name": "updated_at",
1848
+ "type": "timestamp with time zone",
1849
+ "primaryKey": false,
1850
+ "notNull": true,
1851
+ "default": "now()"
1852
+ }
1853
+ },
1854
+ "indexes": {},
1855
+ "foreignKeys": {
1856
+ "invoices_organisation_id_organisations_id_fk": {
1857
+ "name": "invoices_organisation_id_organisations_id_fk",
1858
+ "tableFrom": "invoices",
1859
+ "tableTo": "organisations",
1860
+ "columnsFrom": [
1861
+ "organisation_id"
1862
+ ],
1863
+ "columnsTo": [
1864
+ "id"
1865
+ ],
1866
+ "onDelete": "no action",
1867
+ "onUpdate": "no action"
1868
+ },
1869
+ "invoices_ready_by_people_id_fk": {
1870
+ "name": "invoices_ready_by_people_id_fk",
1871
+ "tableFrom": "invoices",
1872
+ "tableTo": "people",
1873
+ "columnsFrom": [
1874
+ "ready_by"
1875
+ ],
1876
+ "columnsTo": [
1877
+ "id"
1878
+ ],
1879
+ "onDelete": "set null",
1880
+ "onUpdate": "no action"
1881
+ },
1882
+ "invoices_send_requested_by_people_id_fk": {
1883
+ "name": "invoices_send_requested_by_people_id_fk",
1884
+ "tableFrom": "invoices",
1885
+ "tableTo": "people",
1886
+ "columnsFrom": [
1887
+ "send_requested_by"
1888
+ ],
1889
+ "columnsTo": [
1890
+ "id"
1891
+ ],
1892
+ "onDelete": "set null",
1893
+ "onUpdate": "no action"
1894
+ },
1895
+ "invoices_contact_same_org": {
1896
+ "name": "invoices_contact_same_org",
1897
+ "tableFrom": "invoices",
1898
+ "tableTo": "contacts",
1899
+ "columnsFrom": [
1900
+ "organisation_id",
1901
+ "contact_id"
1902
+ ],
1903
+ "columnsTo": [
1904
+ "organisation_id",
1905
+ "id"
1906
+ ],
1907
+ "onDelete": "no action",
1908
+ "onUpdate": "no action"
1909
+ }
1910
+ },
1911
+ "compositePrimaryKeys": {},
1912
+ "uniqueConstraints": {
1913
+ "invoices_org_id": {
1914
+ "name": "invoices_org_id",
1915
+ "nullsNotDistinct": false,
1916
+ "columns": [
1917
+ "organisation_id",
1918
+ "id"
1919
+ ]
1920
+ },
1921
+ "invoices_org_number": {
1922
+ "name": "invoices_org_number",
1923
+ "nullsNotDistinct": false,
1924
+ "columns": [
1925
+ "organisation_id",
1926
+ "number"
1927
+ ]
1928
+ }
1929
+ },
1930
+ "policies": {},
1931
+ "checkConstraints": {
1932
+ "invoices_status_valid": {
1933
+ "name": "invoices_status_valid",
1934
+ "value": "\"invoices\".\"status\" in ('draft', 'issued', 'void')"
1935
+ },
1936
+ "invoices_issued_has_number": {
1937
+ "name": "invoices_issued_has_number",
1938
+ "value": "\"invoices\".\"status\" = 'draft' or \"invoices\".\"number\" is not null"
1939
+ },
1940
+ "invoices_send_state_valid": {
1941
+ "name": "invoices_send_state_valid",
1942
+ "value": "\"invoices\".\"send_state\" is null or \"invoices\".\"send_state\" in ('queued', 'sent', 'failed')"
1943
+ }
1944
+ },
1945
+ "isRLSEnabled": false
1946
+ },
1947
+ "public.invoicing_settings": {
1948
+ "name": "invoicing_settings",
1949
+ "schema": "",
1950
+ "columns": {
1951
+ "organisation_id": {
1952
+ "name": "organisation_id",
1953
+ "type": "uuid",
1954
+ "primaryKey": true,
1955
+ "notNull": true
1956
+ },
1957
+ "send_mode": {
1958
+ "name": "send_mode",
1959
+ "type": "text",
1960
+ "primaryKey": false,
1961
+ "notNull": true,
1962
+ "default": "'accounting_draft'"
1963
+ },
1964
+ "stale_days": {
1965
+ "name": "stale_days",
1966
+ "type": "integer",
1967
+ "primaryKey": false,
1968
+ "notNull": true,
1969
+ "default": 90
1970
+ },
1971
+ "payment_terms_days": {
1972
+ "name": "payment_terms_days",
1973
+ "type": "integer",
1974
+ "primaryKey": false,
1975
+ "notNull": true,
1976
+ "default": 30
1977
+ },
1978
+ "require_practitioner": {
1979
+ "name": "require_practitioner",
1980
+ "type": "boolean",
1981
+ "primaryKey": false,
1982
+ "notNull": true,
1983
+ "default": false
1984
+ },
1985
+ "rush_item_code": {
1986
+ "name": "rush_item_code",
1987
+ "type": "text",
1988
+ "primaryKey": false,
1989
+ "notNull": false
1990
+ },
1991
+ "rush_percent": {
1992
+ "name": "rush_percent",
1993
+ "type": "integer",
1994
+ "primaryKey": false,
1995
+ "notNull": true,
1996
+ "default": 20
1997
+ },
1998
+ "reference_template": {
1999
+ "name": "reference_template",
2000
+ "type": "text",
2001
+ "primaryKey": false,
2002
+ "notNull": true,
2003
+ "default": "'{practitioner} - {patient}'"
2004
+ },
2005
+ "rules_seeded": {
2006
+ "name": "rules_seeded",
2007
+ "type": "boolean",
2008
+ "primaryKey": false,
2009
+ "notNull": true,
2010
+ "default": false
2011
+ },
2012
+ "updated_by": {
2013
+ "name": "updated_by",
2014
+ "type": "uuid",
2015
+ "primaryKey": false,
2016
+ "notNull": false
2017
+ },
2018
+ "updated_at": {
2019
+ "name": "updated_at",
2020
+ "type": "timestamp with time zone",
2021
+ "primaryKey": false,
2022
+ "notNull": true,
2023
+ "default": "now()"
2024
+ }
2025
+ },
2026
+ "indexes": {},
2027
+ "foreignKeys": {
2028
+ "invoicing_settings_organisation_id_organisations_id_fk": {
2029
+ "name": "invoicing_settings_organisation_id_organisations_id_fk",
2030
+ "tableFrom": "invoicing_settings",
2031
+ "tableTo": "organisations",
2032
+ "columnsFrom": [
2033
+ "organisation_id"
2034
+ ],
2035
+ "columnsTo": [
2036
+ "id"
2037
+ ],
2038
+ "onDelete": "no action",
2039
+ "onUpdate": "no action"
2040
+ },
2041
+ "invoicing_settings_updated_by_people_id_fk": {
2042
+ "name": "invoicing_settings_updated_by_people_id_fk",
2043
+ "tableFrom": "invoicing_settings",
2044
+ "tableTo": "people",
2045
+ "columnsFrom": [
2046
+ "updated_by"
2047
+ ],
2048
+ "columnsTo": [
2049
+ "id"
2050
+ ],
2051
+ "onDelete": "set null",
2052
+ "onUpdate": "no action"
2053
+ }
2054
+ },
2055
+ "compositePrimaryKeys": {},
2056
+ "uniqueConstraints": {},
2057
+ "policies": {},
2058
+ "checkConstraints": {
2059
+ "invoicing_settings_send_mode_valid": {
2060
+ "name": "invoicing_settings_send_mode_valid",
2061
+ "value": "send_mode in ('accounting_draft', 'approve_and_email')"
2062
+ },
2063
+ "invoicing_settings_stale_days_valid": {
2064
+ "name": "invoicing_settings_stale_days_valid",
2065
+ "value": "\"invoicing_settings\".\"stale_days\" between 1 and 3650"
2066
+ },
2067
+ "invoicing_settings_terms_valid": {
2068
+ "name": "invoicing_settings_terms_valid",
2069
+ "value": "\"invoicing_settings\".\"payment_terms_days\" between 0 and 365"
2070
+ },
2071
+ "invoicing_settings_rush_valid": {
2072
+ "name": "invoicing_settings_rush_valid",
2073
+ "value": "\"invoicing_settings\".\"rush_percent\" between 0 and 100"
2074
+ }
2075
+ },
2076
+ "isRLSEnabled": false
2077
+ },
2078
+ "public.job_field_events": {
2079
+ "name": "job_field_events",
2080
+ "schema": "",
2081
+ "columns": {
2082
+ "id": {
2083
+ "name": "id",
2084
+ "type": "uuid",
2085
+ "primaryKey": true,
2086
+ "notNull": true,
2087
+ "default": "gen_random_uuid()"
2088
+ },
2089
+ "organisation_id": {
2090
+ "name": "organisation_id",
2091
+ "type": "uuid",
2092
+ "primaryKey": false,
2093
+ "notNull": true
2094
+ },
2095
+ "field_id": {
2096
+ "name": "field_id",
2097
+ "type": "uuid",
2098
+ "primaryKey": false,
2099
+ "notNull": true
2100
+ },
2101
+ "source_system": {
2102
+ "name": "source_system",
2103
+ "type": "text",
2104
+ "primaryKey": false,
2105
+ "notNull": true
2106
+ },
2107
+ "source_job_ref": {
2108
+ "name": "source_job_ref",
2109
+ "type": "text",
2110
+ "primaryKey": false,
2111
+ "notNull": true
2112
+ },
2113
+ "from_value": {
2114
+ "name": "from_value",
2115
+ "type": "jsonb",
2116
+ "primaryKey": false,
2117
+ "notNull": false
2118
+ },
2119
+ "to_value": {
2120
+ "name": "to_value",
2121
+ "type": "jsonb",
2122
+ "primaryKey": false,
2123
+ "notNull": false
2124
+ },
2125
+ "actor": {
2126
+ "name": "actor",
2127
+ "type": "uuid",
2128
+ "primaryKey": false,
2129
+ "notNull": false
2130
+ },
2131
+ "created_at": {
2132
+ "name": "created_at",
2133
+ "type": "timestamp with time zone",
2134
+ "primaryKey": false,
2135
+ "notNull": true,
2136
+ "default": "now()"
2137
+ }
2138
+ },
2139
+ "indexes": {
2140
+ "job_field_events_job": {
2141
+ "name": "job_field_events_job",
2142
+ "columns": [
2143
+ {
2144
+ "expression": "organisation_id",
2145
+ "isExpression": false,
2146
+ "asc": true,
2147
+ "nulls": "last"
2148
+ },
2149
+ {
2150
+ "expression": "source_system",
2151
+ "isExpression": false,
2152
+ "asc": true,
2153
+ "nulls": "last"
2154
+ },
2155
+ {
2156
+ "expression": "source_job_ref",
2157
+ "isExpression": false,
2158
+ "asc": true,
2159
+ "nulls": "last"
2160
+ },
2161
+ {
2162
+ "expression": "created_at",
2163
+ "isExpression": false,
2164
+ "asc": true,
2165
+ "nulls": "last"
2166
+ }
2167
+ ],
2168
+ "isUnique": false,
2169
+ "concurrently": false,
2170
+ "method": "btree",
2171
+ "with": {}
2172
+ }
2173
+ },
2174
+ "foreignKeys": {
2175
+ "job_field_events_organisation_id_organisations_id_fk": {
2176
+ "name": "job_field_events_organisation_id_organisations_id_fk",
2177
+ "tableFrom": "job_field_events",
2178
+ "tableTo": "organisations",
2179
+ "columnsFrom": [
2180
+ "organisation_id"
2181
+ ],
2182
+ "columnsTo": [
2183
+ "id"
2184
+ ],
2185
+ "onDelete": "no action",
2186
+ "onUpdate": "no action"
2187
+ },
2188
+ "job_field_events_actor_people_id_fk": {
2189
+ "name": "job_field_events_actor_people_id_fk",
2190
+ "tableFrom": "job_field_events",
2191
+ "tableTo": "people",
2192
+ "columnsFrom": [
2193
+ "actor"
2194
+ ],
2195
+ "columnsTo": [
2196
+ "id"
2197
+ ],
2198
+ "onDelete": "set null",
2199
+ "onUpdate": "no action"
2200
+ },
2201
+ "job_field_events_field_same_org": {
2202
+ "name": "job_field_events_field_same_org",
2203
+ "tableFrom": "job_field_events",
2204
+ "tableTo": "job_fields",
2205
+ "columnsFrom": [
2206
+ "organisation_id",
2207
+ "field_id"
2208
+ ],
2209
+ "columnsTo": [
2210
+ "organisation_id",
2211
+ "id"
2212
+ ],
2213
+ "onDelete": "cascade",
2214
+ "onUpdate": "no action"
2215
+ }
2216
+ },
2217
+ "compositePrimaryKeys": {},
2218
+ "uniqueConstraints": {},
2219
+ "policies": {},
2220
+ "checkConstraints": {},
2221
+ "isRLSEnabled": false
2222
+ },
2223
+ "public.job_field_settings": {
2224
+ "name": "job_field_settings",
2225
+ "schema": "",
2226
+ "columns": {
2227
+ "organisation_id": {
2228
+ "name": "organisation_id",
2229
+ "type": "uuid",
2230
+ "primaryKey": true,
2231
+ "notNull": true
2232
+ },
2233
+ "group_colors": {
2234
+ "name": "group_colors",
2235
+ "type": "jsonb",
2236
+ "primaryKey": false,
2237
+ "notNull": true,
2238
+ "default": "'{}'::jsonb"
2239
+ },
2240
+ "assignee_made_at": {
2241
+ "name": "assignee_made_at",
2242
+ "type": "timestamp with time zone",
2243
+ "primaryKey": false,
2244
+ "notNull": false
2245
+ },
2246
+ "updated_by": {
2247
+ "name": "updated_by",
2248
+ "type": "uuid",
2249
+ "primaryKey": false,
2250
+ "notNull": false
2251
+ },
2252
+ "updated_at": {
2253
+ "name": "updated_at",
2254
+ "type": "timestamp with time zone",
2255
+ "primaryKey": false,
2256
+ "notNull": true,
2257
+ "default": "now()"
2258
+ }
2259
+ },
2260
+ "indexes": {},
2261
+ "foreignKeys": {
2262
+ "job_field_settings_organisation_id_organisations_id_fk": {
2263
+ "name": "job_field_settings_organisation_id_organisations_id_fk",
2264
+ "tableFrom": "job_field_settings",
2265
+ "tableTo": "organisations",
2266
+ "columnsFrom": [
2267
+ "organisation_id"
2268
+ ],
2269
+ "columnsTo": [
2270
+ "id"
2271
+ ],
2272
+ "onDelete": "no action",
2273
+ "onUpdate": "no action"
2274
+ },
2275
+ "job_field_settings_updated_by_people_id_fk": {
2276
+ "name": "job_field_settings_updated_by_people_id_fk",
2277
+ "tableFrom": "job_field_settings",
2278
+ "tableTo": "people",
2279
+ "columnsFrom": [
2280
+ "updated_by"
2281
+ ],
2282
+ "columnsTo": [
2283
+ "id"
2284
+ ],
2285
+ "onDelete": "set null",
2286
+ "onUpdate": "no action"
2287
+ }
2288
+ },
2289
+ "compositePrimaryKeys": {},
2290
+ "uniqueConstraints": {},
2291
+ "policies": {},
2292
+ "checkConstraints": {},
2293
+ "isRLSEnabled": false
2294
+ },
2295
+ "public.job_field_values": {
2296
+ "name": "job_field_values",
2297
+ "schema": "",
2298
+ "columns": {
2299
+ "organisation_id": {
2300
+ "name": "organisation_id",
2301
+ "type": "uuid",
2302
+ "primaryKey": false,
2303
+ "notNull": true
2304
+ },
2305
+ "field_id": {
2306
+ "name": "field_id",
2307
+ "type": "uuid",
2308
+ "primaryKey": false,
2309
+ "notNull": true
2310
+ },
2311
+ "source_system": {
2312
+ "name": "source_system",
2313
+ "type": "text",
2314
+ "primaryKey": false,
2315
+ "notNull": true
2316
+ },
2317
+ "source_job_ref": {
2318
+ "name": "source_job_ref",
2319
+ "type": "text",
2320
+ "primaryKey": false,
2321
+ "notNull": true
2322
+ },
2323
+ "value": {
2324
+ "name": "value",
2325
+ "type": "jsonb",
2326
+ "primaryKey": false,
2327
+ "notNull": true
2328
+ },
2329
+ "updated_by": {
2330
+ "name": "updated_by",
2331
+ "type": "uuid",
2332
+ "primaryKey": false,
2333
+ "notNull": false
2334
+ },
2335
+ "updated_at": {
2336
+ "name": "updated_at",
2337
+ "type": "timestamp with time zone",
2338
+ "primaryKey": false,
2339
+ "notNull": true,
2340
+ "default": "now()"
2341
+ }
2342
+ },
2343
+ "indexes": {
2344
+ "job_field_values_job": {
2345
+ "name": "job_field_values_job",
2346
+ "columns": [
2347
+ {
2348
+ "expression": "organisation_id",
2349
+ "isExpression": false,
2350
+ "asc": true,
2351
+ "nulls": "last"
2352
+ },
2353
+ {
2354
+ "expression": "source_system",
2355
+ "isExpression": false,
2356
+ "asc": true,
2357
+ "nulls": "last"
2358
+ },
2359
+ {
2360
+ "expression": "source_job_ref",
2361
+ "isExpression": false,
2362
+ "asc": true,
2363
+ "nulls": "last"
2364
+ }
2365
+ ],
2366
+ "isUnique": false,
2367
+ "concurrently": false,
2368
+ "method": "btree",
2369
+ "with": {}
2370
+ }
2371
+ },
2372
+ "foreignKeys": {
2373
+ "job_field_values_organisation_id_organisations_id_fk": {
2374
+ "name": "job_field_values_organisation_id_organisations_id_fk",
2375
+ "tableFrom": "job_field_values",
2376
+ "tableTo": "organisations",
2377
+ "columnsFrom": [
2378
+ "organisation_id"
2379
+ ],
2380
+ "columnsTo": [
2381
+ "id"
2382
+ ],
2383
+ "onDelete": "no action",
2384
+ "onUpdate": "no action"
2385
+ },
2386
+ "job_field_values_updated_by_people_id_fk": {
2387
+ "name": "job_field_values_updated_by_people_id_fk",
2388
+ "tableFrom": "job_field_values",
2389
+ "tableTo": "people",
2390
+ "columnsFrom": [
2391
+ "updated_by"
2392
+ ],
2393
+ "columnsTo": [
2394
+ "id"
2395
+ ],
2396
+ "onDelete": "set null",
2397
+ "onUpdate": "no action"
2398
+ },
2399
+ "job_field_values_field_same_org": {
2400
+ "name": "job_field_values_field_same_org",
2401
+ "tableFrom": "job_field_values",
2402
+ "tableTo": "job_fields",
2403
+ "columnsFrom": [
2404
+ "organisation_id",
2405
+ "field_id"
2406
+ ],
2407
+ "columnsTo": [
2408
+ "organisation_id",
2409
+ "id"
2410
+ ],
2411
+ "onDelete": "cascade",
2412
+ "onUpdate": "no action"
2413
+ }
2414
+ },
2415
+ "compositePrimaryKeys": {
2416
+ "job_field_values_organisation_id_field_id_source_system_source_job_ref_pk": {
2417
+ "name": "job_field_values_organisation_id_field_id_source_system_source_job_ref_pk",
2418
+ "columns": [
2419
+ "organisation_id",
2420
+ "field_id",
2421
+ "source_system",
2422
+ "source_job_ref"
2423
+ ]
2424
+ }
2425
+ },
2426
+ "uniqueConstraints": {},
2427
+ "policies": {},
2428
+ "checkConstraints": {},
2429
+ "isRLSEnabled": false
2430
+ },
2431
+ "public.job_fields": {
2432
+ "name": "job_fields",
2433
+ "schema": "",
2434
+ "columns": {
2435
+ "id": {
2436
+ "name": "id",
2437
+ "type": "uuid",
2438
+ "primaryKey": true,
2439
+ "notNull": true,
2440
+ "default": "gen_random_uuid()"
2441
+ },
2442
+ "organisation_id": {
2443
+ "name": "organisation_id",
2444
+ "type": "uuid",
2445
+ "primaryKey": false,
2446
+ "notNull": true
2447
+ },
2448
+ "name": {
2449
+ "name": "name",
2450
+ "type": "text",
2451
+ "primaryKey": false,
2452
+ "notNull": true
2453
+ },
2454
+ "type": {
2455
+ "name": "type",
2456
+ "type": "text",
2457
+ "primaryKey": false,
2458
+ "notNull": true
2459
+ },
2460
+ "options": {
2461
+ "name": "options",
2462
+ "type": "jsonb",
2463
+ "primaryKey": false,
2464
+ "notNull": true,
2465
+ "default": "'[]'::jsonb"
2466
+ },
2467
+ "color": {
2468
+ "name": "color",
2469
+ "type": "text",
2470
+ "primaryKey": false,
2471
+ "notNull": false
2472
+ },
2473
+ "position": {
2474
+ "name": "position",
2475
+ "type": "integer",
2476
+ "primaryKey": false,
2477
+ "notNull": true
2478
+ },
2479
+ "archived_at": {
2480
+ "name": "archived_at",
2481
+ "type": "timestamp with time zone",
2482
+ "primaryKey": false,
2483
+ "notNull": false
2484
+ },
2485
+ "created_by": {
2486
+ "name": "created_by",
2487
+ "type": "uuid",
2488
+ "primaryKey": false,
2489
+ "notNull": false
2490
+ },
2491
+ "updated_by": {
2492
+ "name": "updated_by",
2493
+ "type": "uuid",
2494
+ "primaryKey": false,
2495
+ "notNull": false
2496
+ },
2497
+ "created_at": {
2498
+ "name": "created_at",
2499
+ "type": "timestamp with time zone",
2500
+ "primaryKey": false,
2501
+ "notNull": true,
2502
+ "default": "now()"
2503
+ },
2504
+ "updated_at": {
2505
+ "name": "updated_at",
2506
+ "type": "timestamp with time zone",
2507
+ "primaryKey": false,
2508
+ "notNull": true,
2509
+ "default": "now()"
2510
+ }
2511
+ },
2512
+ "indexes": {},
2513
+ "foreignKeys": {
2514
+ "job_fields_organisation_id_organisations_id_fk": {
2515
+ "name": "job_fields_organisation_id_organisations_id_fk",
2516
+ "tableFrom": "job_fields",
2517
+ "tableTo": "organisations",
2518
+ "columnsFrom": [
2519
+ "organisation_id"
2520
+ ],
2521
+ "columnsTo": [
2522
+ "id"
2523
+ ],
2524
+ "onDelete": "no action",
2525
+ "onUpdate": "no action"
2526
+ },
2527
+ "job_fields_created_by_people_id_fk": {
2528
+ "name": "job_fields_created_by_people_id_fk",
2529
+ "tableFrom": "job_fields",
2530
+ "tableTo": "people",
2531
+ "columnsFrom": [
2532
+ "created_by"
2533
+ ],
2534
+ "columnsTo": [
2535
+ "id"
2536
+ ],
2537
+ "onDelete": "set null",
2538
+ "onUpdate": "no action"
2539
+ },
2540
+ "job_fields_updated_by_people_id_fk": {
2541
+ "name": "job_fields_updated_by_people_id_fk",
2542
+ "tableFrom": "job_fields",
2543
+ "tableTo": "people",
2544
+ "columnsFrom": [
2545
+ "updated_by"
2546
+ ],
2547
+ "columnsTo": [
2548
+ "id"
2549
+ ],
2550
+ "onDelete": "set null",
2551
+ "onUpdate": "no action"
2552
+ }
2553
+ },
2554
+ "compositePrimaryKeys": {},
2555
+ "uniqueConstraints": {
2556
+ "job_fields_org_id": {
2557
+ "name": "job_fields_org_id",
2558
+ "nullsNotDistinct": false,
2559
+ "columns": [
2560
+ "organisation_id",
2561
+ "id"
2562
+ ]
2563
+ }
2564
+ },
2565
+ "policies": {},
2566
+ "checkConstraints": {
2567
+ "job_fields_type_valid": {
2568
+ "name": "job_fields_type_valid",
2569
+ "value": "\"job_fields\".\"type\" in ('dropdown', 'person', 'checkbox', 'date', 'number', 'text')"
2570
+ },
2571
+ "job_fields_name_valid": {
2572
+ "name": "job_fields_name_valid",
2573
+ "value": "length(\"job_fields\".\"name\") between 1 and 60"
2574
+ },
2575
+ "job_fields_color_valid": {
2576
+ "name": "job_fields_color_valid",
2577
+ "value": "\"job_fields\".\"color\" is null or \"job_fields\".\"color\" in ('gray', 'blue', 'teal', 'green', 'amber', 'red', 'purple', 'pink')"
2578
+ }
2579
+ },
2580
+ "isRLSEnabled": false
2581
+ },
2582
+ "public.line_mappings": {
2583
+ "name": "line_mappings",
2584
+ "schema": "",
2585
+ "columns": {
2586
+ "id": {
2587
+ "name": "id",
2588
+ "type": "uuid",
2589
+ "primaryKey": true,
2590
+ "notNull": true,
2591
+ "default": "gen_random_uuid()"
2592
+ },
2593
+ "organisation_id": {
2594
+ "name": "organisation_id",
2595
+ "type": "uuid",
2596
+ "primaryKey": false,
2597
+ "notNull": true
2598
+ },
2599
+ "kind": {
2600
+ "name": "kind",
2601
+ "type": "text",
2602
+ "primaryKey": false,
2603
+ "notNull": true
2604
+ },
2605
+ "match": {
2606
+ "name": "match",
2607
+ "type": "text",
2608
+ "primaryKey": false,
2609
+ "notNull": true,
2610
+ "default": "'exact'"
2611
+ },
2612
+ "label": {
2613
+ "name": "label",
2614
+ "type": "text",
2615
+ "primaryKey": false,
2616
+ "notNull": true
2617
+ },
2618
+ "unit_amount_cents": {
2619
+ "name": "unit_amount_cents",
2620
+ "type": "integer",
2621
+ "primaryKey": false,
2622
+ "notNull": false
2623
+ },
2624
+ "item_code": {
2625
+ "name": "item_code",
2626
+ "type": "text",
2627
+ "primaryKey": false,
2628
+ "notNull": false
2629
+ },
2630
+ "account_code": {
2631
+ "name": "account_code",
2632
+ "type": "text",
2633
+ "primaryKey": false,
2634
+ "notNull": false
2635
+ },
2636
+ "tax_code": {
2637
+ "name": "tax_code",
2638
+ "type": "text",
2639
+ "primaryKey": false,
2640
+ "notNull": false
2641
+ },
2642
+ "description": {
2643
+ "name": "description",
2644
+ "type": "text",
2645
+ "primaryKey": false,
2646
+ "notNull": false
2647
+ },
2648
+ "enabled": {
2649
+ "name": "enabled",
2650
+ "type": "boolean",
2651
+ "primaryKey": false,
2652
+ "notNull": true,
2653
+ "default": true
2654
+ },
2655
+ "origin": {
2656
+ "name": "origin",
2657
+ "type": "text",
2658
+ "primaryKey": false,
2659
+ "notNull": true,
2660
+ "default": "'person'"
2661
+ },
2662
+ "updated_by": {
2663
+ "name": "updated_by",
2664
+ "type": "uuid",
2665
+ "primaryKey": false,
2666
+ "notNull": false
2667
+ },
2668
+ "created_at": {
2669
+ "name": "created_at",
2670
+ "type": "timestamp with time zone",
2671
+ "primaryKey": false,
2672
+ "notNull": true,
2673
+ "default": "now()"
2674
+ },
2675
+ "updated_at": {
2676
+ "name": "updated_at",
2677
+ "type": "timestamp with time zone",
2678
+ "primaryKey": false,
2679
+ "notNull": true,
2680
+ "default": "now()"
2681
+ }
2682
+ },
2683
+ "indexes": {
2684
+ "line_mappings_unique": {
2685
+ "name": "line_mappings_unique",
2686
+ "columns": [
2687
+ {
2688
+ "expression": "organisation_id",
2689
+ "isExpression": false,
2690
+ "asc": true,
2691
+ "nulls": "last"
2692
+ },
2693
+ {
2694
+ "expression": "kind",
2695
+ "isExpression": false,
2696
+ "asc": true,
2697
+ "nulls": "last"
2698
+ },
2699
+ {
2700
+ "expression": "match",
2701
+ "isExpression": false,
2702
+ "asc": true,
2703
+ "nulls": "last"
2704
+ },
2705
+ {
2706
+ "expression": "label",
2707
+ "isExpression": false,
2708
+ "asc": true,
2709
+ "nulls": "last"
2710
+ },
2711
+ {
2712
+ "expression": "coalesce(\"unit_amount_cents\", -1)",
2713
+ "asc": true,
2714
+ "isExpression": true,
2715
+ "nulls": "last"
2716
+ }
2717
+ ],
2718
+ "isUnique": true,
2719
+ "concurrently": false,
2720
+ "method": "btree",
2721
+ "with": {}
2722
+ }
2723
+ },
2724
+ "foreignKeys": {
2725
+ "line_mappings_organisation_id_organisations_id_fk": {
2726
+ "name": "line_mappings_organisation_id_organisations_id_fk",
2727
+ "tableFrom": "line_mappings",
2728
+ "tableTo": "organisations",
2729
+ "columnsFrom": [
2730
+ "organisation_id"
2731
+ ],
2732
+ "columnsTo": [
2733
+ "id"
2734
+ ],
2735
+ "onDelete": "no action",
2736
+ "onUpdate": "no action"
2737
+ },
2738
+ "line_mappings_updated_by_people_id_fk": {
2739
+ "name": "line_mappings_updated_by_people_id_fk",
2740
+ "tableFrom": "line_mappings",
2741
+ "tableTo": "people",
2742
+ "columnsFrom": [
2743
+ "updated_by"
2744
+ ],
2745
+ "columnsTo": [
2746
+ "id"
2747
+ ],
2748
+ "onDelete": "set null",
2749
+ "onUpdate": "no action"
2750
+ }
2751
+ },
2752
+ "compositePrimaryKeys": {},
2753
+ "uniqueConstraints": {},
2754
+ "policies": {},
2755
+ "checkConstraints": {
2756
+ "line_mappings_kind_valid": {
2757
+ "name": "line_mappings_kind_valid",
2758
+ "value": "\"line_mappings\".\"kind\" in ('alias', 'price_alias', 'saved', 'account')"
2759
+ },
2760
+ "line_mappings_match_valid": {
2761
+ "name": "line_mappings_match_valid",
2762
+ "value": "\"line_mappings\".\"match\" in ('exact', 'starts_with')"
2763
+ },
2764
+ "line_mappings_tax_code_valid": {
2765
+ "name": "line_mappings_tax_code_valid",
2766
+ "value": "\"line_mappings\".\"tax_code\" is null or \"line_mappings\".\"tax_code\" in ('GST', 'GST_FREE')"
2767
+ },
2768
+ "line_mappings_target": {
2769
+ "name": "line_mappings_target",
2770
+ "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)"
2771
+ },
2772
+ "line_mappings_price": {
2773
+ "name": "line_mappings_price",
2774
+ "value": "\"line_mappings\".\"kind\" not in ('price_alias', 'saved') or \"line_mappings\".\"unit_amount_cents\" is not null"
2775
+ },
2776
+ "line_mappings_label_valid": {
2777
+ "name": "line_mappings_label_valid",
2778
+ "value": "length(\"line_mappings\".\"label\") between 1 and 200"
2779
+ }
2780
+ },
2781
+ "isRLSEnabled": false
2782
+ },
2783
+ "public.link_rejections": {
2784
+ "name": "link_rejections",
2785
+ "schema": "",
2786
+ "columns": {
2787
+ "organisation_id": {
2788
+ "name": "organisation_id",
2789
+ "type": "uuid",
2790
+ "primaryKey": false,
2791
+ "notNull": true
2792
+ },
2793
+ "obligation_id": {
2794
+ "name": "obligation_id",
2795
+ "type": "uuid",
2796
+ "primaryKey": false,
2797
+ "notNull": true
2798
+ },
2799
+ "system": {
2800
+ "name": "system",
2801
+ "type": "text",
2802
+ "primaryKey": false,
2803
+ "notNull": true
2804
+ },
2805
+ "external_id": {
2806
+ "name": "external_id",
2807
+ "type": "text",
2808
+ "primaryKey": false,
2809
+ "notNull": true
2810
+ },
2811
+ "actor": {
2812
+ "name": "actor",
2813
+ "type": "text",
2814
+ "primaryKey": false,
2815
+ "notNull": true
2816
+ },
2817
+ "created_at": {
2818
+ "name": "created_at",
2819
+ "type": "timestamp with time zone",
2820
+ "primaryKey": false,
2821
+ "notNull": true,
2822
+ "default": "now()"
2823
+ }
2824
+ },
2825
+ "indexes": {},
2826
+ "foreignKeys": {
2827
+ "link_rejections_organisation_id_organisations_id_fk": {
2828
+ "name": "link_rejections_organisation_id_organisations_id_fk",
2829
+ "tableFrom": "link_rejections",
2830
+ "tableTo": "organisations",
2831
+ "columnsFrom": [
2832
+ "organisation_id"
2833
+ ],
2834
+ "columnsTo": [
2835
+ "id"
2836
+ ],
2837
+ "onDelete": "no action",
2838
+ "onUpdate": "no action"
2839
+ },
2840
+ "link_rejections_obligation_same_org": {
2841
+ "name": "link_rejections_obligation_same_org",
2842
+ "tableFrom": "link_rejections",
2843
+ "tableTo": "billing_obligations",
2844
+ "columnsFrom": [
2845
+ "organisation_id",
2846
+ "obligation_id"
2847
+ ],
2848
+ "columnsTo": [
2849
+ "organisation_id",
2850
+ "id"
2851
+ ],
2852
+ "onDelete": "no action",
2853
+ "onUpdate": "no action"
2854
+ }
2855
+ },
2856
+ "compositePrimaryKeys": {
2857
+ "link_rejections_pk": {
2858
+ "name": "link_rejections_pk",
2859
+ "columns": [
2860
+ "organisation_id",
2861
+ "obligation_id",
2862
+ "system",
2863
+ "external_id"
2864
+ ]
2865
+ }
2866
+ },
2867
+ "uniqueConstraints": {},
2868
+ "policies": {},
2869
+ "checkConstraints": {},
2870
+ "isRLSEnabled": false
2871
+ },
2872
+ "public.link_suggestions": {
2873
+ "name": "link_suggestions",
2874
+ "schema": "",
2875
+ "columns": {
2876
+ "id": {
2877
+ "name": "id",
2878
+ "type": "uuid",
2879
+ "primaryKey": true,
2880
+ "notNull": true,
2881
+ "default": "gen_random_uuid()"
2882
+ },
2883
+ "organisation_id": {
2884
+ "name": "organisation_id",
2885
+ "type": "uuid",
2886
+ "primaryKey": false,
2887
+ "notNull": true
2888
+ },
2889
+ "obligation_id": {
2890
+ "name": "obligation_id",
2891
+ "type": "uuid",
2892
+ "primaryKey": false,
2893
+ "notNull": true
2894
+ },
2895
+ "system": {
2896
+ "name": "system",
2897
+ "type": "text",
2898
+ "primaryKey": false,
2899
+ "notNull": true
2900
+ },
2901
+ "external_id": {
2902
+ "name": "external_id",
2903
+ "type": "text",
2904
+ "primaryKey": false,
2905
+ "notNull": true
2906
+ },
2907
+ "external_number": {
2908
+ "name": "external_number",
2909
+ "type": "text",
2910
+ "primaryKey": false,
2911
+ "notNull": false
2912
+ },
2913
+ "score": {
2914
+ "name": "score",
2915
+ "type": "integer",
2916
+ "primaryKey": false,
2917
+ "notNull": true
2918
+ },
2919
+ "rank": {
2920
+ "name": "rank",
2921
+ "type": "integer",
2922
+ "primaryKey": false,
2923
+ "notNull": true
2924
+ },
2925
+ "signals": {
2926
+ "name": "signals",
2927
+ "type": "jsonb",
2928
+ "primaryKey": false,
2929
+ "notNull": true,
2930
+ "default": "'[]'::jsonb"
2931
+ },
2932
+ "state": {
2933
+ "name": "state",
2934
+ "type": "text",
2935
+ "primaryKey": false,
2936
+ "notNull": true,
2937
+ "default": "'open'"
2938
+ },
2939
+ "decided_by": {
2940
+ "name": "decided_by",
2941
+ "type": "text",
2942
+ "primaryKey": false,
2943
+ "notNull": false
2944
+ },
2945
+ "decided_at": {
2946
+ "name": "decided_at",
2947
+ "type": "timestamp with time zone",
2948
+ "primaryKey": false,
2949
+ "notNull": false
2950
+ },
2951
+ "created_at": {
2952
+ "name": "created_at",
2953
+ "type": "timestamp with time zone",
2954
+ "primaryKey": false,
2955
+ "notNull": true,
2956
+ "default": "now()"
2957
+ },
2958
+ "updated_at": {
2959
+ "name": "updated_at",
2960
+ "type": "timestamp with time zone",
2961
+ "primaryKey": false,
2962
+ "notNull": true,
2963
+ "default": "now()"
2964
+ }
2965
+ },
2966
+ "indexes": {
2967
+ "link_suggestions_open": {
2968
+ "name": "link_suggestions_open",
2969
+ "columns": [
2970
+ {
2971
+ "expression": "organisation_id",
2972
+ "isExpression": false,
2973
+ "asc": true,
2974
+ "nulls": "last"
2975
+ },
2976
+ {
2977
+ "expression": "state",
2978
+ "isExpression": false,
2979
+ "asc": true,
2980
+ "nulls": "last"
2981
+ },
2982
+ {
2983
+ "expression": "obligation_id",
2984
+ "isExpression": false,
2985
+ "asc": true,
2986
+ "nulls": "last"
2987
+ }
2988
+ ],
2989
+ "isUnique": false,
2990
+ "concurrently": false,
2991
+ "method": "btree",
2992
+ "with": {}
2993
+ }
2994
+ },
2995
+ "foreignKeys": {
2996
+ "link_suggestions_organisation_id_organisations_id_fk": {
2997
+ "name": "link_suggestions_organisation_id_organisations_id_fk",
2998
+ "tableFrom": "link_suggestions",
2999
+ "tableTo": "organisations",
3000
+ "columnsFrom": [
3001
+ "organisation_id"
3002
+ ],
3003
+ "columnsTo": [
3004
+ "id"
3005
+ ],
3006
+ "onDelete": "no action",
3007
+ "onUpdate": "no action"
3008
+ },
3009
+ "link_suggestions_obligation_same_org": {
3010
+ "name": "link_suggestions_obligation_same_org",
3011
+ "tableFrom": "link_suggestions",
3012
+ "tableTo": "billing_obligations",
3013
+ "columnsFrom": [
3014
+ "organisation_id",
3015
+ "obligation_id"
3016
+ ],
3017
+ "columnsTo": [
3018
+ "organisation_id",
3019
+ "id"
3020
+ ],
3021
+ "onDelete": "no action",
3022
+ "onUpdate": "no action"
3023
+ }
3024
+ },
3025
+ "compositePrimaryKeys": {},
3026
+ "uniqueConstraints": {
3027
+ "link_suggestions_pair": {
3028
+ "name": "link_suggestions_pair",
3029
+ "nullsNotDistinct": false,
3030
+ "columns": [
3031
+ "organisation_id",
3032
+ "obligation_id",
3033
+ "system",
3034
+ "external_id"
3035
+ ]
3036
+ }
3037
+ },
3038
+ "policies": {},
3039
+ "checkConstraints": {
3040
+ "link_suggestions_state_valid": {
3041
+ "name": "link_suggestions_state_valid",
3042
+ "value": "state in ('open', 'accepted', 'rejected', 'stale')"
3043
+ }
3044
+ },
3045
+ "isRLSEnabled": false
3046
+ },
3047
+ "public.obligation_events": {
3048
+ "name": "obligation_events",
3049
+ "schema": "",
3050
+ "columns": {
3051
+ "id": {
3052
+ "name": "id",
3053
+ "type": "uuid",
3054
+ "primaryKey": true,
3055
+ "notNull": true,
3056
+ "default": "gen_random_uuid()"
3057
+ },
3058
+ "organisation_id": {
3059
+ "name": "organisation_id",
3060
+ "type": "uuid",
3061
+ "primaryKey": false,
3062
+ "notNull": true
3063
+ },
3064
+ "obligation_id": {
3065
+ "name": "obligation_id",
3066
+ "type": "uuid",
3067
+ "primaryKey": false,
3068
+ "notNull": true
3069
+ },
3070
+ "kind": {
3071
+ "name": "kind",
3072
+ "type": "text",
3073
+ "primaryKey": false,
3074
+ "notNull": true
3075
+ },
3076
+ "actor": {
3077
+ "name": "actor",
3078
+ "type": "text",
3079
+ "primaryKey": false,
3080
+ "notNull": true
3081
+ },
3082
+ "evidence": {
3083
+ "name": "evidence",
3084
+ "type": "jsonb",
3085
+ "primaryKey": false,
3086
+ "notNull": true,
3087
+ "default": "'{}'::jsonb"
3088
+ },
3089
+ "created_at": {
3090
+ "name": "created_at",
3091
+ "type": "timestamp with time zone",
3092
+ "primaryKey": false,
3093
+ "notNull": true,
3094
+ "default": "now()"
3095
+ }
3096
+ },
3097
+ "indexes": {},
3098
+ "foreignKeys": {
3099
+ "obligation_events_obligation_same_org": {
3100
+ "name": "obligation_events_obligation_same_org",
3101
+ "tableFrom": "obligation_events",
3102
+ "tableTo": "billing_obligations",
3103
+ "columnsFrom": [
3104
+ "organisation_id",
3105
+ "obligation_id"
3106
+ ],
3107
+ "columnsTo": [
3108
+ "organisation_id",
3109
+ "id"
3110
+ ],
3111
+ "onDelete": "no action",
3112
+ "onUpdate": "no action"
3113
+ }
3114
+ },
3115
+ "compositePrimaryKeys": {},
3116
+ "uniqueConstraints": {},
3117
+ "policies": {},
3118
+ "checkConstraints": {},
3119
+ "isRLSEnabled": false
3120
+ },
3121
+ "public.obligation_payments": {
3122
+ "name": "obligation_payments",
3123
+ "schema": "",
3124
+ "columns": {
3125
+ "id": {
3126
+ "name": "id",
3127
+ "type": "uuid",
3128
+ "primaryKey": true,
3129
+ "notNull": true,
3130
+ "default": "gen_random_uuid()"
3131
+ },
3132
+ "organisation_id": {
3133
+ "name": "organisation_id",
3134
+ "type": "uuid",
3135
+ "primaryKey": false,
3136
+ "notNull": true
3137
+ },
3138
+ "obligation_id": {
3139
+ "name": "obligation_id",
3140
+ "type": "uuid",
3141
+ "primaryKey": false,
3142
+ "notNull": true
3143
+ },
3144
+ "payment_ref": {
3145
+ "name": "payment_ref",
3146
+ "type": "text",
3147
+ "primaryKey": false,
3148
+ "notNull": true
3149
+ },
3150
+ "paid_on": {
3151
+ "name": "paid_on",
3152
+ "type": "date",
3153
+ "primaryKey": false,
3154
+ "notNull": true
3155
+ },
3156
+ "amount_cents": {
3157
+ "name": "amount_cents",
3158
+ "type": "integer",
3159
+ "primaryKey": false,
3160
+ "notNull": true
3161
+ },
3162
+ "reference": {
3163
+ "name": "reference",
3164
+ "type": "text",
3165
+ "primaryKey": false,
3166
+ "notNull": false
3167
+ },
3168
+ "reconciled": {
3169
+ "name": "reconciled",
3170
+ "type": "boolean",
3171
+ "primaryKey": false,
3172
+ "notNull": true
3173
+ },
3174
+ "accounting_url": {
3175
+ "name": "accounting_url",
3176
+ "type": "text",
3177
+ "primaryKey": false,
3178
+ "notNull": false
3179
+ },
3180
+ "observed_at": {
3181
+ "name": "observed_at",
3182
+ "type": "timestamp with time zone",
3183
+ "primaryKey": false,
3184
+ "notNull": true,
3185
+ "default": "now()"
3186
+ }
3187
+ },
3188
+ "indexes": {},
3189
+ "foreignKeys": {
3190
+ "obligation_payments_obligation_same_org": {
3191
+ "name": "obligation_payments_obligation_same_org",
3192
+ "tableFrom": "obligation_payments",
3193
+ "tableTo": "billing_obligations",
3194
+ "columnsFrom": [
3195
+ "organisation_id",
3196
+ "obligation_id"
3197
+ ],
3198
+ "columnsTo": [
3199
+ "organisation_id",
3200
+ "id"
3201
+ ],
3202
+ "onDelete": "no action",
3203
+ "onUpdate": "no action"
3204
+ }
3205
+ },
3206
+ "compositePrimaryKeys": {},
3207
+ "uniqueConstraints": {
3208
+ "obligation_payments_ref": {
3209
+ "name": "obligation_payments_ref",
3210
+ "nullsNotDistinct": false,
3211
+ "columns": [
3212
+ "organisation_id",
3213
+ "obligation_id",
3214
+ "payment_ref"
3215
+ ]
3216
+ }
3217
+ },
3218
+ "policies": {},
3219
+ "checkConstraints": {
3220
+ "obligation_payments_amount_positive": {
3221
+ "name": "obligation_payments_amount_positive",
3222
+ "value": "\"obligation_payments\".\"amount_cents\" > 0"
3223
+ }
3224
+ },
3225
+ "isRLSEnabled": false
3226
+ },
3227
+ "public.obligation_writebacks": {
3228
+ "name": "obligation_writebacks",
3229
+ "schema": "",
3230
+ "columns": {
3231
+ "id": {
3232
+ "name": "id",
3233
+ "type": "uuid",
3234
+ "primaryKey": true,
3235
+ "notNull": true,
3236
+ "default": "gen_random_uuid()"
3237
+ },
3238
+ "organisation_id": {
3239
+ "name": "organisation_id",
3240
+ "type": "uuid",
3241
+ "primaryKey": false,
3242
+ "notNull": true
3243
+ },
3244
+ "obligation_id": {
3245
+ "name": "obligation_id",
3246
+ "type": "uuid",
3247
+ "primaryKey": false,
3248
+ "notNull": true
3249
+ },
3250
+ "target_system": {
3251
+ "name": "target_system",
3252
+ "type": "text",
3253
+ "primaryKey": false,
3254
+ "notNull": true
3255
+ },
3256
+ "status": {
3257
+ "name": "status",
3258
+ "type": "text",
3259
+ "primaryKey": false,
3260
+ "notNull": true
3261
+ },
3262
+ "state": {
3263
+ "name": "state",
3264
+ "type": "text",
3265
+ "primaryKey": false,
3266
+ "notNull": true,
3267
+ "default": "'pending'"
3268
+ },
3269
+ "evidence": {
3270
+ "name": "evidence",
3271
+ "type": "jsonb",
3272
+ "primaryKey": false,
3273
+ "notNull": true
3274
+ },
3275
+ "attempts": {
3276
+ "name": "attempts",
3277
+ "type": "integer",
3278
+ "primaryKey": false,
3279
+ "notNull": true,
3280
+ "default": 0
3281
+ },
3282
+ "last_error": {
3283
+ "name": "last_error",
3284
+ "type": "text",
3285
+ "primaryKey": false,
3286
+ "notNull": false
3287
+ },
3288
+ "sent_at": {
3289
+ "name": "sent_at",
3290
+ "type": "timestamp with time zone",
3291
+ "primaryKey": false,
3292
+ "notNull": false
3293
+ },
3294
+ "created_at": {
3295
+ "name": "created_at",
3296
+ "type": "timestamp with time zone",
3297
+ "primaryKey": false,
3298
+ "notNull": true,
3299
+ "default": "now()"
3300
+ },
3301
+ "updated_at": {
3302
+ "name": "updated_at",
3303
+ "type": "timestamp with time zone",
3304
+ "primaryKey": false,
3305
+ "notNull": true,
3306
+ "default": "now()"
3307
+ }
3308
+ },
3309
+ "indexes": {},
3310
+ "foreignKeys": {
3311
+ "obligation_writebacks_obligation_same_org": {
3312
+ "name": "obligation_writebacks_obligation_same_org",
3313
+ "tableFrom": "obligation_writebacks",
3314
+ "tableTo": "billing_obligations",
3315
+ "columnsFrom": [
3316
+ "organisation_id",
3317
+ "obligation_id"
3318
+ ],
3319
+ "columnsTo": [
3320
+ "organisation_id",
3321
+ "id"
3322
+ ],
3323
+ "onDelete": "no action",
3324
+ "onUpdate": "no action"
3325
+ }
3326
+ },
3327
+ "compositePrimaryKeys": {},
3328
+ "uniqueConstraints": {
3329
+ "obligation_writebacks_status": {
3330
+ "name": "obligation_writebacks_status",
3331
+ "nullsNotDistinct": false,
3332
+ "columns": [
3333
+ "organisation_id",
3334
+ "obligation_id",
3335
+ "status"
3336
+ ]
3337
+ }
3338
+ },
3339
+ "policies": {},
3340
+ "checkConstraints": {
3341
+ "obligation_writebacks_state_valid": {
3342
+ "name": "obligation_writebacks_state_valid",
3343
+ "value": "state in ('pending', 'sent', 'failed', 'not_supported')"
3344
+ }
3345
+ },
3346
+ "isRLSEnabled": false
3347
+ },
3348
+ "public.organisations": {
3349
+ "name": "organisations",
3350
+ "schema": "",
3351
+ "columns": {
3352
+ "id": {
3353
+ "name": "id",
3354
+ "type": "uuid",
3355
+ "primaryKey": true,
3356
+ "notNull": true,
3357
+ "default": "gen_random_uuid()"
3358
+ },
3359
+ "name": {
3360
+ "name": "name",
3361
+ "type": "text",
3362
+ "primaryKey": false,
3363
+ "notNull": true
3364
+ },
3365
+ "invoice_prefix": {
3366
+ "name": "invoice_prefix",
3367
+ "type": "text",
3368
+ "primaryKey": false,
3369
+ "notNull": true,
3370
+ "default": "'INV-'"
3371
+ },
3372
+ "next_invoice_number": {
3373
+ "name": "next_invoice_number",
3374
+ "type": "integer",
3375
+ "primaryKey": false,
3376
+ "notNull": true,
3377
+ "default": 1
3378
+ },
3379
+ "created_at": {
3380
+ "name": "created_at",
3381
+ "type": "timestamp with time zone",
3382
+ "primaryKey": false,
3383
+ "notNull": true,
3384
+ "default": "now()"
3385
+ }
3386
+ },
3387
+ "indexes": {},
3388
+ "foreignKeys": {},
3389
+ "compositePrimaryKeys": {},
3390
+ "uniqueConstraints": {},
3391
+ "policies": {},
3392
+ "checkConstraints": {
3393
+ "organisations_next_invoice_number_positive": {
3394
+ "name": "organisations_next_invoice_number_positive",
3395
+ "value": "\"organisations\".\"next_invoice_number\" > 0"
3396
+ }
3397
+ },
3398
+ "isRLSEnabled": false
3399
+ },
3400
+ "public.outbox": {
3401
+ "name": "outbox",
3402
+ "schema": "",
3403
+ "columns": {
3404
+ "id": {
3405
+ "name": "id",
3406
+ "type": "uuid",
3407
+ "primaryKey": true,
3408
+ "notNull": true,
3409
+ "default": "gen_random_uuid()"
3410
+ },
3411
+ "organisation_id": {
3412
+ "name": "organisation_id",
3413
+ "type": "uuid",
3414
+ "primaryKey": false,
3415
+ "notNull": true
3416
+ },
3417
+ "system": {
3418
+ "name": "system",
3419
+ "type": "text",
3420
+ "primaryKey": false,
3421
+ "notNull": true
3422
+ },
3423
+ "action": {
3424
+ "name": "action",
3425
+ "type": "text",
3426
+ "primaryKey": false,
3427
+ "notNull": true
3428
+ },
3429
+ "entity": {
3430
+ "name": "entity",
3431
+ "type": "text",
3432
+ "primaryKey": false,
3433
+ "notNull": true
3434
+ },
3435
+ "flow_id": {
3436
+ "name": "flow_id",
3437
+ "type": "uuid",
3438
+ "primaryKey": false,
3439
+ "notNull": true
3440
+ },
3441
+ "idempotency_key": {
3442
+ "name": "idempotency_key",
3443
+ "type": "text",
3444
+ "primaryKey": false,
3445
+ "notNull": true
3446
+ },
3447
+ "request": {
3448
+ "name": "request",
3449
+ "type": "jsonb",
3450
+ "primaryKey": false,
3451
+ "notNull": true
3452
+ },
3453
+ "state": {
3454
+ "name": "state",
3455
+ "type": "text",
3456
+ "primaryKey": false,
3457
+ "notNull": true,
3458
+ "default": "'pending'"
3459
+ },
3460
+ "external_id": {
3461
+ "name": "external_id",
3462
+ "type": "text",
3463
+ "primaryKey": false,
3464
+ "notNull": false
3465
+ },
3466
+ "attempts": {
3467
+ "name": "attempts",
3468
+ "type": "integer",
3469
+ "primaryKey": false,
3470
+ "notNull": true,
3471
+ "default": 0
3472
+ },
3473
+ "last_error": {
3474
+ "name": "last_error",
3475
+ "type": "text",
3476
+ "primaryKey": false,
3477
+ "notNull": false
3478
+ },
3479
+ "created_by": {
3480
+ "name": "created_by",
3481
+ "type": "text",
3482
+ "primaryKey": false,
3483
+ "notNull": true
3484
+ },
3485
+ "sent_at": {
3486
+ "name": "sent_at",
3487
+ "type": "timestamp with time zone",
3488
+ "primaryKey": false,
3489
+ "notNull": false
3490
+ },
3491
+ "created_at": {
3492
+ "name": "created_at",
3493
+ "type": "timestamp with time zone",
3494
+ "primaryKey": false,
3495
+ "notNull": true,
3496
+ "default": "now()"
3497
+ },
3498
+ "updated_at": {
3499
+ "name": "updated_at",
3500
+ "type": "timestamp with time zone",
3501
+ "primaryKey": false,
3502
+ "notNull": true,
3503
+ "default": "now()"
3504
+ }
3505
+ },
3506
+ "indexes": {
3507
+ "outbox_pending": {
3508
+ "name": "outbox_pending",
3509
+ "columns": [
3510
+ {
3511
+ "expression": "system",
3512
+ "isExpression": false,
3513
+ "asc": true,
3514
+ "nulls": "last"
3515
+ },
3516
+ {
3517
+ "expression": "state",
3518
+ "isExpression": false,
3519
+ "asc": true,
3520
+ "nulls": "last"
3521
+ },
3522
+ {
3523
+ "expression": "created_at",
3524
+ "isExpression": false,
3525
+ "asc": true,
3526
+ "nulls": "last"
3527
+ }
3528
+ ],
3529
+ "isUnique": false,
3530
+ "concurrently": false,
3531
+ "method": "btree",
3532
+ "with": {}
3533
+ }
3534
+ },
3535
+ "foreignKeys": {
3536
+ "outbox_organisation_id_organisations_id_fk": {
3537
+ "name": "outbox_organisation_id_organisations_id_fk",
3538
+ "tableFrom": "outbox",
3539
+ "tableTo": "organisations",
3540
+ "columnsFrom": [
3541
+ "organisation_id"
3542
+ ],
3543
+ "columnsTo": [
3544
+ "id"
3545
+ ],
3546
+ "onDelete": "no action",
3547
+ "onUpdate": "no action"
3548
+ }
3549
+ },
3550
+ "compositePrimaryKeys": {},
3551
+ "uniqueConstraints": {
3552
+ "outbox_org_id": {
3553
+ "name": "outbox_org_id",
3554
+ "nullsNotDistinct": false,
3555
+ "columns": [
3556
+ "organisation_id",
3557
+ "id"
3558
+ ]
3559
+ },
3560
+ "outbox_idempotency_key": {
3561
+ "name": "outbox_idempotency_key",
3562
+ "nullsNotDistinct": false,
3563
+ "columns": [
3564
+ "idempotency_key"
3565
+ ]
3566
+ }
3567
+ },
3568
+ "policies": {},
3569
+ "checkConstraints": {
3570
+ "outbox_state_valid": {
3571
+ "name": "outbox_state_valid",
3572
+ "value": "state in ('pending', 'sending', 'ambiguous', 'sent', 'failed', 'cancelled')"
3573
+ },
3574
+ "outbox_sent_has_id": {
3575
+ "name": "outbox_sent_has_id",
3576
+ "value": "\"outbox\".\"state\" <> 'sent' or \"outbox\".\"external_id\" is not null"
3577
+ }
3578
+ },
3579
+ "isRLSEnabled": false
3580
+ },
3581
+ "public.people": {
3582
+ "name": "people",
3583
+ "schema": "",
3584
+ "columns": {
3585
+ "id": {
3586
+ "name": "id",
3587
+ "type": "uuid",
3588
+ "primaryKey": true,
3589
+ "notNull": true,
3590
+ "default": "gen_random_uuid()"
3591
+ },
3592
+ "email": {
3593
+ "name": "email",
3594
+ "type": "text",
3595
+ "primaryKey": false,
3596
+ "notNull": true
3597
+ },
3598
+ "name": {
3599
+ "name": "name",
3600
+ "type": "text",
3601
+ "primaryKey": false,
3602
+ "notNull": false
3603
+ },
3604
+ "role": {
3605
+ "name": "role",
3606
+ "type": "text",
3607
+ "primaryKey": false,
3608
+ "notNull": true
3609
+ },
3610
+ "status": {
3611
+ "name": "status",
3612
+ "type": "text",
3613
+ "primaryKey": false,
3614
+ "notNull": true,
3615
+ "default": "'active'"
3616
+ },
3617
+ "clerk_user_id": {
3618
+ "name": "clerk_user_id",
3619
+ "type": "text",
3620
+ "primaryKey": false,
3621
+ "notNull": false
3622
+ },
3623
+ "invited_by": {
3624
+ "name": "invited_by",
3625
+ "type": "uuid",
3626
+ "primaryKey": false,
3627
+ "notNull": false
3628
+ },
3629
+ "linked_at": {
3630
+ "name": "linked_at",
3631
+ "type": "timestamp with time zone",
3632
+ "primaryKey": false,
3633
+ "notNull": false
3634
+ },
3635
+ "appearance": {
3636
+ "name": "appearance",
3637
+ "type": "jsonb",
3638
+ "primaryKey": false,
3639
+ "notNull": false
3640
+ },
3641
+ "views": {
3642
+ "name": "views",
3643
+ "type": "jsonb",
3644
+ "primaryKey": false,
3645
+ "notNull": false
3646
+ },
3647
+ "created_at": {
3648
+ "name": "created_at",
3649
+ "type": "timestamp with time zone",
3650
+ "primaryKey": false,
3651
+ "notNull": true,
3652
+ "default": "now()"
3653
+ },
3654
+ "updated_at": {
3655
+ "name": "updated_at",
3656
+ "type": "timestamp with time zone",
3657
+ "primaryKey": false,
3658
+ "notNull": true,
3659
+ "default": "now()"
3660
+ }
3661
+ },
3662
+ "indexes": {},
3663
+ "foreignKeys": {
3664
+ "people_invited_by_people_id_fk": {
3665
+ "name": "people_invited_by_people_id_fk",
3666
+ "tableFrom": "people",
3667
+ "tableTo": "people",
3668
+ "columnsFrom": [
3669
+ "invited_by"
3670
+ ],
3671
+ "columnsTo": [
3672
+ "id"
3673
+ ],
3674
+ "onDelete": "set null",
3675
+ "onUpdate": "no action"
3676
+ }
3677
+ },
3678
+ "compositePrimaryKeys": {},
3679
+ "uniqueConstraints": {
3680
+ "people_email": {
3681
+ "name": "people_email",
3682
+ "nullsNotDistinct": false,
3683
+ "columns": [
3684
+ "email"
3685
+ ]
3686
+ },
3687
+ "people_clerk_user_id": {
3688
+ "name": "people_clerk_user_id",
3689
+ "nullsNotDistinct": false,
3690
+ "columns": [
3691
+ "clerk_user_id"
3692
+ ]
3693
+ }
3694
+ },
3695
+ "policies": {},
3696
+ "checkConstraints": {
3697
+ "people_email_lower": {
3698
+ "name": "people_email_lower",
3699
+ "value": "\"people\".\"email\" = lower(\"people\".\"email\")"
3700
+ },
3701
+ "people_role_valid": {
3702
+ "name": "people_role_valid",
3703
+ "value": "\"people\".\"role\" in ('owner', 'admin', 'staff')"
3704
+ },
3705
+ "people_status_valid": {
3706
+ "name": "people_status_valid",
3707
+ "value": "\"people\".\"status\" in ('active', 'pending', 'disabled')"
3708
+ }
3709
+ },
3710
+ "isRLSEnabled": false
3711
+ },
3712
+ "public.pipeline_cursors": {
3713
+ "name": "pipeline_cursors",
3714
+ "schema": "",
3715
+ "columns": {
3716
+ "organisation_id": {
3717
+ "name": "organisation_id",
3718
+ "type": "uuid",
3719
+ "primaryKey": false,
3720
+ "notNull": true
3721
+ },
3722
+ "name": {
3723
+ "name": "name",
3724
+ "type": "text",
3725
+ "primaryKey": false,
3726
+ "notNull": true
3727
+ },
3728
+ "cursor": {
3729
+ "name": "cursor",
3730
+ "type": "text",
3731
+ "primaryKey": false,
3732
+ "notNull": false
3733
+ },
3734
+ "updated_at": {
3735
+ "name": "updated_at",
3736
+ "type": "timestamp with time zone",
3737
+ "primaryKey": false,
3738
+ "notNull": true,
3739
+ "default": "now()"
3740
+ }
3741
+ },
3742
+ "indexes": {},
3743
+ "foreignKeys": {
3744
+ "pipeline_cursors_organisation_id_organisations_id_fk": {
3745
+ "name": "pipeline_cursors_organisation_id_organisations_id_fk",
3746
+ "tableFrom": "pipeline_cursors",
3747
+ "tableTo": "organisations",
3748
+ "columnsFrom": [
3749
+ "organisation_id"
3750
+ ],
3751
+ "columnsTo": [
3752
+ "id"
3753
+ ],
3754
+ "onDelete": "no action",
3755
+ "onUpdate": "no action"
3756
+ }
3757
+ },
3758
+ "compositePrimaryKeys": {
3759
+ "pipeline_cursors_pk": {
3760
+ "name": "pipeline_cursors_pk",
3761
+ "columns": [
3762
+ "organisation_id",
3763
+ "name"
3764
+ ]
3765
+ }
3766
+ },
3767
+ "uniqueConstraints": {},
3768
+ "policies": {},
3769
+ "checkConstraints": {},
3770
+ "isRLSEnabled": false
3771
+ },
3772
+ "public.price_item_links": {
3773
+ "name": "price_item_links",
3774
+ "schema": "",
3775
+ "columns": {
3776
+ "id": {
3777
+ "name": "id",
3778
+ "type": "uuid",
3779
+ "primaryKey": true,
3780
+ "notNull": true,
3781
+ "default": "gen_random_uuid()"
3782
+ },
3783
+ "organisation_id": {
3784
+ "name": "organisation_id",
3785
+ "type": "uuid",
3786
+ "primaryKey": false,
3787
+ "notNull": true
3788
+ },
3789
+ "price_item_id": {
3790
+ "name": "price_item_id",
3791
+ "type": "uuid",
3792
+ "primaryKey": false,
3793
+ "notNull": true
3794
+ },
3795
+ "system": {
3796
+ "name": "system",
3797
+ "type": "text",
3798
+ "primaryKey": false,
3799
+ "notNull": true
3800
+ },
3801
+ "external_id": {
3802
+ "name": "external_id",
3803
+ "type": "text",
3804
+ "primaryKey": false,
3805
+ "notNull": true
3806
+ },
3807
+ "external_code": {
3808
+ "name": "external_code",
3809
+ "type": "text",
3810
+ "primaryKey": false,
3811
+ "notNull": false
3812
+ },
3813
+ "matched_by": {
3814
+ "name": "matched_by",
3815
+ "type": "text",
3816
+ "primaryKey": false,
3817
+ "notNull": true
3818
+ },
3819
+ "created_by": {
3820
+ "name": "created_by",
3821
+ "type": "uuid",
3822
+ "primaryKey": false,
3823
+ "notNull": false
3824
+ },
3825
+ "created_at": {
3826
+ "name": "created_at",
3827
+ "type": "timestamp with time zone",
3828
+ "primaryKey": false,
3829
+ "notNull": true,
3830
+ "default": "now()"
3831
+ }
3832
+ },
3833
+ "indexes": {
3834
+ "price_item_links_external": {
3835
+ "name": "price_item_links_external",
3836
+ "columns": [
3837
+ {
3838
+ "expression": "organisation_id",
3839
+ "isExpression": false,
3840
+ "asc": true,
3841
+ "nulls": "last"
3842
+ },
3843
+ {
3844
+ "expression": "system",
3845
+ "isExpression": false,
3846
+ "asc": true,
3847
+ "nulls": "last"
3848
+ },
3849
+ {
3850
+ "expression": "external_id",
3851
+ "isExpression": false,
3852
+ "asc": true,
3853
+ "nulls": "last"
3854
+ }
3855
+ ],
3856
+ "isUnique": true,
3857
+ "concurrently": false,
3858
+ "method": "btree",
3859
+ "with": {}
3860
+ }
3861
+ },
3862
+ "foreignKeys": {
3863
+ "price_item_links_organisation_id_organisations_id_fk": {
3864
+ "name": "price_item_links_organisation_id_organisations_id_fk",
3865
+ "tableFrom": "price_item_links",
3866
+ "tableTo": "organisations",
3867
+ "columnsFrom": [
3868
+ "organisation_id"
3869
+ ],
3870
+ "columnsTo": [
3871
+ "id"
3872
+ ],
3873
+ "onDelete": "no action",
3874
+ "onUpdate": "no action"
3875
+ },
3876
+ "price_item_links_created_by_people_id_fk": {
3877
+ "name": "price_item_links_created_by_people_id_fk",
3878
+ "tableFrom": "price_item_links",
3879
+ "tableTo": "people",
3880
+ "columnsFrom": [
3881
+ "created_by"
3882
+ ],
3883
+ "columnsTo": [
3884
+ "id"
3885
+ ],
3886
+ "onDelete": "set null",
3887
+ "onUpdate": "no action"
3888
+ },
3889
+ "price_item_links_item_same_org": {
3890
+ "name": "price_item_links_item_same_org",
3891
+ "tableFrom": "price_item_links",
3892
+ "tableTo": "price_items",
3893
+ "columnsFrom": [
3894
+ "organisation_id",
3895
+ "price_item_id"
3896
+ ],
3897
+ "columnsTo": [
3898
+ "organisation_id",
3899
+ "id"
3900
+ ],
3901
+ "onDelete": "cascade",
3902
+ "onUpdate": "no action"
3903
+ }
3904
+ },
3905
+ "compositePrimaryKeys": {},
3906
+ "uniqueConstraints": {},
3907
+ "policies": {},
3908
+ "checkConstraints": {
3909
+ "price_item_links_matched_by_valid": {
3910
+ "name": "price_item_links_matched_by_valid",
3911
+ "value": "\"price_item_links\".\"matched_by\" in ('code', 'person')"
3912
+ },
3913
+ "price_item_links_system_valid": {
3914
+ "name": "price_item_links_system_valid",
3915
+ "value": "\"price_item_links\".\"system\" ~ '^[a-z][a-z0-9-]{1,31}$'"
3916
+ }
3917
+ },
3918
+ "isRLSEnabled": false
3919
+ },
3920
+ "public.price_items": {
3921
+ "name": "price_items",
3922
+ "schema": "",
3923
+ "columns": {
3924
+ "id": {
3925
+ "name": "id",
3926
+ "type": "uuid",
3927
+ "primaryKey": true,
3928
+ "notNull": true,
3929
+ "default": "gen_random_uuid()"
3930
+ },
3931
+ "organisation_id": {
3932
+ "name": "organisation_id",
3933
+ "type": "uuid",
3934
+ "primaryKey": false,
3935
+ "notNull": true
3936
+ },
3937
+ "code": {
3938
+ "name": "code",
3939
+ "type": "text",
3940
+ "primaryKey": false,
3941
+ "notNull": true
3942
+ },
3943
+ "name": {
3944
+ "name": "name",
3945
+ "type": "text",
3946
+ "primaryKey": false,
3947
+ "notNull": true
3948
+ },
3949
+ "description": {
3950
+ "name": "description",
3951
+ "type": "text",
3952
+ "primaryKey": false,
3953
+ "notNull": false
3954
+ },
3955
+ "unit_amount_cents": {
3956
+ "name": "unit_amount_cents",
3957
+ "type": "integer",
3958
+ "primaryKey": false,
3959
+ "notNull": true
3960
+ },
3961
+ "tax_code": {
3962
+ "name": "tax_code",
3963
+ "type": "text",
3964
+ "primaryKey": false,
3965
+ "notNull": true,
3966
+ "default": "'GST'"
3967
+ },
3968
+ "account_code": {
3969
+ "name": "account_code",
3970
+ "type": "text",
3971
+ "primaryKey": false,
3972
+ "notNull": false
3973
+ },
3974
+ "archived_at": {
3975
+ "name": "archived_at",
3976
+ "type": "timestamp with time zone",
3977
+ "primaryKey": false,
3978
+ "notNull": false
3979
+ },
3980
+ "updated_by": {
3981
+ "name": "updated_by",
3982
+ "type": "uuid",
3983
+ "primaryKey": false,
3984
+ "notNull": false
3985
+ },
3986
+ "created_at": {
3987
+ "name": "created_at",
3988
+ "type": "timestamp with time zone",
3989
+ "primaryKey": false,
3990
+ "notNull": true,
3991
+ "default": "now()"
3992
+ },
3993
+ "updated_at": {
3994
+ "name": "updated_at",
3995
+ "type": "timestamp with time zone",
3996
+ "primaryKey": false,
3997
+ "notNull": true,
3998
+ "default": "now()"
3999
+ }
4000
+ },
4001
+ "indexes": {},
4002
+ "foreignKeys": {
4003
+ "price_items_organisation_id_organisations_id_fk": {
4004
+ "name": "price_items_organisation_id_organisations_id_fk",
4005
+ "tableFrom": "price_items",
4006
+ "tableTo": "organisations",
4007
+ "columnsFrom": [
4008
+ "organisation_id"
4009
+ ],
4010
+ "columnsTo": [
4011
+ "id"
4012
+ ],
4013
+ "onDelete": "no action",
4014
+ "onUpdate": "no action"
4015
+ },
4016
+ "price_items_updated_by_people_id_fk": {
4017
+ "name": "price_items_updated_by_people_id_fk",
4018
+ "tableFrom": "price_items",
4019
+ "tableTo": "people",
4020
+ "columnsFrom": [
4021
+ "updated_by"
4022
+ ],
4023
+ "columnsTo": [
4024
+ "id"
4025
+ ],
4026
+ "onDelete": "set null",
4027
+ "onUpdate": "no action"
4028
+ }
4029
+ },
4030
+ "compositePrimaryKeys": {},
4031
+ "uniqueConstraints": {
4032
+ "price_items_org_id": {
4033
+ "name": "price_items_org_id",
4034
+ "nullsNotDistinct": false,
4035
+ "columns": [
4036
+ "organisation_id",
4037
+ "id"
4038
+ ]
4039
+ },
4040
+ "price_items_org_code": {
4041
+ "name": "price_items_org_code",
4042
+ "nullsNotDistinct": false,
4043
+ "columns": [
4044
+ "organisation_id",
4045
+ "code"
4046
+ ]
4047
+ }
4048
+ },
4049
+ "policies": {},
4050
+ "checkConstraints": {
4051
+ "price_items_tax_code_valid": {
4052
+ "name": "price_items_tax_code_valid",
4053
+ "value": "\"price_items\".\"tax_code\" in ('GST', 'GST_FREE')"
4054
+ }
4055
+ },
4056
+ "isRLSEnabled": false
4057
+ },
4058
+ "public.prior_links": {
4059
+ "name": "prior_links",
4060
+ "schema": "",
4061
+ "columns": {
4062
+ "id": {
4063
+ "name": "id",
4064
+ "type": "uuid",
4065
+ "primaryKey": true,
4066
+ "notNull": true,
4067
+ "default": "gen_random_uuid()"
4068
+ },
4069
+ "organisation_id": {
4070
+ "name": "organisation_id",
4071
+ "type": "uuid",
4072
+ "primaryKey": false,
4073
+ "notNull": true
4074
+ },
4075
+ "source_system": {
4076
+ "name": "source_system",
4077
+ "type": "text",
4078
+ "primaryKey": false,
4079
+ "notNull": true
4080
+ },
4081
+ "source_job_ref": {
4082
+ "name": "source_job_ref",
4083
+ "type": "text",
4084
+ "primaryKey": false,
4085
+ "notNull": true
4086
+ },
4087
+ "system": {
4088
+ "name": "system",
4089
+ "type": "text",
4090
+ "primaryKey": false,
4091
+ "notNull": true
4092
+ },
4093
+ "external_id": {
4094
+ "name": "external_id",
4095
+ "type": "text",
4096
+ "primaryKey": false,
4097
+ "notNull": true
4098
+ },
4099
+ "external_number": {
4100
+ "name": "external_number",
4101
+ "type": "text",
4102
+ "primaryKey": false,
4103
+ "notNull": false
4104
+ },
4105
+ "matched_by": {
4106
+ "name": "matched_by",
4107
+ "type": "text",
4108
+ "primaryKey": false,
4109
+ "notNull": true
4110
+ },
4111
+ "matched_at": {
4112
+ "name": "matched_at",
4113
+ "type": "timestamp with time zone",
4114
+ "primaryKey": false,
4115
+ "notNull": false
4116
+ },
4117
+ "origin": {
4118
+ "name": "origin",
4119
+ "type": "text",
4120
+ "primaryKey": false,
4121
+ "notNull": true
4122
+ },
4123
+ "created_at": {
4124
+ "name": "created_at",
4125
+ "type": "timestamp with time zone",
4126
+ "primaryKey": false,
4127
+ "notNull": true,
4128
+ "default": "now()"
4129
+ }
4130
+ },
4131
+ "indexes": {
4132
+ "prior_links_job": {
4133
+ "name": "prior_links_job",
4134
+ "columns": [
4135
+ {
4136
+ "expression": "organisation_id",
4137
+ "isExpression": false,
4138
+ "asc": true,
4139
+ "nulls": "last"
4140
+ },
4141
+ {
4142
+ "expression": "source_system",
4143
+ "isExpression": false,
4144
+ "asc": true,
4145
+ "nulls": "last"
4146
+ },
4147
+ {
4148
+ "expression": "source_job_ref",
4149
+ "isExpression": false,
4150
+ "asc": true,
4151
+ "nulls": "last"
4152
+ },
4153
+ {
4154
+ "expression": "system",
4155
+ "isExpression": false,
4156
+ "asc": true,
4157
+ "nulls": "last"
4158
+ }
4159
+ ],
4160
+ "isUnique": true,
4161
+ "concurrently": false,
4162
+ "method": "btree",
4163
+ "with": {}
4164
+ },
4165
+ "prior_links_external": {
4166
+ "name": "prior_links_external",
4167
+ "columns": [
4168
+ {
4169
+ "expression": "organisation_id",
4170
+ "isExpression": false,
4171
+ "asc": true,
4172
+ "nulls": "last"
4173
+ },
4174
+ {
4175
+ "expression": "system",
4176
+ "isExpression": false,
4177
+ "asc": true,
4178
+ "nulls": "last"
4179
+ },
4180
+ {
4181
+ "expression": "external_id",
4182
+ "isExpression": false,
4183
+ "asc": true,
4184
+ "nulls": "last"
4185
+ }
4186
+ ],
4187
+ "isUnique": false,
4188
+ "concurrently": false,
4189
+ "method": "btree",
4190
+ "with": {}
4191
+ }
4192
+ },
4193
+ "foreignKeys": {
4194
+ "prior_links_organisation_id_organisations_id_fk": {
4195
+ "name": "prior_links_organisation_id_organisations_id_fk",
4196
+ "tableFrom": "prior_links",
4197
+ "tableTo": "organisations",
4198
+ "columnsFrom": [
4199
+ "organisation_id"
4200
+ ],
4201
+ "columnsTo": [
4202
+ "id"
4203
+ ],
4204
+ "onDelete": "no action",
4205
+ "onUpdate": "no action"
4206
+ }
4207
+ },
4208
+ "compositePrimaryKeys": {},
4209
+ "uniqueConstraints": {},
4210
+ "policies": {},
4211
+ "checkConstraints": {
4212
+ "prior_links_matched_by_valid": {
4213
+ "name": "prior_links_matched_by_valid",
4214
+ "value": "matched_by in ('person', 'imported')"
4215
+ }
4216
+ },
4217
+ "isRLSEnabled": false
4218
+ },
4219
+ "public.review_items": {
4220
+ "name": "review_items",
4221
+ "schema": "",
4222
+ "columns": {
4223
+ "id": {
4224
+ "name": "id",
4225
+ "type": "uuid",
4226
+ "primaryKey": true,
4227
+ "notNull": true,
4228
+ "default": "gen_random_uuid()"
4229
+ },
4230
+ "organisation_id": {
4231
+ "name": "organisation_id",
4232
+ "type": "uuid",
4233
+ "primaryKey": false,
4234
+ "notNull": true
4235
+ },
4236
+ "kind": {
4237
+ "name": "kind",
4238
+ "type": "text",
4239
+ "primaryKey": false,
4240
+ "notNull": true
4241
+ },
4242
+ "entity": {
4243
+ "name": "entity",
4244
+ "type": "text",
4245
+ "primaryKey": false,
4246
+ "notNull": true
4247
+ },
4248
+ "flow_id": {
4249
+ "name": "flow_id",
4250
+ "type": "uuid",
4251
+ "primaryKey": false,
4252
+ "notNull": true
4253
+ },
4254
+ "systems": {
4255
+ "name": "systems",
4256
+ "type": "text[]",
4257
+ "primaryKey": false,
4258
+ "notNull": true,
4259
+ "default": "'{}'::text[]"
4260
+ },
4261
+ "evidence": {
4262
+ "name": "evidence",
4263
+ "type": "jsonb",
4264
+ "primaryKey": false,
4265
+ "notNull": true,
4266
+ "default": "'{}'::jsonb"
4267
+ },
4268
+ "money_at_risk_cents": {
4269
+ "name": "money_at_risk_cents",
4270
+ "type": "bigint",
4271
+ "primaryKey": false,
4272
+ "notNull": true,
4273
+ "default": 0
4274
+ },
4275
+ "state": {
4276
+ "name": "state",
4277
+ "type": "text",
4278
+ "primaryKey": false,
4279
+ "notNull": true,
4280
+ "default": "'open'"
4281
+ },
4282
+ "seen_count": {
4283
+ "name": "seen_count",
4284
+ "type": "integer",
4285
+ "primaryKey": false,
4286
+ "notNull": true,
4287
+ "default": 1
4288
+ },
4289
+ "resolution": {
4290
+ "name": "resolution",
4291
+ "type": "text",
4292
+ "primaryKey": false,
4293
+ "notNull": false
4294
+ },
4295
+ "note": {
4296
+ "name": "note",
4297
+ "type": "text",
4298
+ "primaryKey": false,
4299
+ "notNull": false
4300
+ },
4301
+ "resolved_by": {
4302
+ "name": "resolved_by",
4303
+ "type": "text",
4304
+ "primaryKey": false,
4305
+ "notNull": false
4306
+ },
4307
+ "resolved_at": {
4308
+ "name": "resolved_at",
4309
+ "type": "timestamp with time zone",
4310
+ "primaryKey": false,
4311
+ "notNull": false
4312
+ },
4313
+ "created_at": {
4314
+ "name": "created_at",
4315
+ "type": "timestamp with time zone",
4316
+ "primaryKey": false,
4317
+ "notNull": true,
4318
+ "default": "now()"
4319
+ },
4320
+ "updated_at": {
4321
+ "name": "updated_at",
4322
+ "type": "timestamp with time zone",
4323
+ "primaryKey": false,
4324
+ "notNull": true,
4325
+ "default": "now()"
4326
+ }
4327
+ },
4328
+ "indexes": {
4329
+ "review_items_one_open": {
4330
+ "name": "review_items_one_open",
4331
+ "columns": [
4332
+ {
4333
+ "expression": "organisation_id",
4334
+ "isExpression": false,
4335
+ "asc": true,
4336
+ "nulls": "last"
4337
+ },
4338
+ {
4339
+ "expression": "kind",
4340
+ "isExpression": false,
4341
+ "asc": true,
4342
+ "nulls": "last"
4343
+ },
4344
+ {
4345
+ "expression": "entity",
4346
+ "isExpression": false,
4347
+ "asc": true,
4348
+ "nulls": "last"
4349
+ },
4350
+ {
4351
+ "expression": "flow_id",
4352
+ "isExpression": false,
4353
+ "asc": true,
4354
+ "nulls": "last"
4355
+ }
4356
+ ],
4357
+ "isUnique": true,
4358
+ "where": "state = 'open'",
4359
+ "concurrently": false,
4360
+ "method": "btree",
4361
+ "with": {}
4362
+ },
4363
+ "review_items_queue": {
4364
+ "name": "review_items_queue",
4365
+ "columns": [
4366
+ {
4367
+ "expression": "organisation_id",
4368
+ "isExpression": false,
4369
+ "asc": true,
4370
+ "nulls": "last"
4371
+ },
4372
+ {
4373
+ "expression": "state",
4374
+ "isExpression": false,
4375
+ "asc": true,
4376
+ "nulls": "last"
4377
+ },
4378
+ {
4379
+ "expression": "money_at_risk_cents",
4380
+ "isExpression": false,
4381
+ "asc": true,
4382
+ "nulls": "last"
4383
+ }
4384
+ ],
4385
+ "isUnique": false,
4386
+ "concurrently": false,
4387
+ "method": "btree",
4388
+ "with": {}
4389
+ }
4390
+ },
4391
+ "foreignKeys": {
4392
+ "review_items_organisation_id_organisations_id_fk": {
4393
+ "name": "review_items_organisation_id_organisations_id_fk",
4394
+ "tableFrom": "review_items",
4395
+ "tableTo": "organisations",
4396
+ "columnsFrom": [
4397
+ "organisation_id"
4398
+ ],
4399
+ "columnsTo": [
4400
+ "id"
4401
+ ],
4402
+ "onDelete": "no action",
4403
+ "onUpdate": "no action"
4404
+ }
4405
+ },
4406
+ "compositePrimaryKeys": {},
4407
+ "uniqueConstraints": {
4408
+ "review_items_org_id": {
4409
+ "name": "review_items_org_id",
4410
+ "nullsNotDistinct": false,
4411
+ "columns": [
4412
+ "organisation_id",
4413
+ "id"
4414
+ ]
4415
+ }
4416
+ },
4417
+ "policies": {},
4418
+ "checkConstraints": {
4419
+ "review_items_state_valid": {
4420
+ "name": "review_items_state_valid",
4421
+ "value": "state in ('open', 'resolved', 'dismissed')"
4422
+ },
4423
+ "review_items_money_not_negative": {
4424
+ "name": "review_items_money_not_negative",
4425
+ "value": "\"review_items\".\"money_at_risk_cents\" >= 0"
4426
+ },
4427
+ "review_items_closed_has_resolution": {
4428
+ "name": "review_items_closed_has_resolution",
4429
+ "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)"
4430
+ }
4431
+ },
4432
+ "isRLSEnabled": false
4433
+ }
4434
+ },
4435
+ "enums": {},
4436
+ "schemas": {},
4437
+ "sequences": {},
4438
+ "roles": {},
4439
+ "policies": {},
4440
+ "views": {},
4441
+ "_meta": {
4442
+ "columns": {},
4443
+ "schemas": {},
4444
+ "tables": {}
4445
+ }
4446
+ }