@vrplatform/kysely 1.3.45-5070 → 1.3.45-5103
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/local/generate.js +8 -8
- package/build/main/local/generate.js.map +1 -1
- package/build/main/local/index.js +5 -4
- package/build/main/local/index.js.map +1 -1
- package/build/main/migration.d.ts +7 -0
- package/build/main/migration.js +11 -0
- package/build/main/migration.js.map +1 -0
- package/build/main/v1.generated.d.ts +158 -154
- package/build/main/v1.generated.js.map +1 -1
- package/build/migrations-v2/0000000000000-baseline.ts +5 -0
- package/build/migrations-v2/0000000000001-public-audit-events-v2.ts +137 -0
- package/build/module/local/generate.js +8 -8
- package/build/module/local/generate.js.map +1 -1
- package/build/module/local/index.js +5 -4
- package/build/module/local/index.js.map +1 -1
- package/build/module/migration.d.ts +7 -0
- package/build/module/migration.js +8 -0
- package/build/module/migration.js.map +1 -0
- package/build/module/v1.generated.d.ts +158 -154
- package/build/module/v1.generated.js.map +1 -1
- package/package.json +3 -3
- package/build/migrations/0000000000001-init.ts +0 -5
- package/build/migrations/0000000000009-drop-store-schema.ts +0 -14
- package/build/migrations/0000000000010-bank-rules.ts +0 -190
- package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +0 -65
- package/build/migrations/0000000000012-bank-rule-conditions.ts +0 -45
- package/build/migrations/0000000000013-bank-rule-name-unique.ts +0 -15
- package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +0 -41
- package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +0 -70
- package/build/migrations/0000000000016-owner-statement-draft-status.ts +0 -22
- package/build/migrations/0000000000017-tenant-migration-markers.ts +0 -18
- package/build/migrations/0000000000018-security-deposits-payable-category.ts +0 -63
- package/build/migrations/0000000000019-tenant-app-settings.ts +0 -76
- package/build/migrations/0000000000020-operating-opening-trial-balance.ts +0 -36
- package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +0 -77
- package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +0 -30
- package/build/migrations/0000000000023-journal-entry-currency-mismatch-reason.ts +0 -14
- package/build/migrations/0000000000024-listing-parent.ts +0 -37
- package/build/migrations/0000000000025-journal-entry-parent-listing.ts +0 -26
- package/build/migrations/0000000000026-booking-channel-logo-slots.ts +0 -89
- package/build/migrations/0000000000027-list-browse-performance-indexes.ts +0 -52
- package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +0 -20
- package/build/migrations/0000000000029-tenant-slug.ts +0 -328
- package/build/migrations/0000000000030-pms-accounting-windows.ts +0 -50
- package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +0 -20
- package/build/migrations/0000000000032-flow-event-listening.ts +0 -28
- package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +0 -272
- package/build/migrations/0000000000034-historic-general-ledger.ts +0 -24
- package/build/migrations/0000000000035-tenant-regional-placement.ts +0 -37
- package/build/migrations/0000000000036-control-plane-projection-events.ts +0 -43
- package/build/migrations/0000000000037-tenant-guide-onboarding.ts +0 -21
- package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +0 -31
- package/build/migrations/0000000000039-crunchy-region.ts +0 -86
- package/build/migrations/0000000000040-hostaway-region.ts +0 -72
- package/build/migrations/0000000000041-audit-tenant-fk.ts +0 -66
- package/build/migrations/0000000000042-ramp-staging-connect-params.ts +0 -35
- package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +0 -125
- package/build/migrations/0000000000044-tenant-cross-region-fks.ts +0 -45
- package/build/migrations/0000000000045-cloudflare-region-env.ts +0 -100
- package/build/migrations/0000000000046-control-plane-outbox-alias.ts +0 -46
- package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +0 -16
- package/build/migrations/0000000000047-tenant-status-backfill.ts +0 -40
- package/build/migrations/0000000000048-tenant-status-constraint.ts +0 -24
- package/build/migrations/0000000000049-health-tenant-issues.ts +0 -69
- package/build/migrations/0000000000050-partner-webhooks.ts +0 -135
- package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +0 -42
- package/build/migrations/0000000000052-feature-approval-team-enablement.ts +0 -13
- package/build/migrations/0000000000053-health-webhook-enums.ts +0 -296
- package/build/migrations/0000000000054-user-secondary-emails-jsonb.ts +0 -25
- package/build/migrations/0000000000055-outbound-webhooks-v1.ts +0 -221
- package/build/migrations/0000000000056-connection-webhook-version.ts +0 -18
- package/build/migrations/0000000000057-sync-webhook-version.ts +0 -18
- package/build/migrations/0000000000058-reservation-webhook-version.ts +0 -18
- package/build/migrations/0000000000059-listing-webhook-version.ts +0 -18
- package/build/migrations/0000000000060-owner-statement-webhook-version.ts +0 -19
- package/build/migrations/0000000000061-transaction-webhook-version.ts +0 -18
- package/build/migrations/0000000000062-plaid-connect-session.ts +0 -102
- package/build/migrations/0000000000063-pgcrypto.ts +0 -27
- package/build/migrations/0000000000064-partner-api-foundation.ts +0 -36
- package/build/migrations/0000000000065-canonical-jsonb-shapes.ts +0 -231
- package/build/migrations/0000000000066-source-delete-fk-indexes.ts +0 -20
- package/build/migrations/0000000000067-remove-opening-trial-balance-account-columns.ts +0 -34
- package/build/migrations/0000000000068-bank-record-account-delete-cascade.ts +0 -26
- package/build/migrations/0000000000069-account-connections.ts +0 -204
- package/build/migrations/0000000000070-provider-payment-projection-indexes.ts +0 -53
- package/build/migrations/0000000000071-tenant-app-settings-shape.ts +0 -39
- package/build/migrations/0000000000072-tenant-app-settings-shape-validation.ts +0 -11
- package/build/migrations/0000000000073-public-audit-events.ts +0 -241
|
@@ -1,296 +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 type health.tenant_issue_code as enum (
|
|
7
|
-
'teamInactive',
|
|
8
|
-
'partnerInactive',
|
|
9
|
-
'partnerBillingInactive',
|
|
10
|
-
'brokenConnections',
|
|
11
|
-
'outdatedConnections',
|
|
12
|
-
'pmsMissingAccountingStart',
|
|
13
|
-
'operatingBankAccountsWithoutOpex',
|
|
14
|
-
'duplicatedPayments',
|
|
15
|
-
'unbalancedJournalEntries',
|
|
16
|
-
'unbalancedTransactionJournalEntries',
|
|
17
|
-
'closedPeriodUnattachedJournalEntries',
|
|
18
|
-
'missingOwnershipOrDeactivation',
|
|
19
|
-
'unpaidReservations',
|
|
20
|
-
'cancelledReservationPaidWithoutAdjustment',
|
|
21
|
-
'publishedStatementUnpaid',
|
|
22
|
-
'endedOwnershipNonZeroBalance',
|
|
23
|
-
'reservationPaymentProjectionMismatch',
|
|
24
|
-
'listingOwnershipPeriodNotFoundOnActiveJournals',
|
|
25
|
-
'reservationGuestTotalsMismatch',
|
|
26
|
-
'reservationCurrencyMismatch'
|
|
27
|
-
)
|
|
28
|
-
`.execute(db);
|
|
29
|
-
await sql`
|
|
30
|
-
create type health.tenant_issue_status as enum ('open', 'resolved')
|
|
31
|
-
`.execute(db);
|
|
32
|
-
await sql`
|
|
33
|
-
create type health.tenant_issue_severity as enum ('error', 'warning')
|
|
34
|
-
`.execute(db);
|
|
35
|
-
await sql`
|
|
36
|
-
create type health.tenant_issue_category as enum (
|
|
37
|
-
'criticalToUser',
|
|
38
|
-
'criticalToSystem'
|
|
39
|
-
)
|
|
40
|
-
`.execute(db);
|
|
41
|
-
await sql`
|
|
42
|
-
create type webhook.subscription_scope as enum ('self', 'managedTeams')
|
|
43
|
-
`.execute(db);
|
|
44
|
-
await sql`
|
|
45
|
-
create type webhook.subscription_status as enum (
|
|
46
|
-
'pending',
|
|
47
|
-
'active',
|
|
48
|
-
'disabled'
|
|
49
|
-
)
|
|
50
|
-
`.execute(db);
|
|
51
|
-
await sql`
|
|
52
|
-
create type webhook.subscription_event_type as enum (
|
|
53
|
-
'team.issues.changed'
|
|
54
|
-
)
|
|
55
|
-
`.execute(db);
|
|
56
|
-
await sql`
|
|
57
|
-
create type webhook.event_type as enum (
|
|
58
|
-
'webhook.test',
|
|
59
|
-
'team.issues.changed'
|
|
60
|
-
)
|
|
61
|
-
`.execute(db);
|
|
62
|
-
await sql`
|
|
63
|
-
create type webhook.api_version as enum ('2026-07-01')
|
|
64
|
-
`.execute(db);
|
|
65
|
-
await sql`
|
|
66
|
-
create type webhook.resource_type as enum ('webhook', 'team')
|
|
67
|
-
`.execute(db);
|
|
68
|
-
await sql`
|
|
69
|
-
create type webhook.delivery_status as enum (
|
|
70
|
-
'queued',
|
|
71
|
-
'delivering',
|
|
72
|
-
'retrying',
|
|
73
|
-
'succeeded',
|
|
74
|
-
'failed',
|
|
75
|
-
'canceled'
|
|
76
|
-
)
|
|
77
|
-
`.execute(db);
|
|
78
|
-
|
|
79
|
-
await sql`drop index health.tenant_issue_open_idx`.execute(db);
|
|
80
|
-
await sql`
|
|
81
|
-
alter table health.tenant_issue
|
|
82
|
-
drop constraint tenant_issue_status_check,
|
|
83
|
-
drop constraint tenant_issue_severity_check,
|
|
84
|
-
drop constraint tenant_issue_category_check,
|
|
85
|
-
drop constraint tenant_issue_affected_check
|
|
86
|
-
`.execute(db);
|
|
87
|
-
await sql`
|
|
88
|
-
alter table health.tenant_issue
|
|
89
|
-
alter column code type health.tenant_issue_code
|
|
90
|
-
using code::health.tenant_issue_code,
|
|
91
|
-
alter column status type health.tenant_issue_status
|
|
92
|
-
using status::health.tenant_issue_status,
|
|
93
|
-
alter column severity type health.tenant_issue_severity
|
|
94
|
-
using severity::health.tenant_issue_severity,
|
|
95
|
-
alter column category type health.tenant_issue_category
|
|
96
|
-
using category::health.tenant_issue_category
|
|
97
|
-
`.execute(db);
|
|
98
|
-
await sql`
|
|
99
|
-
alter table health.tenant_issue
|
|
100
|
-
add constraint tenant_issue_affected_check
|
|
101
|
-
check (
|
|
102
|
-
(status = 'open' and affected > 0)
|
|
103
|
-
or (status = 'resolved' and affected = 0)
|
|
104
|
-
)
|
|
105
|
-
`.execute(db);
|
|
106
|
-
await sql`
|
|
107
|
-
create index tenant_issue_open_idx
|
|
108
|
-
on health.tenant_issue (tenant_id, code)
|
|
109
|
-
where status = 'open'
|
|
110
|
-
`.execute(db);
|
|
111
|
-
|
|
112
|
-
await sql`drop index webhook.webhook_delivery_recovery_idx`.execute(db);
|
|
113
|
-
await sql`
|
|
114
|
-
alter table webhook.subscription
|
|
115
|
-
drop constraint webhook_subscription_scope_check,
|
|
116
|
-
drop constraint webhook_subscription_status_check,
|
|
117
|
-
drop constraint webhook_subscription_event_types_check,
|
|
118
|
-
alter column status drop default
|
|
119
|
-
`.execute(db);
|
|
120
|
-
await sql`
|
|
121
|
-
alter table webhook.delivery
|
|
122
|
-
drop constraint webhook_delivery_status_check,
|
|
123
|
-
alter column status drop default
|
|
124
|
-
`.execute(db);
|
|
125
|
-
await sql`
|
|
126
|
-
alter table webhook.subscription
|
|
127
|
-
alter column scope type webhook.subscription_scope
|
|
128
|
-
using scope::webhook.subscription_scope,
|
|
129
|
-
alter column status type webhook.subscription_status
|
|
130
|
-
using status::webhook.subscription_status,
|
|
131
|
-
alter column api_version type webhook.api_version
|
|
132
|
-
using api_version::webhook.api_version,
|
|
133
|
-
alter column event_types type webhook.subscription_event_type[]
|
|
134
|
-
using event_types::text::webhook.subscription_event_type[],
|
|
135
|
-
alter column status set default 'pending'
|
|
136
|
-
`.execute(db);
|
|
137
|
-
await sql`
|
|
138
|
-
alter table webhook.subscription
|
|
139
|
-
add constraint webhook_subscription_event_types_check
|
|
140
|
-
check (cardinality(event_types) > 0)
|
|
141
|
-
`.execute(db);
|
|
142
|
-
await sql`
|
|
143
|
-
alter table webhook.delivery
|
|
144
|
-
alter column event_type type webhook.event_type
|
|
145
|
-
using event_type::webhook.event_type,
|
|
146
|
-
alter column api_version type webhook.api_version
|
|
147
|
-
using api_version::webhook.api_version,
|
|
148
|
-
alter column resource_type type webhook.resource_type
|
|
149
|
-
using resource_type::webhook.resource_type,
|
|
150
|
-
alter column status type webhook.delivery_status
|
|
151
|
-
using status::webhook.delivery_status,
|
|
152
|
-
alter column status set default 'queued'
|
|
153
|
-
`.execute(db);
|
|
154
|
-
await sql`
|
|
155
|
-
create index webhook_delivery_recovery_idx
|
|
156
|
-
on webhook.delivery (status, next_attempt_at)
|
|
157
|
-
`.execute(db);
|
|
158
|
-
|
|
159
|
-
await sql`
|
|
160
|
-
do $$
|
|
161
|
-
begin
|
|
162
|
-
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
163
|
-
grant usage on type
|
|
164
|
-
health.tenant_issue_code,
|
|
165
|
-
health.tenant_issue_status,
|
|
166
|
-
health.tenant_issue_severity,
|
|
167
|
-
health.tenant_issue_category,
|
|
168
|
-
webhook.subscription_scope,
|
|
169
|
-
webhook.subscription_status,
|
|
170
|
-
webhook.subscription_event_type,
|
|
171
|
-
webhook.event_type,
|
|
172
|
-
webhook.api_version,
|
|
173
|
-
webhook.resource_type,
|
|
174
|
-
webhook.delivery_status
|
|
175
|
-
to application;
|
|
176
|
-
alter default privileges in schema health, webhook
|
|
177
|
-
grant usage on types to application;
|
|
178
|
-
end if;
|
|
179
|
-
end
|
|
180
|
-
$$;
|
|
181
|
-
`.execute(db);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
185
|
-
await sql`
|
|
186
|
-
do $$
|
|
187
|
-
begin
|
|
188
|
-
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
189
|
-
alter default privileges in schema health, webhook
|
|
190
|
-
revoke usage on types from application;
|
|
191
|
-
end if;
|
|
192
|
-
end
|
|
193
|
-
$$;
|
|
194
|
-
`.execute(db);
|
|
195
|
-
|
|
196
|
-
await sql`drop index health.tenant_issue_open_idx`.execute(db);
|
|
197
|
-
await sql`
|
|
198
|
-
alter table health.tenant_issue
|
|
199
|
-
drop constraint tenant_issue_affected_check
|
|
200
|
-
`.execute(db);
|
|
201
|
-
await sql`
|
|
202
|
-
alter table health.tenant_issue
|
|
203
|
-
alter column code type text using code::text,
|
|
204
|
-
alter column status type text using status::text,
|
|
205
|
-
alter column severity type text using severity::text,
|
|
206
|
-
alter column category type text using category::text
|
|
207
|
-
`.execute(db);
|
|
208
|
-
await sql`
|
|
209
|
-
alter table health.tenant_issue
|
|
210
|
-
add constraint tenant_issue_status_check
|
|
211
|
-
check (status in ('open', 'resolved')),
|
|
212
|
-
add constraint tenant_issue_severity_check
|
|
213
|
-
check (severity in ('error', 'warning')),
|
|
214
|
-
add constraint tenant_issue_category_check
|
|
215
|
-
check (category in ('criticalToUser', 'criticalToSystem')),
|
|
216
|
-
add constraint tenant_issue_affected_check
|
|
217
|
-
check (
|
|
218
|
-
(status = 'open' and affected > 0)
|
|
219
|
-
or (status = 'resolved' and affected = 0)
|
|
220
|
-
)
|
|
221
|
-
`.execute(db);
|
|
222
|
-
await sql`
|
|
223
|
-
create index tenant_issue_open_idx
|
|
224
|
-
on health.tenant_issue (tenant_id, code)
|
|
225
|
-
where status = 'open'
|
|
226
|
-
`.execute(db);
|
|
227
|
-
|
|
228
|
-
await sql`drop index webhook.webhook_delivery_recovery_idx`.execute(db);
|
|
229
|
-
await sql`
|
|
230
|
-
alter table webhook.subscription
|
|
231
|
-
drop constraint webhook_subscription_event_types_check,
|
|
232
|
-
alter column status drop default
|
|
233
|
-
`.execute(db);
|
|
234
|
-
await sql`
|
|
235
|
-
alter table webhook.delivery
|
|
236
|
-
alter column status drop default
|
|
237
|
-
`.execute(db);
|
|
238
|
-
await sql`
|
|
239
|
-
alter table webhook.subscription
|
|
240
|
-
alter column scope type text using scope::text,
|
|
241
|
-
alter column status type text using status::text,
|
|
242
|
-
alter column api_version type text using api_version::text,
|
|
243
|
-
alter column event_types type text[] using event_types::text::text[],
|
|
244
|
-
alter column status set default 'pending'
|
|
245
|
-
`.execute(db);
|
|
246
|
-
await sql`
|
|
247
|
-
alter table webhook.subscription
|
|
248
|
-
add constraint webhook_subscription_scope_check
|
|
249
|
-
check (scope in ('self', 'managedTeams')),
|
|
250
|
-
add constraint webhook_subscription_status_check
|
|
251
|
-
check (status in ('pending', 'active', 'disabled')),
|
|
252
|
-
add constraint webhook_subscription_event_types_check
|
|
253
|
-
check (cardinality(event_types) > 0)
|
|
254
|
-
`.execute(db);
|
|
255
|
-
await sql`
|
|
256
|
-
alter table webhook.delivery
|
|
257
|
-
alter column event_type type text using event_type::text,
|
|
258
|
-
alter column api_version type text using api_version::text,
|
|
259
|
-
alter column resource_type type text using resource_type::text,
|
|
260
|
-
alter column status type text using status::text,
|
|
261
|
-
alter column status set default 'queued'
|
|
262
|
-
`.execute(db);
|
|
263
|
-
await sql`
|
|
264
|
-
alter table webhook.delivery
|
|
265
|
-
add constraint webhook_delivery_status_check
|
|
266
|
-
check (
|
|
267
|
-
status in (
|
|
268
|
-
'queued',
|
|
269
|
-
'delivering',
|
|
270
|
-
'retrying',
|
|
271
|
-
'succeeded',
|
|
272
|
-
'failed',
|
|
273
|
-
'canceled'
|
|
274
|
-
)
|
|
275
|
-
)
|
|
276
|
-
`.execute(db);
|
|
277
|
-
await sql`
|
|
278
|
-
create index webhook_delivery_recovery_idx
|
|
279
|
-
on webhook.delivery (status, next_attempt_at)
|
|
280
|
-
`.execute(db);
|
|
281
|
-
|
|
282
|
-
await sql`
|
|
283
|
-
drop type
|
|
284
|
-
webhook.delivery_status,
|
|
285
|
-
webhook.resource_type,
|
|
286
|
-
webhook.api_version,
|
|
287
|
-
webhook.event_type,
|
|
288
|
-
webhook.subscription_event_type,
|
|
289
|
-
webhook.subscription_status,
|
|
290
|
-
webhook.subscription_scope,
|
|
291
|
-
health.tenant_issue_category,
|
|
292
|
-
health.tenant_issue_severity,
|
|
293
|
-
health.tenant_issue_status,
|
|
294
|
-
health.tenant_issue_code
|
|
295
|
-
`.execute(db);
|
|
296
|
-
}
|
|
@@ -1,25 +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
|
-
update public.user
|
|
7
|
-
set secondary_emails = '[]'::jsonb
|
|
8
|
-
where secondary_emails = to_jsonb('[]'::text)
|
|
9
|
-
`.execute(db);
|
|
10
|
-
await sql`
|
|
11
|
-
alter table public.user
|
|
12
|
-
add constraint user_secondary_emails_array_check
|
|
13
|
-
check (
|
|
14
|
-
secondary_emails is null
|
|
15
|
-
or jsonb_typeof(secondary_emails) = 'array'
|
|
16
|
-
)
|
|
17
|
-
`.execute(db);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
21
|
-
await sql`
|
|
22
|
-
alter table public.user
|
|
23
|
-
drop constraint user_secondary_emails_array_check
|
|
24
|
-
`.execute(db);
|
|
25
|
-
}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import type { Kysely } from 'kysely';
|
|
2
|
-
import { sql } from 'kysely';
|
|
3
|
-
|
|
4
|
-
const subscriptionEventTypes = [
|
|
5
|
-
'connection.changed',
|
|
6
|
-
'sync.status.changed',
|
|
7
|
-
'reservation.changed',
|
|
8
|
-
'listing.changed',
|
|
9
|
-
'statement.status.changed',
|
|
10
|
-
'transaction.changed',
|
|
11
|
-
] as const;
|
|
12
|
-
|
|
13
|
-
const resourceTypes = [
|
|
14
|
-
'connection',
|
|
15
|
-
'sync',
|
|
16
|
-
'reservation',
|
|
17
|
-
'listing',
|
|
18
|
-
'statement',
|
|
19
|
-
'transaction',
|
|
20
|
-
] as const;
|
|
21
|
-
|
|
22
|
-
export async function up(db: Kysely<any>): Promise<void> {
|
|
23
|
-
for (const eventType of subscriptionEventTypes) {
|
|
24
|
-
await sql`
|
|
25
|
-
alter type webhook.subscription_event_type add value if not exists ${sql.lit(
|
|
26
|
-
eventType
|
|
27
|
-
)}
|
|
28
|
-
`.execute(db);
|
|
29
|
-
await sql`
|
|
30
|
-
alter type webhook.event_type add value if not exists ${sql.lit(eventType)}
|
|
31
|
-
`.execute(db);
|
|
32
|
-
}
|
|
33
|
-
for (const resourceType of resourceTypes) {
|
|
34
|
-
await sql`
|
|
35
|
-
alter type webhook.resource_type add value if not exists ${sql.lit(
|
|
36
|
-
resourceType
|
|
37
|
-
)}
|
|
38
|
-
`.execute(db);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
await sql`
|
|
42
|
-
alter table webhook.subscription
|
|
43
|
-
add column revision bigint not null default 1,
|
|
44
|
-
add constraint webhook_subscription_revision_check check (revision > 0)
|
|
45
|
-
`.execute(db);
|
|
46
|
-
await sql`
|
|
47
|
-
alter table webhook.delivery
|
|
48
|
-
add column subscription_revision bigint,
|
|
49
|
-
add column retry_attempt_count integer not null default 0,
|
|
50
|
-
add constraint webhook_delivery_subscription_revision_check
|
|
51
|
-
check (subscription_revision > 0),
|
|
52
|
-
add constraint webhook_delivery_retry_attempt_count_check
|
|
53
|
-
check (retry_attempt_count >= 0)
|
|
54
|
-
`.execute(db);
|
|
55
|
-
await sql`
|
|
56
|
-
update webhook.delivery delivery
|
|
57
|
-
set subscription_revision = subscription.revision
|
|
58
|
-
from webhook.subscription subscription
|
|
59
|
-
where subscription.id = delivery.subscription_id
|
|
60
|
-
`.execute(db);
|
|
61
|
-
await sql`
|
|
62
|
-
update webhook.delivery
|
|
63
|
-
set retry_attempt_count = least(attempt_count, 7)
|
|
64
|
-
`.execute(db);
|
|
65
|
-
await sql`
|
|
66
|
-
alter table webhook.delivery
|
|
67
|
-
alter column subscription_revision set not null
|
|
68
|
-
`.execute(db);
|
|
69
|
-
|
|
70
|
-
await sql`
|
|
71
|
-
create table webhook.delivery_attempt_secret (
|
|
72
|
-
delivery_attempt_id uuid not null
|
|
73
|
-
references webhook.delivery_attempt(id) on delete cascade,
|
|
74
|
-
subscription_secret_id uuid not null
|
|
75
|
-
references webhook.subscription_secret(id) on delete restrict,
|
|
76
|
-
position text not null,
|
|
77
|
-
primary key (delivery_attempt_id, subscription_secret_id),
|
|
78
|
-
constraint webhook_delivery_attempt_secret_position_check
|
|
79
|
-
check (position in ('primary', 'overlap')),
|
|
80
|
-
constraint webhook_delivery_attempt_secret_position_key
|
|
81
|
-
unique (delivery_attempt_id, position)
|
|
82
|
-
)
|
|
83
|
-
`.execute(db);
|
|
84
|
-
await sql`
|
|
85
|
-
insert into webhook.delivery_attempt_secret (
|
|
86
|
-
delivery_attempt_id,
|
|
87
|
-
subscription_secret_id,
|
|
88
|
-
position
|
|
89
|
-
)
|
|
90
|
-
select id, subscription_secret_id, 'primary'
|
|
91
|
-
from webhook.delivery_attempt
|
|
92
|
-
`.execute(db);
|
|
93
|
-
await sql`
|
|
94
|
-
alter table webhook.delivery_attempt drop column subscription_secret_id
|
|
95
|
-
`.execute(db);
|
|
96
|
-
|
|
97
|
-
await sql`
|
|
98
|
-
create table webhook.rate_limit (
|
|
99
|
-
owner_tenant_id uuid not null,
|
|
100
|
-
key text not null,
|
|
101
|
-
window_started_at timestamptz not null,
|
|
102
|
-
request_count integer not null,
|
|
103
|
-
primary key (owner_tenant_id, key, window_started_at),
|
|
104
|
-
constraint webhook_rate_limit_request_count_check
|
|
105
|
-
check (request_count > 0)
|
|
106
|
-
)
|
|
107
|
-
`.execute(db);
|
|
108
|
-
|
|
109
|
-
await sql`
|
|
110
|
-
drop index webhook.webhook_delivery_recovery_idx
|
|
111
|
-
`.execute(db);
|
|
112
|
-
await sql`
|
|
113
|
-
create index webhook_delivery_recovery_idx
|
|
114
|
-
on webhook.delivery (next_attempt_at, id)
|
|
115
|
-
where status in ('queued', 'retrying', 'delivering')
|
|
116
|
-
`.execute(db);
|
|
117
|
-
await sql`
|
|
118
|
-
create index webhook_delivery_retention_idx
|
|
119
|
-
on webhook.delivery (updated_at, id)
|
|
120
|
-
where status in ('succeeded', 'failed', 'canceled')
|
|
121
|
-
`.execute(db);
|
|
122
|
-
|
|
123
|
-
await sql`
|
|
124
|
-
do $$
|
|
125
|
-
begin
|
|
126
|
-
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
127
|
-
grant select, insert, update, delete
|
|
128
|
-
on webhook.delivery_attempt_secret, webhook.rate_limit
|
|
129
|
-
to application;
|
|
130
|
-
end if;
|
|
131
|
-
end
|
|
132
|
-
$$
|
|
133
|
-
`.execute(db);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
137
|
-
await sql`drop table webhook.rate_limit`.execute(db);
|
|
138
|
-
await sql`
|
|
139
|
-
alter table webhook.delivery_attempt add column subscription_secret_id uuid
|
|
140
|
-
`.execute(db);
|
|
141
|
-
await sql`
|
|
142
|
-
update webhook.delivery_attempt attempt
|
|
143
|
-
set subscription_secret_id = attempt_secret.subscription_secret_id
|
|
144
|
-
from webhook.delivery_attempt_secret attempt_secret
|
|
145
|
-
where attempt_secret.delivery_attempt_id = attempt.id
|
|
146
|
-
and attempt_secret.position = 'primary'
|
|
147
|
-
`.execute(db);
|
|
148
|
-
await sql`
|
|
149
|
-
alter table webhook.delivery_attempt
|
|
150
|
-
alter column subscription_secret_id set not null,
|
|
151
|
-
add constraint delivery_attempt_subscription_secret_id_fkey
|
|
152
|
-
foreign key (subscription_secret_id)
|
|
153
|
-
references webhook.subscription_secret(id) on delete restrict
|
|
154
|
-
`.execute(db);
|
|
155
|
-
await sql`drop table webhook.delivery_attempt_secret`.execute(db);
|
|
156
|
-
|
|
157
|
-
await sql`
|
|
158
|
-
drop index webhook.webhook_delivery_retention_idx
|
|
159
|
-
`.execute(db);
|
|
160
|
-
await sql`
|
|
161
|
-
drop index webhook.webhook_delivery_recovery_idx
|
|
162
|
-
`.execute(db);
|
|
163
|
-
await sql`
|
|
164
|
-
create index webhook_delivery_recovery_idx
|
|
165
|
-
on webhook.delivery (status, next_attempt_at)
|
|
166
|
-
`.execute(db);
|
|
167
|
-
await sql`
|
|
168
|
-
alter table webhook.delivery
|
|
169
|
-
drop constraint webhook_delivery_subscription_revision_check,
|
|
170
|
-
drop constraint webhook_delivery_retry_attempt_count_check,
|
|
171
|
-
drop column subscription_revision,
|
|
172
|
-
drop column retry_attempt_count
|
|
173
|
-
`.execute(db);
|
|
174
|
-
await sql`
|
|
175
|
-
alter table webhook.subscription
|
|
176
|
-
drop constraint webhook_subscription_revision_check,
|
|
177
|
-
drop column revision
|
|
178
|
-
`.execute(db);
|
|
179
|
-
|
|
180
|
-
await sql`
|
|
181
|
-
alter table webhook.subscription
|
|
182
|
-
drop constraint webhook_subscription_event_types_check,
|
|
183
|
-
alter column event_types type text[] using event_types::text::text[]
|
|
184
|
-
`.execute(db);
|
|
185
|
-
await sql`
|
|
186
|
-
alter table webhook.delivery
|
|
187
|
-
alter column event_type type text using event_type::text,
|
|
188
|
-
alter column resource_type type text using resource_type::text
|
|
189
|
-
`.execute(db);
|
|
190
|
-
await sql`
|
|
191
|
-
drop type webhook.subscription_event_type,
|
|
192
|
-
webhook.event_type,
|
|
193
|
-
webhook.resource_type
|
|
194
|
-
`.execute(db);
|
|
195
|
-
await sql`
|
|
196
|
-
create type webhook.subscription_event_type as enum ('team.issues.changed')
|
|
197
|
-
`.execute(db);
|
|
198
|
-
await sql`
|
|
199
|
-
create type webhook.event_type as enum (
|
|
200
|
-
'webhook.test',
|
|
201
|
-
'team.issues.changed'
|
|
202
|
-
)
|
|
203
|
-
`.execute(db);
|
|
204
|
-
await sql`
|
|
205
|
-
create type webhook.resource_type as enum ('webhook', 'team')
|
|
206
|
-
`.execute(db);
|
|
207
|
-
await sql`
|
|
208
|
-
alter table webhook.subscription
|
|
209
|
-
alter column event_types type webhook.subscription_event_type[]
|
|
210
|
-
using event_types::text::webhook.subscription_event_type[],
|
|
211
|
-
add constraint webhook_subscription_event_types_check
|
|
212
|
-
check (cardinality(event_types) > 0)
|
|
213
|
-
`.execute(db);
|
|
214
|
-
await sql`
|
|
215
|
-
alter table webhook.delivery
|
|
216
|
-
alter column event_type type webhook.event_type
|
|
217
|
-
using event_type::webhook.event_type,
|
|
218
|
-
alter column resource_type type webhook.resource_type
|
|
219
|
-
using resource_type::webhook.resource_type
|
|
220
|
-
`.execute(db);
|
|
221
|
-
}
|
|
@@ -1,18 +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
|
-
alter table public.connection
|
|
7
|
-
add column webhook_version bigint not null default 1,
|
|
8
|
-
add constraint connection_webhook_version_check check (webhook_version > 0)
|
|
9
|
-
`.execute(db);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
13
|
-
await sql`
|
|
14
|
-
alter table public.connection
|
|
15
|
-
drop constraint connection_webhook_version_check,
|
|
16
|
-
drop column webhook_version
|
|
17
|
-
`.execute(db);
|
|
18
|
-
}
|
|
@@ -1,18 +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
|
-
alter table core.sync
|
|
7
|
-
add column webhook_version bigint not null default 1,
|
|
8
|
-
add constraint sync_webhook_version_check check (webhook_version > 0)
|
|
9
|
-
`.execute(db);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
13
|
-
await sql`
|
|
14
|
-
alter table core.sync
|
|
15
|
-
drop constraint sync_webhook_version_check,
|
|
16
|
-
drop column webhook_version
|
|
17
|
-
`.execute(db);
|
|
18
|
-
}
|
|
@@ -1,18 +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
|
-
alter table public.reservation
|
|
7
|
-
add column webhook_version bigint not null default 1,
|
|
8
|
-
add constraint reservation_webhook_version_check check (webhook_version > 0)
|
|
9
|
-
`.execute(db);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
13
|
-
await sql`
|
|
14
|
-
alter table public.reservation
|
|
15
|
-
drop constraint reservation_webhook_version_check,
|
|
16
|
-
drop column webhook_version
|
|
17
|
-
`.execute(db);
|
|
18
|
-
}
|
|
@@ -1,18 +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
|
-
alter table public.listing
|
|
7
|
-
add column webhook_version bigint not null default 1,
|
|
8
|
-
add constraint listing_webhook_version_check check (webhook_version > 0)
|
|
9
|
-
`.execute(db);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
13
|
-
await sql`
|
|
14
|
-
alter table public.listing
|
|
15
|
-
drop constraint listing_webhook_version_check,
|
|
16
|
-
drop column webhook_version
|
|
17
|
-
`.execute(db);
|
|
18
|
-
}
|
|
@@ -1,19 +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
|
-
alter table public.owner_statement
|
|
7
|
-
add column webhook_version bigint not null default 1,
|
|
8
|
-
add constraint owner_statement_webhook_version_check
|
|
9
|
-
check (webhook_version > 0)
|
|
10
|
-
`.execute(db);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
14
|
-
await sql`
|
|
15
|
-
alter table public.owner_statement
|
|
16
|
-
drop constraint owner_statement_webhook_version_check,
|
|
17
|
-
drop column webhook_version
|
|
18
|
-
`.execute(db);
|
|
19
|
-
}
|
|
@@ -1,18 +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
|
-
alter table accounting.transaction
|
|
7
|
-
add column webhook_version bigint not null default 1,
|
|
8
|
-
add constraint transaction_webhook_version_check check (webhook_version > 0)
|
|
9
|
-
`.execute(db);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
13
|
-
await sql`
|
|
14
|
-
alter table accounting.transaction
|
|
15
|
-
drop constraint transaction_webhook_version_check,
|
|
16
|
-
drop column webhook_version
|
|
17
|
-
`.execute(db);
|
|
18
|
-
}
|