@vrplatform/kysely 1.3.45-4997 → 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.
- package/build/.data.tar +0 -0
- package/build/main/camel-case/index.js +1 -1
- package/build/main/camel-case/index.js.map +1 -1
- package/build/main/control-plane/index.d.ts +216 -17
- package/build/main/control-plane/index.js +61 -0
- package/build/main/control-plane/index.js.map +1 -1
- package/build/main/domain.d.ts +4 -0
- package/build/main/domain.js +3 -0
- package/build/main/domain.js.map +1 -0
- package/build/main/index.d.ts +6 -11
- package/build/main/index.js +127 -57
- package/build/main/index.js.map +1 -1
- package/build/main/isomorphic.d.ts +5 -5
- package/build/main/isomorphic.js +2 -8
- package/build/main/isomorphic.js.map +1 -1
- package/build/main/local/digest.d.ts +3 -3
- package/build/main/local/digest.js.map +1 -1
- package/build/main/local/generate.js +9 -8
- package/build/main/local/generate.js.map +1 -1
- package/build/main/local/index.d.ts +5 -1
- package/build/main/local/index.js +214 -4
- package/build/main/local/index.js.map +1 -1
- package/build/main/local/prune-pulled-schema.js +4 -1
- package/build/main/local/prune-pulled-schema.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/query/listing/status.d.ts +0 -10
- package/build/main/query/listing/status.js +2 -14
- package/build/main/query/listing/status.js.map +1 -1
- package/build/main/query/tenant/status.d.ts +5 -8
- package/build/main/query/tenant/status.js +18 -21
- package/build/main/query/tenant/status.js.map +1 -1
- package/build/main/regional.d.ts +6 -1
- package/build/main/regional.js +13 -9
- package/build/main/regional.js.map +1 -1
- package/build/main/test/index.d.ts +3 -14
- package/build/main/test/index.js +0 -23
- package/build/main/test/index.js.map +1 -1
- package/build/main/transaction.d.ts +3 -3
- package/build/main/transaction.js.map +1 -1
- package/build/main/v1.generated.d.ts +501 -134
- 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/migrations-v2/0000000000002-audit-recovery-watermarks.ts +30 -0
- package/build/migrations-v2/0000000000003-audit-effect-recovery-watermark.ts +13 -0
- package/build/migrations-v2/0000000000004-audit-event-projected-at.ts +15 -0
- package/build/migrations-v2/0000000000005-audit-recovery-indexes.ts +63 -0
- package/build/migrations-v2/0000000000006-audit-action-public-event-projected-at.ts +22 -0
- package/build/migrations-v2/0000000000007-audit-action-public-event-projected-at-backfill.ts +35 -0
- package/build/migrations-v2/0000000000008-global-user-attribution.ts +33 -0
- package/build/migrations-v2/0000000000008-team-issue-rule-state.ts +52 -0
- package/build/migrations-v2/0000000000009-reservation-issue-projections.ts +45 -0
- package/build/migrations-v2/0000000000010-bank-rule-application-bank-record-delete-cascade.ts +26 -0
- package/build/migrations-v2/0000000000011-guest-balance-journal-entry-lookup-index.ts +25 -0
- package/build/migrations-v2/0000000000012-trial-free-analytics-billing-status.ts +72 -0
- package/build/migrations-v2/0000000000013-ui-permission-bundles.ts +45 -0
- package/build/migrations-v2/0000000000014-ui-permission-bundle-top-up.ts +32 -0
- package/build/migrations-v2/0000000000016-managed-team-access.ts +34 -0
- package/build/migrations-v2/0000000000017-drop-trial-until.ts +42 -0
- package/build/migrations-v2/0000000000018-accounting-integrity-monitoring.ts +276 -0
- package/build/migrations-v2/0000000000019-accounting-integrity-run-shards.ts +26 -0
- package/build/migrations-v2/0000000000020-accounting-integrity-case-classification.ts +52 -0
- package/build/migrations-v2/0000000000021-payment-line-classification-monitor-indexes.ts +31 -0
- package/build/migrations-v2/0000000000022-accounting-integrity-controlled-repairs.ts +281 -0
- package/build/migrations-v2/0000000000023-line-classification-usage.ts +325 -0
- package/build/migrations-v2/0000000000024-tenant-region-migration.ts +108 -0
- package/build/migrations-v2/0000000000025-partner-ach-denial-default.ts +30 -0
- package/build/migrations-v2/0000000000026-line-classification-usage-capture.ts +399 -0
- package/build/migrations-v2/0000000000027-payout-replacement-chain.ts +27 -0
- package/build/migrations-v2/0000000000028-accounting-integrity-operator-workflow.ts +108 -0
- package/build/migrations-v2/0000000000029-accounting-integrity-definition-artifacts.ts +40 -0
- package/build/migrations-v2/0000000000030-accounting-integrity-review-metadata-compatibility.ts +49 -0
- package/build/module/camel-case/index.js +1 -1
- package/build/module/camel-case/index.js.map +1 -1
- package/build/module/control-plane/index.d.ts +216 -17
- package/build/module/control-plane/index.js +49 -1
- package/build/module/control-plane/index.js.map +1 -1
- package/build/module/domain.d.ts +4 -0
- package/build/module/domain.js +2 -0
- package/build/module/domain.js.map +1 -0
- package/build/module/index.d.ts +6 -11
- package/build/module/index.js +129 -55
- package/build/module/index.js.map +1 -1
- package/build/module/isomorphic.d.ts +5 -5
- package/build/module/isomorphic.js +1 -6
- package/build/module/isomorphic.js.map +1 -1
- package/build/module/local/digest.d.ts +3 -3
- package/build/module/local/digest.js.map +1 -1
- package/build/module/local/generate.js +9 -8
- package/build/module/local/generate.js.map +1 -1
- package/build/module/local/index.d.ts +5 -1
- package/build/module/local/index.js +215 -5
- package/build/module/local/index.js.map +1 -1
- package/build/module/local/prune-pulled-schema.js +4 -1
- package/build/module/local/prune-pulled-schema.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/query/listing/status.d.ts +0 -10
- package/build/module/query/listing/status.js +2 -12
- package/build/module/query/listing/status.js.map +1 -1
- package/build/module/query/tenant/status.d.ts +5 -8
- package/build/module/query/tenant/status.js +18 -21
- package/build/module/query/tenant/status.js.map +1 -1
- package/build/module/regional.d.ts +6 -1
- package/build/module/regional.js +13 -9
- package/build/module/regional.js.map +1 -1
- package/build/module/test/index.d.ts +3 -14
- package/build/module/test/index.js +1 -23
- package/build/module/test/index.js.map +1 -1
- package/build/module/transaction.d.ts +3 -3
- package/build/module/transaction.js.map +1 -1
- package/build/module/v1.generated.d.ts +501 -134
- 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
|
@@ -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
|
-
}
|
|
@@ -1,102 +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 public.plaid_connect_mode as enum (
|
|
7
|
-
'create',
|
|
8
|
-
'update',
|
|
9
|
-
'replace'
|
|
10
|
-
)
|
|
11
|
-
`.execute(db);
|
|
12
|
-
await sql`
|
|
13
|
-
create type public.plaid_connect_status as enum (
|
|
14
|
-
'pendingLink',
|
|
15
|
-
'exchanging',
|
|
16
|
-
'credentialsStored',
|
|
17
|
-
'discoveringAccounts',
|
|
18
|
-
'awaitingConfiguration',
|
|
19
|
-
'configuring',
|
|
20
|
-
'completed',
|
|
21
|
-
'expired',
|
|
22
|
-
'exchangeOutcomeUnknown',
|
|
23
|
-
'failed'
|
|
24
|
-
)
|
|
25
|
-
`.execute(db);
|
|
26
|
-
|
|
27
|
-
await sql`
|
|
28
|
-
alter table accounting.bank_account
|
|
29
|
-
add column persistent_ref text
|
|
30
|
-
`.execute(db);
|
|
31
|
-
await sql`
|
|
32
|
-
create index bank_account_connection_persistent_ref_idx
|
|
33
|
-
on accounting.bank_account (connection_id, persistent_ref)
|
|
34
|
-
where persistent_ref is not null
|
|
35
|
-
`.execute(db);
|
|
36
|
-
|
|
37
|
-
await sql`
|
|
38
|
-
create table public.plaid_connect_session (
|
|
39
|
-
id uuid primary key default gen_random_uuid(),
|
|
40
|
-
tenant_id uuid not null references public.tenant(id) on delete cascade,
|
|
41
|
-
mode public.plaid_connect_mode not null,
|
|
42
|
-
status public.plaid_connect_status not null default 'pendingLink',
|
|
43
|
-
environment text not null,
|
|
44
|
-
connection_id uuid references public.connection(id) on delete set null,
|
|
45
|
-
expires_at timestamptz not null,
|
|
46
|
-
lease_expires_at timestamptz,
|
|
47
|
-
link_session_id text,
|
|
48
|
-
item_id text,
|
|
49
|
-
result jsonb,
|
|
50
|
-
sync_id uuid references core.sync(id) on delete set null,
|
|
51
|
-
error_code text,
|
|
52
|
-
error_retryable boolean,
|
|
53
|
-
created_at timestamptz not null default now(),
|
|
54
|
-
updated_at timestamptz not null default now(),
|
|
55
|
-
constraint plaid_connect_session_environment_check
|
|
56
|
-
check (environment in ('sandbox', 'production'))
|
|
57
|
-
)
|
|
58
|
-
`.execute(db);
|
|
59
|
-
await sql`
|
|
60
|
-
create index plaid_connect_session_tenant_created_idx
|
|
61
|
-
on public.plaid_connect_session (tenant_id, created_at desc)
|
|
62
|
-
`.execute(db);
|
|
63
|
-
await sql`
|
|
64
|
-
create index plaid_connect_session_recovery_idx
|
|
65
|
-
on public.plaid_connect_session (status, lease_expires_at)
|
|
66
|
-
where status in (
|
|
67
|
-
'exchanging',
|
|
68
|
-
'credentialsStored',
|
|
69
|
-
'discoveringAccounts',
|
|
70
|
-
'configuring'
|
|
71
|
-
)
|
|
72
|
-
`.execute(db);
|
|
73
|
-
|
|
74
|
-
await sql`
|
|
75
|
-
do $$
|
|
76
|
-
begin
|
|
77
|
-
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
78
|
-
grant usage on type
|
|
79
|
-
public.plaid_connect_mode,
|
|
80
|
-
public.plaid_connect_status
|
|
81
|
-
to application;
|
|
82
|
-
grant select, insert, update, delete
|
|
83
|
-
on public.plaid_connect_session
|
|
84
|
-
to application;
|
|
85
|
-
end if;
|
|
86
|
-
end
|
|
87
|
-
$$
|
|
88
|
-
`.execute(db);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
92
|
-
await sql`drop table if exists public.plaid_connect_session`.execute(db);
|
|
93
|
-
await sql`
|
|
94
|
-
drop index if exists accounting.bank_account_connection_persistent_ref_idx
|
|
95
|
-
`.execute(db);
|
|
96
|
-
await sql`
|
|
97
|
-
alter table accounting.bank_account
|
|
98
|
-
drop column if exists persistent_ref
|
|
99
|
-
`.execute(db);
|
|
100
|
-
await sql`drop type if exists public.plaid_connect_status`.execute(db);
|
|
101
|
-
await sql`drop type if exists public.plaid_connect_mode`.execute(db);
|
|
102
|
-
}
|
|
@@ -1,27 +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 to_regprocedure('gen_random_bytes(integer)') is null
|
|
9
|
-
or to_regprocedure('digest(text,text)') is null
|
|
10
|
-
then
|
|
11
|
-
create extension if not exists pgcrypto;
|
|
12
|
-
end if;
|
|
13
|
-
|
|
14
|
-
if to_regprocedure('gen_random_bytes(integer)') is null
|
|
15
|
-
or to_regprocedure('digest(text,text)') is null
|
|
16
|
-
then
|
|
17
|
-
raise exception 'pgcrypto functions are unavailable';
|
|
18
|
-
end if;
|
|
19
|
-
end
|
|
20
|
-
$$
|
|
21
|
-
`.execute(db);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function down(): Promise<void> {
|
|
25
|
-
// Existing databases require pgcrypto for baseline functions, so rollback
|
|
26
|
-
// must not remove the extension.
|
|
27
|
-
}
|
|
@@ -1,36 +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 column unique_ref text;
|
|
8
|
-
`.execute(db);
|
|
9
|
-
|
|
10
|
-
await sql`
|
|
11
|
-
create unique index tenant_partner_unique_ref_unique_idx
|
|
12
|
-
on public.tenant (partner_id, unique_ref)
|
|
13
|
-
where partner_id is not null and unique_ref is not null;
|
|
14
|
-
`.execute(db);
|
|
15
|
-
|
|
16
|
-
await sql`
|
|
17
|
-
create unique index token_partner_secret_unique_idx
|
|
18
|
-
on public.token (nano_id)
|
|
19
|
-
where type in ('partner_api_key', 'embedded_bootstrap');
|
|
20
|
-
`.execute(db);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
24
|
-
await sql`
|
|
25
|
-
drop index if exists public.token_partner_secret_unique_idx;
|
|
26
|
-
`.execute(db);
|
|
27
|
-
|
|
28
|
-
await sql`
|
|
29
|
-
drop index if exists public.tenant_partner_unique_ref_unique_idx;
|
|
30
|
-
`.execute(db);
|
|
31
|
-
|
|
32
|
-
await sql`
|
|
33
|
-
alter table public.tenant
|
|
34
|
-
drop column unique_ref;
|
|
35
|
-
`.execute(db);
|
|
36
|
-
}
|