@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.
- 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,135 +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`create schema if not exists webhook;`.execute(db);
|
|
6
|
-
|
|
7
|
-
await sql`
|
|
8
|
-
create table webhook.subscription (
|
|
9
|
-
id uuid primary key default gen_random_uuid(),
|
|
10
|
-
owner_tenant_id uuid not null,
|
|
11
|
-
scope text not null,
|
|
12
|
-
url text not null,
|
|
13
|
-
status text not null default 'pending',
|
|
14
|
-
api_version text not null,
|
|
15
|
-
event_types text[] not null,
|
|
16
|
-
description text,
|
|
17
|
-
verified_at timestamptz,
|
|
18
|
-
disabled_at timestamptz,
|
|
19
|
-
created_at timestamptz not null default now(),
|
|
20
|
-
updated_at timestamptz not null default now(),
|
|
21
|
-
constraint webhook_subscription_scope_check
|
|
22
|
-
check (scope in ('self', 'managedTeams')),
|
|
23
|
-
constraint webhook_subscription_status_check
|
|
24
|
-
check (status in ('pending', 'active', 'disabled')),
|
|
25
|
-
constraint webhook_subscription_event_types_check
|
|
26
|
-
check (cardinality(event_types) > 0)
|
|
27
|
-
);
|
|
28
|
-
`.execute(db);
|
|
29
|
-
|
|
30
|
-
await sql`
|
|
31
|
-
create index webhook_subscription_owner_idx
|
|
32
|
-
on webhook.subscription (owner_tenant_id, created_at desc);
|
|
33
|
-
`.execute(db);
|
|
34
|
-
|
|
35
|
-
await sql`
|
|
36
|
-
create table webhook.subscription_secret (
|
|
37
|
-
id uuid primary key default gen_random_uuid(),
|
|
38
|
-
subscription_id uuid not null
|
|
39
|
-
references webhook.subscription(id) on delete cascade,
|
|
40
|
-
encrypted_secret text not null,
|
|
41
|
-
encryption_key_id text not null,
|
|
42
|
-
active_from timestamptz not null default now(),
|
|
43
|
-
expires_at timestamptz,
|
|
44
|
-
revoked_at timestamptz,
|
|
45
|
-
created_at timestamptz not null default now()
|
|
46
|
-
);
|
|
47
|
-
`.execute(db);
|
|
48
|
-
|
|
49
|
-
await sql`
|
|
50
|
-
create index webhook_subscription_secret_active_idx
|
|
51
|
-
on webhook.subscription_secret (subscription_id, active_from desc);
|
|
52
|
-
`.execute(db);
|
|
53
|
-
|
|
54
|
-
await sql`
|
|
55
|
-
create table webhook.delivery (
|
|
56
|
-
id uuid primary key default gen_random_uuid(),
|
|
57
|
-
source_event_key text not null,
|
|
58
|
-
subscription_id uuid not null
|
|
59
|
-
references webhook.subscription(id) on delete cascade,
|
|
60
|
-
source_tenant_id uuid,
|
|
61
|
-
event_type text not null,
|
|
62
|
-
api_version text not null,
|
|
63
|
-
resource_type text,
|
|
64
|
-
resource_id text,
|
|
65
|
-
body text not null,
|
|
66
|
-
status text not null default 'queued',
|
|
67
|
-
attempt_count integer not null default 0,
|
|
68
|
-
next_attempt_at timestamptz not null default now(),
|
|
69
|
-
claimed_at timestamptz,
|
|
70
|
-
claimed_by text,
|
|
71
|
-
last_error_code text,
|
|
72
|
-
delivered_at timestamptz,
|
|
73
|
-
failed_at timestamptz,
|
|
74
|
-
created_at timestamptz not null default now(),
|
|
75
|
-
updated_at timestamptz not null default now(),
|
|
76
|
-
constraint webhook_delivery_subscription_event_key
|
|
77
|
-
unique (subscription_id, source_event_key),
|
|
78
|
-
constraint webhook_delivery_status_check
|
|
79
|
-
check (
|
|
80
|
-
status in (
|
|
81
|
-
'queued',
|
|
82
|
-
'delivering',
|
|
83
|
-
'retrying',
|
|
84
|
-
'succeeded',
|
|
85
|
-
'failed',
|
|
86
|
-
'canceled'
|
|
87
|
-
)
|
|
88
|
-
),
|
|
89
|
-
constraint webhook_delivery_attempt_count_check check (attempt_count >= 0)
|
|
90
|
-
);
|
|
91
|
-
`.execute(db);
|
|
92
|
-
|
|
93
|
-
await sql`
|
|
94
|
-
create index webhook_delivery_recovery_idx
|
|
95
|
-
on webhook.delivery (status, next_attempt_at);
|
|
96
|
-
`.execute(db);
|
|
97
|
-
await sql`
|
|
98
|
-
create index webhook_delivery_subscription_created_idx
|
|
99
|
-
on webhook.delivery (subscription_id, created_at desc);
|
|
100
|
-
`.execute(db);
|
|
101
|
-
await sql`
|
|
102
|
-
create index webhook_delivery_source_tenant_created_idx
|
|
103
|
-
on webhook.delivery (source_tenant_id, created_at desc);
|
|
104
|
-
`.execute(db);
|
|
105
|
-
|
|
106
|
-
await sql`
|
|
107
|
-
create table webhook.delivery_attempt (
|
|
108
|
-
id uuid primary key default gen_random_uuid(),
|
|
109
|
-
delivery_id uuid not null references webhook.delivery(id) on delete cascade,
|
|
110
|
-
subscription_secret_id uuid not null
|
|
111
|
-
references webhook.subscription_secret(id) on delete restrict,
|
|
112
|
-
attempt_number integer not null,
|
|
113
|
-
started_at timestamptz not null,
|
|
114
|
-
finished_at timestamptz not null,
|
|
115
|
-
duration_ms integer not null,
|
|
116
|
-
response_status integer,
|
|
117
|
-
error_class text,
|
|
118
|
-
response_excerpt text,
|
|
119
|
-
created_at timestamptz not null default now(),
|
|
120
|
-
constraint webhook_delivery_attempt_number_key
|
|
121
|
-
unique (delivery_id, attempt_number),
|
|
122
|
-
constraint webhook_delivery_attempt_number_check check (attempt_number > 0),
|
|
123
|
-
constraint webhook_delivery_attempt_duration_check check (duration_ms >= 0)
|
|
124
|
-
);
|
|
125
|
-
`.execute(db);
|
|
126
|
-
|
|
127
|
-
await sql`
|
|
128
|
-
create index webhook_delivery_attempt_delivery_created_idx
|
|
129
|
-
on webhook.delivery_attempt (delivery_id, created_at);
|
|
130
|
-
`.execute(db);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
134
|
-
await sql`drop schema if exists webhook cascade;`.execute(db);
|
|
135
|
-
}
|
|
@@ -1,42 +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
|
-
do $$
|
|
7
|
-
begin
|
|
8
|
-
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
9
|
-
grant usage on schema health, webhook to application;
|
|
10
|
-
grant select, insert, update, delete
|
|
11
|
-
on all tables in schema health, webhook to application;
|
|
12
|
-
grant usage, select, update
|
|
13
|
-
on all sequences in schema health, webhook to application;
|
|
14
|
-
alter default privileges in schema health, webhook
|
|
15
|
-
grant select, insert, update, delete on tables to application;
|
|
16
|
-
alter default privileges in schema health, webhook
|
|
17
|
-
grant usage, select, update on sequences to application;
|
|
18
|
-
end if;
|
|
19
|
-
end
|
|
20
|
-
$$;
|
|
21
|
-
`.execute(db);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function down(db: Kysely<any>): Promise<void> {
|
|
25
|
-
await sql`
|
|
26
|
-
do $$
|
|
27
|
-
begin
|
|
28
|
-
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
29
|
-
alter default privileges in schema health, webhook
|
|
30
|
-
revoke select, insert, update, delete on tables from application;
|
|
31
|
-
alter default privileges in schema health, webhook
|
|
32
|
-
revoke usage, select, update on sequences from application;
|
|
33
|
-
revoke select, insert, update, delete
|
|
34
|
-
on all tables in schema health, webhook from application;
|
|
35
|
-
revoke usage, select, update
|
|
36
|
-
on all sequences in schema health, webhook from application;
|
|
37
|
-
revoke usage on schema health, webhook from application;
|
|
38
|
-
end if;
|
|
39
|
-
end
|
|
40
|
-
$$;
|
|
41
|
-
`.execute(db);
|
|
42
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Kysely } from 'kysely';
|
|
2
|
-
|
|
3
|
-
// CUS-2503: retained as a no-op because this migration name reached staging.
|
|
4
|
-
// Feature evaluation belongs in /me and must not manufacture team enablements
|
|
5
|
-
// from user approvals. Keeping the file lets environments with an existing
|
|
6
|
-
// migration-ledger entry continue to migrate safely.
|
|
7
|
-
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
8
|
-
void db;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
12
|
-
void db;
|
|
13
|
-
}
|
|
@@ -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
|
-
}
|