@vrplatform/kysely 1.3.41 → 1.3.45-4440
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.
- package/build/.data.tar +0 -0
- package/build/main/camel-case/index.js.map +1 -1
- package/build/main/control-plane/index.d.ts +142 -0
- package/build/main/control-plane/index.js +3 -0
- package/build/main/control-plane/index.js.map +1 -0
- package/build/main/error.js.map +1 -1
- package/build/main/index.d.ts +5 -3
- package/build/main/index.js +8 -10
- package/build/main/index.js.map +1 -1
- package/build/main/isomorphic.js +2 -2
- package/build/main/isomorphic.js.map +1 -1
- package/build/main/local/digest.js.map +1 -1
- package/build/main/local/generate.js.map +1 -1
- package/build/main/local/index.js.map +1 -1
- package/build/main/local/prune-pulled-schema.js.map +1 -1
- package/build/main/pganalyze-comment-plugin/comment-transformer.js +0 -1
- package/build/main/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
- package/build/main/pganalyze-comment-plugin/index.js +16 -3
- package/build/main/pganalyze-comment-plugin/index.js.map +1 -1
- package/build/main/plugins.js.map +1 -1
- package/build/main/query/listing/status.d.ts +4 -4
- package/build/main/query/listing/status.js +2 -1
- package/build/main/query/listing/status.js.map +1 -1
- package/build/main/regional.d.ts +34 -0
- package/build/main/regional.js +145 -0
- package/build/main/regional.js.map +1 -0
- package/build/main/test/index.js.map +1 -1
- package/build/main/transaction.js.map +1 -1
- package/build/main/v1.generated.d.ts +123 -1
- package/build/main/v1.generated.js.map +1 -1
- package/build/migrations/0000000000001-init.ts +5 -0
- package/build/migrations/0000000000009-drop-store-schema.ts +14 -0
- package/build/migrations/0000000000010-bank-rules.ts +190 -0
- package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +65 -0
- package/build/migrations/0000000000012-bank-rule-conditions.ts +45 -0
- package/build/migrations/0000000000013-bank-rule-name-unique.ts +15 -0
- package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +41 -0
- package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +70 -0
- package/build/migrations/0000000000016-owner-statement-draft-status.ts +22 -0
- package/build/migrations/0000000000017-tenant-migration-markers.ts +18 -0
- package/build/migrations/0000000000018-security-deposits-payable-category.ts +63 -0
- package/build/migrations/0000000000019-tenant-app-settings.ts +76 -0
- package/build/migrations/0000000000020-operating-opening-trial-balance.ts +36 -0
- package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +77 -0
- package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +30 -0
- package/build/migrations/0000000000023-journal-entry-currency-mismatch-reason.ts +14 -0
- package/build/migrations/0000000000024-listing-parent.ts +37 -0
- package/build/migrations/0000000000025-journal-entry-parent-listing.ts +26 -0
- package/build/migrations/0000000000026-booking-channel-logo-slots.ts +89 -0
- package/build/migrations/0000000000027-list-browse-performance-indexes.ts +52 -0
- package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +20 -0
- package/build/migrations/0000000000029-tenant-slug.ts +328 -0
- package/build/migrations/0000000000030-pms-accounting-windows.ts +50 -0
- package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +20 -0
- package/build/migrations/0000000000032-flow-event-listening.ts +28 -0
- package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +272 -0
- package/build/migrations/0000000000034-historic-general-ledger.ts +24 -0
- package/build/migrations/0000000000035-tenant-regional-placement.ts +37 -0
- package/build/migrations/0000000000036-control-plane-projection-events.ts +43 -0
- package/build/migrations/0000000000037-tenant-guide-onboarding.ts +21 -0
- package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +31 -0
- package/build/migrations/0000000000039-crunchy-region.ts +86 -0
- package/build/migrations/0000000000040-hostaway-region.ts +72 -0
- package/build/migrations/0000000000041-audit-tenant-fk.ts +66 -0
- package/build/migrations/0000000000042-ramp-staging-connect-params.ts +35 -0
- package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +125 -0
- package/build/migrations/0000000000044-tenant-cross-region-fks.ts +45 -0
- package/build/migrations/0000000000045-cloudflare-region-env.ts +100 -0
- package/build/migrations/0000000000046-control-plane-outbox-alias.ts +46 -0
- package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +16 -0
- package/build/migrations/0000000000047-tenant-status-backfill.ts +40 -0
- package/build/migrations/0000000000048-tenant-status-constraint.ts +24 -0
- package/build/migrations/0000000000049-health-tenant-issues.ts +69 -0
- package/build/migrations/0000000000050-partner-webhooks.ts +135 -0
- package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +42 -0
- package/build/migrations/0000000000052-feature-approval-team-enablement.ts +13 -0
- package/build/migrations/0000000000053-health-webhook-enums.ts +296 -0
- package/build/module/camel-case/index.js.map +1 -1
- package/build/module/control-plane/index.d.ts +142 -0
- package/build/module/control-plane/index.js +2 -0
- package/build/module/control-plane/index.js.map +1 -0
- package/build/module/error.js.map +1 -1
- package/build/module/index.d.ts +5 -3
- package/build/module/index.js +8 -10
- package/build/module/index.js.map +1 -1
- package/build/module/isomorphic.js.map +1 -1
- package/build/module/local/digest.js.map +1 -1
- package/build/module/local/generate.js.map +1 -1
- package/build/module/local/index.js.map +1 -1
- package/build/module/local/prune-pulled-schema.js.map +1 -1
- package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
- package/build/module/pganalyze-comment-plugin/index.js.map +1 -1
- package/build/module/plugins.js.map +1 -1
- package/build/module/query/listing/status.d.ts +4 -4
- package/build/module/query/listing/status.js +2 -1
- package/build/module/query/listing/status.js.map +1 -1
- package/build/module/regional.d.ts +34 -0
- package/build/module/regional.js +103 -0
- package/build/module/regional.js.map +1 -0
- package/build/module/test/index.js.map +1 -1
- package/build/module/transaction.js.map +1 -1
- package/build/module/v1.generated.d.ts +123 -1
- package/build/module/v1.generated.js.map +1 -1
- package/package.json +13 -4
- package/build/main/tsconfig.main.tsbuildinfo +0 -1
- package/build/module/tsconfig.esm.tsbuildinfo +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
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 reservation_tenant_gl_status_effective_check_in_idx
|
|
7
|
+
on public.reservation (
|
|
8
|
+
tenant_id,
|
|
9
|
+
general_ledger_status,
|
|
10
|
+
effective_check_in desc
|
|
11
|
+
)
|
|
12
|
+
include (id, status, connection_id, source_id, listing_id)
|
|
13
|
+
where status not in ('inactive', 'inquiry');
|
|
14
|
+
`.execute(db);
|
|
15
|
+
|
|
16
|
+
await sql`
|
|
17
|
+
create index if not exists listing_ownership_period_inactive_lookup_idx
|
|
18
|
+
on public.listing_ownership_period (
|
|
19
|
+
tenant_id,
|
|
20
|
+
listing_id,
|
|
21
|
+
start_at,
|
|
22
|
+
end_at
|
|
23
|
+
)
|
|
24
|
+
where set_listing_inactive = true;
|
|
25
|
+
`.execute(db);
|
|
26
|
+
|
|
27
|
+
await sql`
|
|
28
|
+
create index if not exists transaction_tenant_type_status_date_idx
|
|
29
|
+
on accounting.transaction (
|
|
30
|
+
tenant_id,
|
|
31
|
+
type,
|
|
32
|
+
status,
|
|
33
|
+
is_opening_balance,
|
|
34
|
+
date desc
|
|
35
|
+
)
|
|
36
|
+
include (id, account_id, connection_id, source_id, contact_id);
|
|
37
|
+
`.execute(db);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
41
|
+
await sql`
|
|
42
|
+
drop index if exists accounting.transaction_tenant_type_status_date_idx;
|
|
43
|
+
`.execute(db);
|
|
44
|
+
|
|
45
|
+
await sql`
|
|
46
|
+
drop index if exists public.listing_ownership_period_inactive_lookup_idx;
|
|
47
|
+
`.execute(db);
|
|
48
|
+
|
|
49
|
+
await sql`
|
|
50
|
+
drop index if exists public.reservation_tenant_gl_status_effective_check_in_idx;
|
|
51
|
+
`.execute(db);
|
|
52
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
update core.flow_setting
|
|
7
|
+
set value = case value #>> '{}'
|
|
8
|
+
when '"active"' then to_jsonb('active'::text)
|
|
9
|
+
when '"inactive"' then to_jsonb('inactive'::text)
|
|
10
|
+
else value
|
|
11
|
+
end
|
|
12
|
+
where setting_key = 'status'
|
|
13
|
+
and jsonb_typeof(value) = 'string'
|
|
14
|
+
and value #>> '{}' in ('"active"', '"inactive"');
|
|
15
|
+
`.execute(db);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function down(_db: Kysely<any>): Promise<void> {
|
|
19
|
+
// Data repair is intentionally irreversible.
|
|
20
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
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
|
+
alter table public.tenant
|
|
7
|
+
add column slug text;
|
|
8
|
+
`.execute(db);
|
|
9
|
+
|
|
10
|
+
await sql`
|
|
11
|
+
create or replace function public.normalize_tenant_slug(value text)
|
|
12
|
+
returns text
|
|
13
|
+
language sql
|
|
14
|
+
immutable
|
|
15
|
+
as $$
|
|
16
|
+
select trim(
|
|
17
|
+
both '-'
|
|
18
|
+
from regexp_replace(
|
|
19
|
+
regexp_replace(lower(coalesce(value, '')), '[^a-z0-9]+', '-', 'g'),
|
|
20
|
+
'-+',
|
|
21
|
+
'-',
|
|
22
|
+
'g'
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
$$;
|
|
26
|
+
`.execute(db);
|
|
27
|
+
|
|
28
|
+
await sql`
|
|
29
|
+
create or replace function public.build_unique_tenant_slug(
|
|
30
|
+
target_name text,
|
|
31
|
+
target_id uuid
|
|
32
|
+
)
|
|
33
|
+
returns text
|
|
34
|
+
language plpgsql
|
|
35
|
+
as $$
|
|
36
|
+
declare
|
|
37
|
+
reserved text[] := array[
|
|
38
|
+
'admin',
|
|
39
|
+
'api',
|
|
40
|
+
'app',
|
|
41
|
+
'assets',
|
|
42
|
+
'auth',
|
|
43
|
+
'billing',
|
|
44
|
+
'cdn',
|
|
45
|
+
'cloudflare',
|
|
46
|
+
'dev',
|
|
47
|
+
'docs',
|
|
48
|
+
'email',
|
|
49
|
+
'ftp',
|
|
50
|
+
'help',
|
|
51
|
+
'imap',
|
|
52
|
+
'internal',
|
|
53
|
+
'localhost',
|
|
54
|
+
'login',
|
|
55
|
+
'logout',
|
|
56
|
+
'mail',
|
|
57
|
+
'mx',
|
|
58
|
+
'new',
|
|
59
|
+
'ns1',
|
|
60
|
+
'ns2',
|
|
61
|
+
'payments',
|
|
62
|
+
'portal',
|
|
63
|
+
'pop',
|
|
64
|
+
'signup',
|
|
65
|
+
'smtp',
|
|
66
|
+
'sftp',
|
|
67
|
+
'ssh',
|
|
68
|
+
'staging',
|
|
69
|
+
'static',
|
|
70
|
+
'status',
|
|
71
|
+
'support',
|
|
72
|
+
'team',
|
|
73
|
+
'teams',
|
|
74
|
+
'test',
|
|
75
|
+
'vrplatform',
|
|
76
|
+
'worker',
|
|
77
|
+
'workers',
|
|
78
|
+
'www'
|
|
79
|
+
];
|
|
80
|
+
base text;
|
|
81
|
+
candidate text;
|
|
82
|
+
suffix integer := 1;
|
|
83
|
+
suffix_text text;
|
|
84
|
+
begin
|
|
85
|
+
base := public.normalize_tenant_slug(target_name);
|
|
86
|
+
if base = '' then
|
|
87
|
+
base := 'team';
|
|
88
|
+
end if;
|
|
89
|
+
if base = any(reserved) then
|
|
90
|
+
base := left(base, 58) || '-team';
|
|
91
|
+
end if;
|
|
92
|
+
|
|
93
|
+
base := left(base, 63);
|
|
94
|
+
base := trim(both '-' from base);
|
|
95
|
+
if base = '' then
|
|
96
|
+
base := 'team';
|
|
97
|
+
end if;
|
|
98
|
+
|
|
99
|
+
candidate := base;
|
|
100
|
+
while exists (
|
|
101
|
+
select 1
|
|
102
|
+
from public.tenant
|
|
103
|
+
where slug = candidate
|
|
104
|
+
and id <> target_id
|
|
105
|
+
) loop
|
|
106
|
+
suffix := suffix + 1;
|
|
107
|
+
suffix_text := '-' || suffix::text;
|
|
108
|
+
candidate := left(base, 63 - length(suffix_text)) || suffix_text;
|
|
109
|
+
end loop;
|
|
110
|
+
|
|
111
|
+
return candidate;
|
|
112
|
+
end;
|
|
113
|
+
$$;
|
|
114
|
+
`.execute(db);
|
|
115
|
+
|
|
116
|
+
await sql`
|
|
117
|
+
create or replace function public.set_tenant_slug()
|
|
118
|
+
returns trigger
|
|
119
|
+
language plpgsql
|
|
120
|
+
as $$
|
|
121
|
+
declare
|
|
122
|
+
reserved text[] := array[
|
|
123
|
+
'admin',
|
|
124
|
+
'api',
|
|
125
|
+
'app',
|
|
126
|
+
'assets',
|
|
127
|
+
'auth',
|
|
128
|
+
'billing',
|
|
129
|
+
'cdn',
|
|
130
|
+
'cloudflare',
|
|
131
|
+
'dev',
|
|
132
|
+
'docs',
|
|
133
|
+
'email',
|
|
134
|
+
'ftp',
|
|
135
|
+
'help',
|
|
136
|
+
'imap',
|
|
137
|
+
'internal',
|
|
138
|
+
'localhost',
|
|
139
|
+
'login',
|
|
140
|
+
'logout',
|
|
141
|
+
'mail',
|
|
142
|
+
'mx',
|
|
143
|
+
'new',
|
|
144
|
+
'ns1',
|
|
145
|
+
'ns2',
|
|
146
|
+
'payments',
|
|
147
|
+
'portal',
|
|
148
|
+
'pop',
|
|
149
|
+
'signup',
|
|
150
|
+
'smtp',
|
|
151
|
+
'sftp',
|
|
152
|
+
'ssh',
|
|
153
|
+
'staging',
|
|
154
|
+
'static',
|
|
155
|
+
'status',
|
|
156
|
+
'support',
|
|
157
|
+
'team',
|
|
158
|
+
'teams',
|
|
159
|
+
'test',
|
|
160
|
+
'vrplatform',
|
|
161
|
+
'worker',
|
|
162
|
+
'workers',
|
|
163
|
+
'www'
|
|
164
|
+
];
|
|
165
|
+
begin
|
|
166
|
+
if new.slug is null or btrim(new.slug) = '' then
|
|
167
|
+
new.slug := public.build_unique_tenant_slug(new.name, new.id);
|
|
168
|
+
else
|
|
169
|
+
new.slug := public.normalize_tenant_slug(new.slug);
|
|
170
|
+
|
|
171
|
+
if new.slug = '' then
|
|
172
|
+
raise exception 'Tenant slug is required' using errcode = '23514';
|
|
173
|
+
end if;
|
|
174
|
+
if new.slug !~ '^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$' then
|
|
175
|
+
raise exception 'Tenant slug % is invalid', new.slug
|
|
176
|
+
using errcode = '23514';
|
|
177
|
+
end if;
|
|
178
|
+
if new.slug = any(reserved) then
|
|
179
|
+
raise exception 'Tenant slug % is reserved', new.slug
|
|
180
|
+
using errcode = '23514';
|
|
181
|
+
end if;
|
|
182
|
+
if exists (
|
|
183
|
+
select 1
|
|
184
|
+
from public.tenant
|
|
185
|
+
where slug = new.slug
|
|
186
|
+
and id <> new.id
|
|
187
|
+
) then
|
|
188
|
+
raise exception 'Tenant slug % is already in use', new.slug
|
|
189
|
+
using errcode = '23505';
|
|
190
|
+
end if;
|
|
191
|
+
end if;
|
|
192
|
+
|
|
193
|
+
return new;
|
|
194
|
+
end;
|
|
195
|
+
$$;
|
|
196
|
+
`.execute(db);
|
|
197
|
+
|
|
198
|
+
await sql`
|
|
199
|
+
create trigger set_public_tenant_slug
|
|
200
|
+
before insert or update of slug, name on public.tenant
|
|
201
|
+
for each row
|
|
202
|
+
execute function public.set_tenant_slug();
|
|
203
|
+
`.execute(db);
|
|
204
|
+
|
|
205
|
+
await sql`
|
|
206
|
+
do $$
|
|
207
|
+
declare
|
|
208
|
+
tenant_row record;
|
|
209
|
+
candidate text;
|
|
210
|
+
begin
|
|
211
|
+
for tenant_row in
|
|
212
|
+
select id, name
|
|
213
|
+
from public.tenant
|
|
214
|
+
where slug is null or btrim(slug) = ''
|
|
215
|
+
order by created_at asc, id asc
|
|
216
|
+
loop
|
|
217
|
+
candidate := public.build_unique_tenant_slug(
|
|
218
|
+
tenant_row.name,
|
|
219
|
+
tenant_row.id
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
update public.tenant
|
|
223
|
+
set slug = candidate
|
|
224
|
+
where id = tenant_row.id;
|
|
225
|
+
end loop;
|
|
226
|
+
end;
|
|
227
|
+
$$;
|
|
228
|
+
`.execute(db);
|
|
229
|
+
|
|
230
|
+
await sql`
|
|
231
|
+
alter table public.tenant
|
|
232
|
+
alter column slug set not null;
|
|
233
|
+
`.execute(db);
|
|
234
|
+
|
|
235
|
+
await sql`
|
|
236
|
+
alter table public.tenant
|
|
237
|
+
add constraint tenant_slug_format_check
|
|
238
|
+
check (slug ~ '^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$');
|
|
239
|
+
`.execute(db);
|
|
240
|
+
|
|
241
|
+
await sql`
|
|
242
|
+
alter table public.tenant
|
|
243
|
+
add constraint tenant_slug_reserved_check
|
|
244
|
+
check (
|
|
245
|
+
slug <> all(array[
|
|
246
|
+
'admin',
|
|
247
|
+
'api',
|
|
248
|
+
'app',
|
|
249
|
+
'assets',
|
|
250
|
+
'auth',
|
|
251
|
+
'billing',
|
|
252
|
+
'cdn',
|
|
253
|
+
'cloudflare',
|
|
254
|
+
'dev',
|
|
255
|
+
'docs',
|
|
256
|
+
'email',
|
|
257
|
+
'ftp',
|
|
258
|
+
'help',
|
|
259
|
+
'imap',
|
|
260
|
+
'internal',
|
|
261
|
+
'localhost',
|
|
262
|
+
'login',
|
|
263
|
+
'logout',
|
|
264
|
+
'mail',
|
|
265
|
+
'mx',
|
|
266
|
+
'new',
|
|
267
|
+
'ns1',
|
|
268
|
+
'ns2',
|
|
269
|
+
'payments',
|
|
270
|
+
'portal',
|
|
271
|
+
'pop',
|
|
272
|
+
'signup',
|
|
273
|
+
'smtp',
|
|
274
|
+
'sftp',
|
|
275
|
+
'ssh',
|
|
276
|
+
'staging',
|
|
277
|
+
'static',
|
|
278
|
+
'status',
|
|
279
|
+
'support',
|
|
280
|
+
'team',
|
|
281
|
+
'teams',
|
|
282
|
+
'test',
|
|
283
|
+
'vrplatform',
|
|
284
|
+
'worker',
|
|
285
|
+
'workers',
|
|
286
|
+
'www'
|
|
287
|
+
])
|
|
288
|
+
);
|
|
289
|
+
`.execute(db);
|
|
290
|
+
|
|
291
|
+
await sql`
|
|
292
|
+
create unique index tenant_slug_unique_idx
|
|
293
|
+
on public.tenant (slug);
|
|
294
|
+
`.execute(db);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
298
|
+
await sql`
|
|
299
|
+
drop index if exists public.tenant_slug_unique_idx;
|
|
300
|
+
`.execute(db);
|
|
301
|
+
|
|
302
|
+
await sql`
|
|
303
|
+
alter table public.tenant
|
|
304
|
+
drop constraint if exists tenant_slug_reserved_check,
|
|
305
|
+
drop constraint if exists tenant_slug_format_check;
|
|
306
|
+
`.execute(db);
|
|
307
|
+
|
|
308
|
+
await sql`
|
|
309
|
+
drop trigger if exists set_public_tenant_slug on public.tenant;
|
|
310
|
+
`.execute(db);
|
|
311
|
+
|
|
312
|
+
await sql`
|
|
313
|
+
drop function if exists public.set_tenant_slug();
|
|
314
|
+
`.execute(db);
|
|
315
|
+
|
|
316
|
+
await sql`
|
|
317
|
+
drop function if exists public.build_unique_tenant_slug(text, uuid);
|
|
318
|
+
`.execute(db);
|
|
319
|
+
|
|
320
|
+
await sql`
|
|
321
|
+
drop function if exists public.normalize_tenant_slug(text);
|
|
322
|
+
`.execute(db);
|
|
323
|
+
|
|
324
|
+
await sql`
|
|
325
|
+
alter table public.tenant
|
|
326
|
+
drop column if exists slug;
|
|
327
|
+
`.execute(db);
|
|
328
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
alter table public.connection
|
|
7
|
+
add column accounting_start_at date,
|
|
8
|
+
add column accounting_end_at date,
|
|
9
|
+
add constraint connection_accounting_window_check
|
|
10
|
+
check (
|
|
11
|
+
(
|
|
12
|
+
accounting_start_at is null
|
|
13
|
+
and accounting_end_at is null
|
|
14
|
+
)
|
|
15
|
+
or accounting_end_at is null
|
|
16
|
+
or accounting_start_at < accounting_end_at
|
|
17
|
+
);
|
|
18
|
+
`.execute(db);
|
|
19
|
+
|
|
20
|
+
await sql`
|
|
21
|
+
update public.connection as connection
|
|
22
|
+
set accounting_start_at = date '1900-01-01'
|
|
23
|
+
from public.app as app
|
|
24
|
+
where app.id = connection.app_id
|
|
25
|
+
and app.category = 'propertyManagementSystem'
|
|
26
|
+
and connection.status = 'active';
|
|
27
|
+
`.execute(db);
|
|
28
|
+
|
|
29
|
+
await sql`
|
|
30
|
+
create index connection_tenant_accounting_window_idx
|
|
31
|
+
on public.connection (
|
|
32
|
+
tenant_id,
|
|
33
|
+
accounting_start_at,
|
|
34
|
+
accounting_end_at
|
|
35
|
+
);
|
|
36
|
+
`.execute(db);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
40
|
+
await sql`
|
|
41
|
+
drop index if exists public.connection_tenant_accounting_window_idx;
|
|
42
|
+
`.execute(db);
|
|
43
|
+
|
|
44
|
+
await sql`
|
|
45
|
+
alter table public.connection
|
|
46
|
+
drop constraint if exists connection_accounting_window_check,
|
|
47
|
+
drop column if exists accounting_end_at,
|
|
48
|
+
drop column if exists accounting_start_at;
|
|
49
|
+
`.execute(db);
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 table accounting.owner_statement_projection_listing_revision (
|
|
7
|
+
tenant_id uuid not null,
|
|
8
|
+
listing_id uuid not null,
|
|
9
|
+
revision bigint default 0 not null,
|
|
10
|
+
updated_at timestamp with time zone default now() not null,
|
|
11
|
+
primary key (tenant_id, listing_id)
|
|
12
|
+
);
|
|
13
|
+
`.execute(db);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
17
|
+
await sql`
|
|
18
|
+
drop table accounting.owner_statement_projection_listing_revision;
|
|
19
|
+
`.execute(db);
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
alter table core.flow
|
|
7
|
+
add column event_listening jsonb not null default '[]'::jsonb,
|
|
8
|
+
add constraint flow_event_listening_array_check
|
|
9
|
+
check (jsonb_typeof(event_listening) = 'array');
|
|
10
|
+
`.execute(db);
|
|
11
|
+
|
|
12
|
+
await sql`
|
|
13
|
+
create index flow_event_listening_idx
|
|
14
|
+
on core.flow using gin (event_listening);
|
|
15
|
+
`.execute(db);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
19
|
+
await sql`
|
|
20
|
+
drop index if exists core.flow_event_listening_idx;
|
|
21
|
+
`.execute(db);
|
|
22
|
+
|
|
23
|
+
await sql`
|
|
24
|
+
alter table core.flow
|
|
25
|
+
drop constraint if exists flow_event_listening_array_check,
|
|
26
|
+
drop column if exists event_listening;
|
|
27
|
+
`.execute(db);
|
|
28
|
+
}
|