@vrplatform/kysely 1.3.45-4998 → 1.3.45-5

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 (183) hide show
  1. package/build/.data.tar +0 -0
  2. package/build/main/camel-case/index.js +1 -1
  3. package/build/main/camel-case/index.js.map +1 -1
  4. package/build/main/control-plane/index.d.ts +216 -17
  5. package/build/main/control-plane/index.js +61 -0
  6. package/build/main/control-plane/index.js.map +1 -1
  7. package/build/main/domain.d.ts +4 -0
  8. package/build/main/domain.js +3 -0
  9. package/build/main/domain.js.map +1 -0
  10. package/build/main/index.d.ts +6 -11
  11. package/build/main/index.js +127 -57
  12. package/build/main/index.js.map +1 -1
  13. package/build/main/isomorphic.d.ts +5 -5
  14. package/build/main/isomorphic.js +2 -8
  15. package/build/main/isomorphic.js.map +1 -1
  16. package/build/main/local/digest.d.ts +3 -3
  17. package/build/main/local/digest.js.map +1 -1
  18. package/build/main/local/generate.js +9 -8
  19. package/build/main/local/generate.js.map +1 -1
  20. package/build/main/local/index.d.ts +5 -1
  21. package/build/main/local/index.js +214 -4
  22. package/build/main/local/index.js.map +1 -1
  23. package/build/main/local/prune-pulled-schema.js +4 -1
  24. package/build/main/local/prune-pulled-schema.js.map +1 -1
  25. package/build/main/migration.d.ts +7 -0
  26. package/build/main/migration.js +11 -0
  27. package/build/main/migration.js.map +1 -0
  28. package/build/main/query/listing/status.d.ts +0 -10
  29. package/build/main/query/listing/status.js +2 -14
  30. package/build/main/query/listing/status.js.map +1 -1
  31. package/build/main/query/tenant/status.d.ts +5 -8
  32. package/build/main/query/tenant/status.js +18 -21
  33. package/build/main/query/tenant/status.js.map +1 -1
  34. package/build/main/regional.d.ts +6 -1
  35. package/build/main/regional.js +13 -9
  36. package/build/main/regional.js.map +1 -1
  37. package/build/main/test/index.d.ts +3 -14
  38. package/build/main/test/index.js +0 -23
  39. package/build/main/test/index.js.map +1 -1
  40. package/build/main/transaction.d.ts +3 -3
  41. package/build/main/transaction.js.map +1 -1
  42. package/build/main/v1.generated.d.ts +501 -134
  43. package/build/main/v1.generated.js.map +1 -1
  44. package/build/migrations-v2/0000000000000-baseline.ts +5 -0
  45. package/build/migrations-v2/0000000000001-public-audit-events-v2.ts +137 -0
  46. package/build/migrations-v2/0000000000002-audit-recovery-watermarks.ts +30 -0
  47. package/build/migrations-v2/0000000000003-audit-effect-recovery-watermark.ts +13 -0
  48. package/build/migrations-v2/0000000000004-audit-event-projected-at.ts +15 -0
  49. package/build/migrations-v2/0000000000005-audit-recovery-indexes.ts +63 -0
  50. package/build/migrations-v2/0000000000006-audit-action-public-event-projected-at.ts +22 -0
  51. package/build/migrations-v2/0000000000007-audit-action-public-event-projected-at-backfill.ts +35 -0
  52. package/build/migrations-v2/0000000000008-global-user-attribution.ts +33 -0
  53. package/build/migrations-v2/0000000000008-team-issue-rule-state.ts +52 -0
  54. package/build/migrations-v2/0000000000009-reservation-issue-projections.ts +45 -0
  55. package/build/migrations-v2/0000000000010-bank-rule-application-bank-record-delete-cascade.ts +26 -0
  56. package/build/migrations-v2/0000000000011-guest-balance-journal-entry-lookup-index.ts +25 -0
  57. package/build/migrations-v2/0000000000012-trial-free-analytics-billing-status.ts +72 -0
  58. package/build/migrations-v2/0000000000013-ui-permission-bundles.ts +45 -0
  59. package/build/migrations-v2/0000000000014-ui-permission-bundle-top-up.ts +32 -0
  60. package/build/migrations-v2/0000000000016-managed-team-access.ts +34 -0
  61. package/build/migrations-v2/0000000000017-drop-trial-until.ts +42 -0
  62. package/build/migrations-v2/0000000000018-accounting-integrity-monitoring.ts +276 -0
  63. package/build/migrations-v2/0000000000019-accounting-integrity-run-shards.ts +26 -0
  64. package/build/migrations-v2/0000000000020-accounting-integrity-case-classification.ts +52 -0
  65. package/build/migrations-v2/0000000000021-payment-line-classification-monitor-indexes.ts +31 -0
  66. package/build/migrations-v2/0000000000022-accounting-integrity-controlled-repairs.ts +281 -0
  67. package/build/migrations-v2/0000000000023-line-classification-usage.ts +325 -0
  68. package/build/migrations-v2/0000000000024-tenant-region-migration.ts +108 -0
  69. package/build/migrations-v2/0000000000025-partner-ach-denial-default.ts +30 -0
  70. package/build/migrations-v2/0000000000026-line-classification-usage-capture.ts +399 -0
  71. package/build/migrations-v2/0000000000027-payout-replacement-chain.ts +27 -0
  72. package/build/migrations-v2/0000000000028-accounting-integrity-operator-workflow.ts +108 -0
  73. package/build/migrations-v2/0000000000029-accounting-integrity-definition-artifacts.ts +40 -0
  74. package/build/migrations-v2/0000000000030-accounting-integrity-review-metadata-compatibility.ts +49 -0
  75. package/build/module/camel-case/index.js +1 -1
  76. package/build/module/camel-case/index.js.map +1 -1
  77. package/build/module/control-plane/index.d.ts +216 -17
  78. package/build/module/control-plane/index.js +49 -1
  79. package/build/module/control-plane/index.js.map +1 -1
  80. package/build/module/domain.d.ts +4 -0
  81. package/build/module/domain.js +2 -0
  82. package/build/module/domain.js.map +1 -0
  83. package/build/module/index.d.ts +6 -11
  84. package/build/module/index.js +129 -55
  85. package/build/module/index.js.map +1 -1
  86. package/build/module/isomorphic.d.ts +5 -5
  87. package/build/module/isomorphic.js +1 -6
  88. package/build/module/isomorphic.js.map +1 -1
  89. package/build/module/local/digest.d.ts +3 -3
  90. package/build/module/local/digest.js.map +1 -1
  91. package/build/module/local/generate.js +9 -8
  92. package/build/module/local/generate.js.map +1 -1
  93. package/build/module/local/index.d.ts +5 -1
  94. package/build/module/local/index.js +215 -5
  95. package/build/module/local/index.js.map +1 -1
  96. package/build/module/local/prune-pulled-schema.js +4 -1
  97. package/build/module/local/prune-pulled-schema.js.map +1 -1
  98. package/build/module/migration.d.ts +7 -0
  99. package/build/module/migration.js +8 -0
  100. package/build/module/migration.js.map +1 -0
  101. package/build/module/query/listing/status.d.ts +0 -10
  102. package/build/module/query/listing/status.js +2 -12
  103. package/build/module/query/listing/status.js.map +1 -1
  104. package/build/module/query/tenant/status.d.ts +5 -8
  105. package/build/module/query/tenant/status.js +18 -21
  106. package/build/module/query/tenant/status.js.map +1 -1
  107. package/build/module/regional.d.ts +6 -1
  108. package/build/module/regional.js +13 -9
  109. package/build/module/regional.js.map +1 -1
  110. package/build/module/test/index.d.ts +3 -14
  111. package/build/module/test/index.js +1 -23
  112. package/build/module/test/index.js.map +1 -1
  113. package/build/module/transaction.d.ts +3 -3
  114. package/build/module/transaction.js.map +1 -1
  115. package/build/module/v1.generated.d.ts +501 -134
  116. package/build/module/v1.generated.js.map +1 -1
  117. package/package.json +3 -3
  118. package/build/migrations/0000000000001-init.ts +0 -5
  119. package/build/migrations/0000000000009-drop-store-schema.ts +0 -14
  120. package/build/migrations/0000000000010-bank-rules.ts +0 -190
  121. package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +0 -65
  122. package/build/migrations/0000000000012-bank-rule-conditions.ts +0 -45
  123. package/build/migrations/0000000000013-bank-rule-name-unique.ts +0 -15
  124. package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +0 -41
  125. package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +0 -70
  126. package/build/migrations/0000000000016-owner-statement-draft-status.ts +0 -22
  127. package/build/migrations/0000000000017-tenant-migration-markers.ts +0 -18
  128. package/build/migrations/0000000000018-security-deposits-payable-category.ts +0 -63
  129. package/build/migrations/0000000000019-tenant-app-settings.ts +0 -76
  130. package/build/migrations/0000000000020-operating-opening-trial-balance.ts +0 -36
  131. package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +0 -77
  132. package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +0 -30
  133. package/build/migrations/0000000000023-journal-entry-currency-mismatch-reason.ts +0 -14
  134. package/build/migrations/0000000000024-listing-parent.ts +0 -37
  135. package/build/migrations/0000000000025-journal-entry-parent-listing.ts +0 -26
  136. package/build/migrations/0000000000026-booking-channel-logo-slots.ts +0 -89
  137. package/build/migrations/0000000000027-list-browse-performance-indexes.ts +0 -52
  138. package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +0 -20
  139. package/build/migrations/0000000000029-tenant-slug.ts +0 -328
  140. package/build/migrations/0000000000030-pms-accounting-windows.ts +0 -50
  141. package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +0 -20
  142. package/build/migrations/0000000000032-flow-event-listening.ts +0 -28
  143. package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +0 -272
  144. package/build/migrations/0000000000034-historic-general-ledger.ts +0 -24
  145. package/build/migrations/0000000000035-tenant-regional-placement.ts +0 -37
  146. package/build/migrations/0000000000036-control-plane-projection-events.ts +0 -43
  147. package/build/migrations/0000000000037-tenant-guide-onboarding.ts +0 -21
  148. package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +0 -31
  149. package/build/migrations/0000000000039-crunchy-region.ts +0 -86
  150. package/build/migrations/0000000000040-hostaway-region.ts +0 -72
  151. package/build/migrations/0000000000041-audit-tenant-fk.ts +0 -66
  152. package/build/migrations/0000000000042-ramp-staging-connect-params.ts +0 -35
  153. package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +0 -125
  154. package/build/migrations/0000000000044-tenant-cross-region-fks.ts +0 -45
  155. package/build/migrations/0000000000045-cloudflare-region-env.ts +0 -100
  156. package/build/migrations/0000000000046-control-plane-outbox-alias.ts +0 -46
  157. package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +0 -16
  158. package/build/migrations/0000000000047-tenant-status-backfill.ts +0 -40
  159. package/build/migrations/0000000000048-tenant-status-constraint.ts +0 -24
  160. package/build/migrations/0000000000049-health-tenant-issues.ts +0 -69
  161. package/build/migrations/0000000000050-partner-webhooks.ts +0 -135
  162. package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +0 -42
  163. package/build/migrations/0000000000052-feature-approval-team-enablement.ts +0 -13
  164. package/build/migrations/0000000000053-health-webhook-enums.ts +0 -296
  165. package/build/migrations/0000000000054-user-secondary-emails-jsonb.ts +0 -25
  166. package/build/migrations/0000000000055-outbound-webhooks-v1.ts +0 -221
  167. package/build/migrations/0000000000056-connection-webhook-version.ts +0 -18
  168. package/build/migrations/0000000000057-sync-webhook-version.ts +0 -18
  169. package/build/migrations/0000000000058-reservation-webhook-version.ts +0 -18
  170. package/build/migrations/0000000000059-listing-webhook-version.ts +0 -18
  171. package/build/migrations/0000000000060-owner-statement-webhook-version.ts +0 -19
  172. package/build/migrations/0000000000061-transaction-webhook-version.ts +0 -18
  173. package/build/migrations/0000000000062-plaid-connect-session.ts +0 -102
  174. package/build/migrations/0000000000063-pgcrypto.ts +0 -27
  175. package/build/migrations/0000000000064-partner-api-foundation.ts +0 -36
  176. package/build/migrations/0000000000065-canonical-jsonb-shapes.ts +0 -231
  177. package/build/migrations/0000000000066-source-delete-fk-indexes.ts +0 -20
  178. package/build/migrations/0000000000067-remove-opening-trial-balance-account-columns.ts +0 -34
  179. package/build/migrations/0000000000068-bank-record-account-delete-cascade.ts +0 -26
  180. package/build/migrations/0000000000069-account-connections.ts +0 -204
  181. package/build/migrations/0000000000070-provider-payment-projection-indexes.ts +0 -53
  182. package/build/migrations/0000000000071-tenant-app-settings-shape.ts +0 -39
  183. package/build/migrations/0000000000072-tenant-app-settings-shape-validation.ts +0 -11
@@ -1,231 +0,0 @@
1
- import type { Kysely } from 'kysely';
2
- import { sql } from 'kysely';
3
-
4
- export async function backfillCanonicalJsonbShapes(
5
- db: Kysely<unknown>
6
- ): Promise<void> {
7
- await sql`
8
- update public.connection
9
- set credentials = (credentials #>> '{}')::jsonb
10
- where jsonb_typeof(credentials) = 'string'
11
- `.execute(db);
12
- await sql`
13
- update public.connection
14
- set persistent_state = (persistent_state #>> '{}')::jsonb
15
- where jsonb_typeof(persistent_state) = 'string'
16
- `.execute(db);
17
- await sql`
18
- update public.feature
19
- set required_approvals = (required_approvals #>> '{}')::jsonb
20
- where jsonb_typeof(required_approvals) = 'string'
21
- `.execute(db);
22
- await sql`
23
- update accounting.transaction
24
- set recurring_pattern = (recurring_pattern #>> '{}')::jsonb
25
- where jsonb_typeof(recurring_pattern) = 'string'
26
- `.execute(db);
27
- await sql`
28
- update public.source
29
- set json = (json #>> '{}')::jsonb
30
- where type = 'ownerStatement'
31
- and jsonb_typeof(json) = 'string'
32
- `.execute(db);
33
- await sql`
34
- update accounting.owner_statement_projection
35
- set payload = (payload #>> '{}')::jsonb
36
- where jsonb_typeof(payload) = 'string'
37
- `.execute(db);
38
- }
39
-
40
- export const canonicalJsonbShapeConstraintTargets = [
41
- 'connection',
42
- 'feature',
43
- 'transaction',
44
- 'source',
45
- 'ownerStatementProjection',
46
- ] as const;
47
-
48
- type CanonicalJsonbShapeConstraintTarget =
49
- (typeof canonicalJsonbShapeConstraintTargets)[number];
50
-
51
- export async function addCanonicalJsonbShapeConstraints(
52
- db: Kysely<unknown>,
53
- target: CanonicalJsonbShapeConstraintTarget
54
- ): Promise<void> {
55
- if (target === 'connection') {
56
- await sql`
57
- do $$
58
- begin
59
- if not exists (
60
- select 1 from pg_constraint
61
- where conname = 'connection_credentials_object_check'
62
- and conrelid = 'public.connection'::regclass
63
- ) then
64
- alter table public.connection
65
- add constraint connection_credentials_object_check
66
- check (
67
- credentials is null
68
- or jsonb_typeof(credentials) = 'object'
69
- ) not valid;
70
- end if;
71
- if not exists (
72
- select 1 from pg_constraint
73
- where conname = 'connection_persistent_state_object_check'
74
- and conrelid = 'public.connection'::regclass
75
- ) then
76
- alter table public.connection
77
- add constraint connection_persistent_state_object_check
78
- check (
79
- persistent_state is null
80
- or jsonb_typeof(persistent_state) = 'object'
81
- ) not valid;
82
- end if;
83
- end
84
- $$
85
- `.execute(db);
86
- } else if (target === 'feature') {
87
- await sql`
88
- do $$
89
- begin
90
- if not exists (
91
- select 1 from pg_constraint
92
- where conname = 'feature_required_approvals_array_check'
93
- and conrelid = 'public.feature'::regclass
94
- ) then
95
- alter table public.feature
96
- add constraint feature_required_approvals_array_check
97
- check (
98
- required_approvals is null
99
- or jsonb_typeof(required_approvals) = 'array'
100
- ) not valid;
101
- end if;
102
- end
103
- $$
104
- `.execute(db);
105
- } else if (target === 'transaction') {
106
- await sql`
107
- do $$
108
- begin
109
- if not exists (
110
- select 1 from pg_constraint
111
- where conname = 'transaction_recurring_pattern_object_check'
112
- and conrelid = 'accounting.transaction'::regclass
113
- ) then
114
- alter table accounting.transaction
115
- add constraint transaction_recurring_pattern_object_check
116
- check (
117
- recurring_pattern is null
118
- or jsonb_typeof(recurring_pattern) = 'object'
119
- ) not valid;
120
- end if;
121
- end
122
- $$
123
- `.execute(db);
124
- } else if (target === 'source') {
125
- await sql`
126
- do $$
127
- begin
128
- if not exists (
129
- select 1 from pg_constraint
130
- where conname = 'source_owner_statement_json_object_check'
131
- and conrelid = 'public.source'::regclass
132
- ) then
133
- alter table public.source
134
- add constraint source_owner_statement_json_object_check
135
- check (
136
- type <> 'ownerStatement'
137
- or json is null
138
- or jsonb_typeof(json) = 'object'
139
- ) not valid;
140
- end if;
141
- end
142
- $$
143
- `.execute(db);
144
- } else {
145
- await sql`
146
- do $$
147
- begin
148
- if not exists (
149
- select 1 from pg_constraint
150
- where conname = 'owner_statement_projection_payload_container_check'
151
- and conrelid = 'accounting.owner_statement_projection'::regclass
152
- ) then
153
- alter table accounting.owner_statement_projection
154
- add constraint owner_statement_projection_payload_container_check
155
- check (jsonb_typeof(payload) in ('array', 'object')) not valid;
156
- end if;
157
- end
158
- $$
159
- `.execute(db);
160
- }
161
- }
162
-
163
- export async function validateCanonicalJsonbShapeConstraints(
164
- db: Kysely<unknown>,
165
- target: CanonicalJsonbShapeConstraintTarget
166
- ): Promise<void> {
167
- if (target === 'connection') {
168
- await sql`
169
- alter table public.connection
170
- validate constraint connection_credentials_object_check
171
- `.execute(db);
172
- await sql`
173
- alter table public.connection
174
- validate constraint connection_persistent_state_object_check
175
- `.execute(db);
176
- } else if (target === 'feature') {
177
- await sql`
178
- alter table public.feature
179
- validate constraint feature_required_approvals_array_check
180
- `.execute(db);
181
- } else if (target === 'transaction') {
182
- await sql`
183
- alter table accounting.transaction
184
- validate constraint transaction_recurring_pattern_object_check
185
- `.execute(db);
186
- } else if (target === 'source') {
187
- await sql`
188
- alter table public.source
189
- validate constraint source_owner_statement_json_object_check
190
- `.execute(db);
191
- } else {
192
- await sql`
193
- alter table accounting.owner_statement_projection
194
- validate constraint owner_statement_projection_payload_container_check
195
- `.execute(db);
196
- }
197
- }
198
-
199
- export async function up(db: Kysely<unknown>): Promise<void> {
200
- await backfillCanonicalJsonbShapes(db);
201
- for (const target of canonicalJsonbShapeConstraintTargets) {
202
- await addCanonicalJsonbShapeConstraints(db, target);
203
- }
204
- for (const target of canonicalJsonbShapeConstraintTargets) {
205
- await validateCanonicalJsonbShapeConstraints(db, target);
206
- }
207
- }
208
-
209
- export async function down(db: Kysely<unknown>): Promise<void> {
210
- await sql`
211
- alter table accounting.owner_statement_projection
212
- drop constraint if exists owner_statement_projection_payload_container_check
213
- `.execute(db);
214
- await sql`
215
- alter table public.source
216
- drop constraint if exists source_owner_statement_json_object_check
217
- `.execute(db);
218
- await sql`
219
- alter table accounting.transaction
220
- drop constraint if exists transaction_recurring_pattern_object_check
221
- `.execute(db);
222
- await sql`
223
- alter table public.feature
224
- drop constraint if exists feature_required_approvals_array_check
225
- `.execute(db);
226
- await sql`
227
- alter table public.connection
228
- drop constraint if exists connection_persistent_state_object_check,
229
- drop constraint if exists connection_credentials_object_check
230
- `.execute(db);
231
- }
@@ -1,20 +0,0 @@
1
- import type { Kysely } from 'kysely';
2
- import { sql } from 'kysely';
3
-
4
- export async function up(db: Kysely<unknown>): Promise<void> {
5
- await sql`
6
- create index flow_mapping_source_id_idx
7
- on core.flow_mapping (source_id)
8
- `.execute(db);
9
- await sql`
10
- create index file_storage_source_link_source_id_idx
11
- on public.file_storage_source_link (source_id)
12
- `.execute(db);
13
- }
14
-
15
- export async function down(db: Kysely<unknown>): Promise<void> {
16
- await sql`
17
- drop index public.file_storage_source_link_source_id_idx
18
- `.execute(db);
19
- await sql`drop index core.flow_mapping_source_id_idx`.execute(db);
20
- }
@@ -1,34 +0,0 @@
1
- import type { Kysely } from 'kysely';
2
- import { sql } from 'kysely';
3
-
4
- export async function up(db: Kysely<unknown>): Promise<void> {
5
- await sql`
6
- do $$
7
- begin
8
- if exists (
9
- select 1
10
- from accounting.transaction
11
- where unique_ref = 'openingTrialBalance'
12
- ) then
13
- raise exception
14
- 'Run the PRO-16921 opening trial balance repository migration first';
15
- end if;
16
- end
17
- $$
18
- `.execute(db);
19
-
20
- await sql`
21
- alter table accounting.account
22
- drop column if exists opening_trial_balance_combined_cent_total,
23
- drop column if exists opening_trial_balance_updated_at
24
- `.execute(db);
25
- }
26
-
27
- export async function down(db: Kysely<unknown>): Promise<void> {
28
- await sql`
29
- alter table accounting.account
30
- add column if not exists opening_trial_balance_combined_cent_total
31
- bigint not null default 0,
32
- add column if not exists opening_trial_balance_updated_at timestamptz
33
- `.execute(db);
34
- }
@@ -1,26 +0,0 @@
1
- import type { Kysely } from 'kysely';
2
- import { sql } from 'kysely';
3
-
4
- export async function up(db: Kysely<unknown>): Promise<void> {
5
- await sql`
6
- alter table accounting.bank_record
7
- drop constraint bank_record_account_id_fkey,
8
- add constraint bank_record_account_id_fkey
9
- foreign key (account_id)
10
- references accounting.account(id)
11
- on update restrict
12
- on delete cascade
13
- `.execute(db);
14
- }
15
-
16
- export async function down(db: Kysely<unknown>): Promise<void> {
17
- await sql`
18
- alter table accounting.bank_record
19
- drop constraint bank_record_account_id_fkey,
20
- add constraint bank_record_account_id_fkey
21
- foreign key (account_id)
22
- references accounting.account(id)
23
- on update restrict
24
- on delete restrict
25
- `.execute(db);
26
- }
@@ -1,204 +0,0 @@
1
- import type { Kysely } from 'kysely';
2
- import { sql } from 'kysely';
3
-
4
- export async function up(db: Kysely<unknown>): Promise<void> {
5
- await sql`
6
- alter table accounting.bank_account
7
- rename to account_connection
8
- `.execute(db);
9
- await sql`
10
- alter table accounting.bank_record
11
- rename column bank_account_id to account_connection_id
12
- `.execute(db);
13
-
14
- await sql`
15
- alter table accounting.account_connection
16
- rename constraint bank_account_pkey to account_connection_pkey
17
- `.execute(db);
18
- await sql`
19
- alter table accounting.account_connection
20
- rename constraint bank_account_connection_id_unique_ref_key
21
- to account_connection_connection_id_unique_ref_key
22
- `.execute(db);
23
- await sql`
24
- alter table accounting.account_connection
25
- rename constraint bank_account_source_id_key
26
- to account_connection_source_id_key
27
- `.execute(db);
28
- await sql`
29
- alter table accounting.account_connection
30
- rename constraint bank_account_account_id_fkey
31
- to account_connection_account_id_fkey
32
- `.execute(db);
33
- await sql`
34
- alter table accounting.account_connection
35
- rename constraint bank_account_category_fkey
36
- to account_connection_category_fkey
37
- `.execute(db);
38
- await sql`
39
- alter table accounting.account_connection
40
- rename constraint bank_account_connection_id_fkey
41
- to account_connection_connection_id_fkey
42
- `.execute(db);
43
- await sql`
44
- alter table accounting.account_connection
45
- rename constraint bank_account_currency_fkey
46
- to account_connection_currency_fkey
47
- `.execute(db);
48
- await sql`
49
- alter table accounting.account_connection
50
- rename constraint bank_account_source_id_fkey
51
- to account_connection_source_id_fkey
52
- `.execute(db);
53
- await sql`
54
- alter table accounting.account_connection
55
- rename constraint bank_account_starting_bank_record_id_fkey
56
- to account_connection_starting_bank_record_id_fkey
57
- `.execute(db);
58
- await sql`
59
- alter table accounting.account_connection
60
- rename constraint bank_account_status_fkey
61
- to account_connection_status_fkey
62
- `.execute(db);
63
- await sql`
64
- alter table accounting.account_connection
65
- rename constraint bank_account_tenant_id_fkey
66
- to account_connection_tenant_id_fkey
67
- `.execute(db);
68
- await sql`
69
- alter table accounting.account_connection
70
- rename constraint bank_account_type_fkey
71
- to account_connection_type_fkey
72
- `.execute(db);
73
-
74
- await sql`
75
- alter table accounting.bank_record
76
- rename constraint bank_record_bank_account_id_unique_ref_key
77
- to bank_record_account_connection_id_unique_ref_key
78
- `.execute(db);
79
- await sql`
80
- alter table accounting.bank_record
81
- rename constraint bank_record_bank_account_id_fkey
82
- to bank_record_account_connection_id_fkey
83
- `.execute(db);
84
-
85
- await sql`
86
- alter index accounting.bank_account_connection_persistent_ref_idx
87
- rename to account_connection_connection_persistent_ref_idx
88
- `.execute(db);
89
- await sql`
90
- alter index accounting.bank_record_bank_account_id_tenant_id_idx
91
- rename to bank_record_account_connection_id_tenant_id_idx
92
- `.execute(db);
93
- await sql`
94
- alter trigger set_accounting_bank_account_updated_at
95
- on accounting.account_connection
96
- rename to set_accounting_account_connection_updated_at
97
- `.execute(db);
98
- await sql`
99
- update public.source
100
- set type = 'accountConnection'
101
- where type = 'bankAccount'
102
- `.execute(db);
103
- }
104
-
105
- export async function down(db: Kysely<unknown>): Promise<void> {
106
- await sql`
107
- update public.source
108
- set type = 'bankAccount'
109
- where type = 'accountConnection'
110
- `.execute(db);
111
- await sql`
112
- alter trigger set_accounting_account_connection_updated_at
113
- on accounting.account_connection
114
- rename to set_accounting_bank_account_updated_at
115
- `.execute(db);
116
- await sql`
117
- alter index accounting.bank_record_account_connection_id_tenant_id_idx
118
- rename to bank_record_bank_account_id_tenant_id_idx
119
- `.execute(db);
120
- await sql`
121
- alter index accounting.account_connection_connection_persistent_ref_idx
122
- rename to bank_account_connection_persistent_ref_idx
123
- `.execute(db);
124
-
125
- await sql`
126
- alter table accounting.bank_record
127
- rename constraint bank_record_account_connection_id_fkey
128
- to bank_record_bank_account_id_fkey
129
- `.execute(db);
130
- await sql`
131
- alter table accounting.bank_record
132
- rename constraint bank_record_account_connection_id_unique_ref_key
133
- to bank_record_bank_account_id_unique_ref_key
134
- `.execute(db);
135
-
136
- await sql`
137
- alter table accounting.account_connection
138
- rename constraint account_connection_type_fkey
139
- to bank_account_type_fkey
140
- `.execute(db);
141
- await sql`
142
- alter table accounting.account_connection
143
- rename constraint account_connection_tenant_id_fkey
144
- to bank_account_tenant_id_fkey
145
- `.execute(db);
146
- await sql`
147
- alter table accounting.account_connection
148
- rename constraint account_connection_status_fkey
149
- to bank_account_status_fkey
150
- `.execute(db);
151
- await sql`
152
- alter table accounting.account_connection
153
- rename constraint account_connection_starting_bank_record_id_fkey
154
- to bank_account_starting_bank_record_id_fkey
155
- `.execute(db);
156
- await sql`
157
- alter table accounting.account_connection
158
- rename constraint account_connection_source_id_fkey
159
- to bank_account_source_id_fkey
160
- `.execute(db);
161
- await sql`
162
- alter table accounting.account_connection
163
- rename constraint account_connection_currency_fkey
164
- to bank_account_currency_fkey
165
- `.execute(db);
166
- await sql`
167
- alter table accounting.account_connection
168
- rename constraint account_connection_connection_id_fkey
169
- to bank_account_connection_id_fkey
170
- `.execute(db);
171
- await sql`
172
- alter table accounting.account_connection
173
- rename constraint account_connection_category_fkey
174
- to bank_account_category_fkey
175
- `.execute(db);
176
- await sql`
177
- alter table accounting.account_connection
178
- rename constraint account_connection_account_id_fkey
179
- to bank_account_account_id_fkey
180
- `.execute(db);
181
- await sql`
182
- alter table accounting.account_connection
183
- rename constraint account_connection_source_id_key
184
- to bank_account_source_id_key
185
- `.execute(db);
186
- await sql`
187
- alter table accounting.account_connection
188
- rename constraint account_connection_connection_id_unique_ref_key
189
- to bank_account_connection_id_unique_ref_key
190
- `.execute(db);
191
- await sql`
192
- alter table accounting.account_connection
193
- rename constraint account_connection_pkey to bank_account_pkey
194
- `.execute(db);
195
-
196
- await sql`
197
- alter table accounting.bank_record
198
- rename column account_connection_id to bank_account_id
199
- `.execute(db);
200
- await sql`
201
- alter table accounting.account_connection
202
- rename to bank_account
203
- `.execute(db);
204
- }
@@ -1,53 +0,0 @@
1
- import type { Kysely } from 'kysely';
2
- import { sql } from 'kysely';
3
-
4
- export async function up(db: Kysely<any>): Promise<void> {
5
- await sql`
6
- create index if not exists source_bill_transfer_id_idx
7
- on public.source (tenant_id, (json ->> 'transferId'))
8
- where type = 'bill';
9
- `.execute(db);
10
-
11
- await sql`
12
- create index if not exists sync_provider_payment_idempotency_key_idx
13
- on core.sync (
14
- tenant_id,
15
- connection_id,
16
- ((params -> 'providerPayment') ->> 'idempotencyKey')
17
- )
18
- where params ? 'providerPayment';
19
- `.execute(db);
20
-
21
- await sql`
22
- create index if not exists sync_provider_payment_transaction_ids_idx
23
- on core.sync using gin (((params -> 'providerPayment') -> 'transactionIds'))
24
- where params ? 'providerPayment';
25
- `.execute(db);
26
-
27
- await sql`
28
- create index if not exists sync_payment_method_contact_id_idx
29
- on core.sync (
30
- tenant_id,
31
- ((params -> 'paymentMethod') ->> 'contactId')
32
- )
33
- where params ? 'paymentMethod';
34
- `.execute(db);
35
- }
36
-
37
- export async function down(db: Kysely<any>): Promise<void> {
38
- await sql`
39
- drop index if exists core.sync_payment_method_contact_id_idx;
40
- `.execute(db);
41
-
42
- await sql`
43
- drop index if exists core.sync_provider_payment_transaction_ids_idx;
44
- `.execute(db);
45
-
46
- await sql`
47
- drop index if exists core.sync_provider_payment_idempotency_key_idx;
48
- `.execute(db);
49
-
50
- await sql`
51
- drop index if exists public.source_bill_transfer_id_idx;
52
- `.execute(db);
53
- }
@@ -1,39 +0,0 @@
1
- import type { Kysely } from 'kysely';
2
- import { sql } from 'kysely';
3
-
4
- export async function up(db: Kysely<unknown>): Promise<void> {
5
- await sql`
6
- alter table public.tenant
7
- add constraint tenant_app_settings_object_check
8
- check (
9
- app_settings is null
10
- or jsonb_typeof(app_settings) = 'object'
11
- ) not valid
12
- `.execute(db);
13
-
14
- await sql`
15
- update public.tenant
16
- set app_settings = case
17
- when jsonb_typeof(app_settings) = 'string' then
18
- case
19
- when pg_input_is_valid(app_settings #>> '{}', 'jsonb') then
20
- case
21
- when jsonb_typeof((app_settings #>> '{}')::jsonb) = 'object'
22
- then (app_settings #>> '{}')::jsonb
23
- else '{}'::jsonb
24
- end
25
- else '{}'::jsonb
26
- end
27
- else '{}'::jsonb
28
- end
29
- where app_settings is not null
30
- and jsonb_typeof(app_settings) <> 'object'
31
- `.execute(db);
32
- }
33
-
34
- export async function down(db: Kysely<unknown>): Promise<void> {
35
- await sql`
36
- alter table public.tenant
37
- drop constraint if exists tenant_app_settings_object_check
38
- `.execute(db);
39
- }
@@ -1,11 +0,0 @@
1
- import type { Kysely } from 'kysely';
2
- import { sql } from 'kysely';
3
-
4
- export async function up(db: Kysely<unknown>): Promise<void> {
5
- await sql`
6
- alter table public.tenant
7
- validate constraint tenant_app_settings_object_check
8
- `.execute(db);
9
- }
10
-
11
- export async function down(): Promise<void> {}