@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.
Files changed (183) hide show
  1. package/build/.data.tar +0 -0
  2. package/build/main/camel-case/index.js +1 -1
  3. package/build/main/camel-case/index.js.map +1 -1
  4. package/build/main/control-plane/index.d.ts +216 -17
  5. package/build/main/control-plane/index.js +61 -0
  6. package/build/main/control-plane/index.js.map +1 -1
  7. package/build/main/domain.d.ts +4 -0
  8. package/build/main/domain.js +3 -0
  9. package/build/main/domain.js.map +1 -0
  10. package/build/main/index.d.ts +6 -11
  11. package/build/main/index.js +127 -57
  12. package/build/main/index.js.map +1 -1
  13. package/build/main/isomorphic.d.ts +5 -5
  14. package/build/main/isomorphic.js +2 -8
  15. package/build/main/isomorphic.js.map +1 -1
  16. package/build/main/local/digest.d.ts +3 -3
  17. package/build/main/local/digest.js.map +1 -1
  18. package/build/main/local/generate.js +9 -8
  19. package/build/main/local/generate.js.map +1 -1
  20. package/build/main/local/index.d.ts +5 -1
  21. package/build/main/local/index.js +214 -4
  22. package/build/main/local/index.js.map +1 -1
  23. package/build/main/local/prune-pulled-schema.js +4 -1
  24. package/build/main/local/prune-pulled-schema.js.map +1 -1
  25. package/build/main/migration.d.ts +7 -0
  26. package/build/main/migration.js +11 -0
  27. package/build/main/migration.js.map +1 -0
  28. package/build/main/query/listing/status.d.ts +0 -10
  29. package/build/main/query/listing/status.js +2 -14
  30. package/build/main/query/listing/status.js.map +1 -1
  31. package/build/main/query/tenant/status.d.ts +5 -8
  32. package/build/main/query/tenant/status.js +18 -21
  33. package/build/main/query/tenant/status.js.map +1 -1
  34. package/build/main/regional.d.ts +6 -1
  35. package/build/main/regional.js +13 -9
  36. package/build/main/regional.js.map +1 -1
  37. package/build/main/test/index.d.ts +3 -14
  38. package/build/main/test/index.js +0 -23
  39. package/build/main/test/index.js.map +1 -1
  40. package/build/main/transaction.d.ts +3 -3
  41. package/build/main/transaction.js.map +1 -1
  42. package/build/main/v1.generated.d.ts +501 -134
  43. package/build/main/v1.generated.js.map +1 -1
  44. package/build/migrations-v2/0000000000000-baseline.ts +5 -0
  45. package/build/migrations-v2/0000000000001-public-audit-events-v2.ts +137 -0
  46. package/build/migrations-v2/0000000000002-audit-recovery-watermarks.ts +30 -0
  47. package/build/migrations-v2/0000000000003-audit-effect-recovery-watermark.ts +13 -0
  48. package/build/migrations-v2/0000000000004-audit-event-projected-at.ts +15 -0
  49. package/build/migrations-v2/0000000000005-audit-recovery-indexes.ts +63 -0
  50. package/build/migrations-v2/0000000000006-audit-action-public-event-projected-at.ts +22 -0
  51. package/build/migrations-v2/0000000000007-audit-action-public-event-projected-at-backfill.ts +35 -0
  52. package/build/migrations-v2/0000000000008-global-user-attribution.ts +33 -0
  53. package/build/migrations-v2/0000000000008-team-issue-rule-state.ts +52 -0
  54. package/build/migrations-v2/0000000000009-reservation-issue-projections.ts +45 -0
  55. package/build/migrations-v2/0000000000010-bank-rule-application-bank-record-delete-cascade.ts +26 -0
  56. package/build/migrations-v2/0000000000011-guest-balance-journal-entry-lookup-index.ts +25 -0
  57. package/build/migrations-v2/0000000000012-trial-free-analytics-billing-status.ts +72 -0
  58. package/build/migrations-v2/0000000000013-ui-permission-bundles.ts +45 -0
  59. package/build/migrations-v2/0000000000014-ui-permission-bundle-top-up.ts +32 -0
  60. package/build/migrations-v2/0000000000016-managed-team-access.ts +34 -0
  61. package/build/migrations-v2/0000000000017-drop-trial-until.ts +42 -0
  62. package/build/migrations-v2/0000000000018-accounting-integrity-monitoring.ts +276 -0
  63. package/build/migrations-v2/0000000000019-accounting-integrity-run-shards.ts +26 -0
  64. package/build/migrations-v2/0000000000020-accounting-integrity-case-classification.ts +52 -0
  65. package/build/migrations-v2/0000000000021-payment-line-classification-monitor-indexes.ts +31 -0
  66. package/build/migrations-v2/0000000000022-accounting-integrity-controlled-repairs.ts +281 -0
  67. package/build/migrations-v2/0000000000023-line-classification-usage.ts +325 -0
  68. package/build/migrations-v2/0000000000024-tenant-region-migration.ts +108 -0
  69. package/build/migrations-v2/0000000000025-partner-ach-denial-default.ts +30 -0
  70. package/build/migrations-v2/0000000000026-line-classification-usage-capture.ts +399 -0
  71. package/build/migrations-v2/0000000000027-payout-replacement-chain.ts +27 -0
  72. package/build/migrations-v2/0000000000028-accounting-integrity-operator-workflow.ts +108 -0
  73. package/build/migrations-v2/0000000000029-accounting-integrity-definition-artifacts.ts +40 -0
  74. package/build/migrations-v2/0000000000030-accounting-integrity-review-metadata-compatibility.ts +49 -0
  75. package/build/module/camel-case/index.js +1 -1
  76. package/build/module/camel-case/index.js.map +1 -1
  77. package/build/module/control-plane/index.d.ts +216 -17
  78. package/build/module/control-plane/index.js +49 -1
  79. package/build/module/control-plane/index.js.map +1 -1
  80. package/build/module/domain.d.ts +4 -0
  81. package/build/module/domain.js +2 -0
  82. package/build/module/domain.js.map +1 -0
  83. package/build/module/index.d.ts +6 -11
  84. package/build/module/index.js +129 -55
  85. package/build/module/index.js.map +1 -1
  86. package/build/module/isomorphic.d.ts +5 -5
  87. package/build/module/isomorphic.js +1 -6
  88. package/build/module/isomorphic.js.map +1 -1
  89. package/build/module/local/digest.d.ts +3 -3
  90. package/build/module/local/digest.js.map +1 -1
  91. package/build/module/local/generate.js +9 -8
  92. package/build/module/local/generate.js.map +1 -1
  93. package/build/module/local/index.d.ts +5 -1
  94. package/build/module/local/index.js +215 -5
  95. package/build/module/local/index.js.map +1 -1
  96. package/build/module/local/prune-pulled-schema.js +4 -1
  97. package/build/module/local/prune-pulled-schema.js.map +1 -1
  98. package/build/module/migration.d.ts +7 -0
  99. package/build/module/migration.js +8 -0
  100. package/build/module/migration.js.map +1 -0
  101. package/build/module/query/listing/status.d.ts +0 -10
  102. package/build/module/query/listing/status.js +2 -12
  103. package/build/module/query/listing/status.js.map +1 -1
  104. package/build/module/query/tenant/status.d.ts +5 -8
  105. package/build/module/query/tenant/status.js +18 -21
  106. package/build/module/query/tenant/status.js.map +1 -1
  107. package/build/module/regional.d.ts +6 -1
  108. package/build/module/regional.js +13 -9
  109. package/build/module/regional.js.map +1 -1
  110. package/build/module/test/index.d.ts +3 -14
  111. package/build/module/test/index.js +1 -23
  112. package/build/module/test/index.js.map +1 -1
  113. package/build/module/transaction.d.ts +3 -3
  114. package/build/module/transaction.js.map +1 -1
  115. package/build/module/v1.generated.d.ts +501 -134
  116. package/build/module/v1.generated.js.map +1 -1
  117. package/package.json +3 -3
  118. package/build/migrations/0000000000001-init.ts +0 -5
  119. package/build/migrations/0000000000009-drop-store-schema.ts +0 -14
  120. package/build/migrations/0000000000010-bank-rules.ts +0 -190
  121. package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +0 -65
  122. package/build/migrations/0000000000012-bank-rule-conditions.ts +0 -45
  123. package/build/migrations/0000000000013-bank-rule-name-unique.ts +0 -15
  124. package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +0 -41
  125. package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +0 -70
  126. package/build/migrations/0000000000016-owner-statement-draft-status.ts +0 -22
  127. package/build/migrations/0000000000017-tenant-migration-markers.ts +0 -18
  128. package/build/migrations/0000000000018-security-deposits-payable-category.ts +0 -63
  129. package/build/migrations/0000000000019-tenant-app-settings.ts +0 -76
  130. package/build/migrations/0000000000020-operating-opening-trial-balance.ts +0 -36
  131. package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +0 -77
  132. package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +0 -30
  133. package/build/migrations/0000000000023-journal-entry-currency-mismatch-reason.ts +0 -14
  134. package/build/migrations/0000000000024-listing-parent.ts +0 -37
  135. package/build/migrations/0000000000025-journal-entry-parent-listing.ts +0 -26
  136. package/build/migrations/0000000000026-booking-channel-logo-slots.ts +0 -89
  137. package/build/migrations/0000000000027-list-browse-performance-indexes.ts +0 -52
  138. package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +0 -20
  139. package/build/migrations/0000000000029-tenant-slug.ts +0 -328
  140. package/build/migrations/0000000000030-pms-accounting-windows.ts +0 -50
  141. package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +0 -20
  142. package/build/migrations/0000000000032-flow-event-listening.ts +0 -28
  143. package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +0 -272
  144. package/build/migrations/0000000000034-historic-general-ledger.ts +0 -24
  145. package/build/migrations/0000000000035-tenant-regional-placement.ts +0 -37
  146. package/build/migrations/0000000000036-control-plane-projection-events.ts +0 -43
  147. package/build/migrations/0000000000037-tenant-guide-onboarding.ts +0 -21
  148. package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +0 -31
  149. package/build/migrations/0000000000039-crunchy-region.ts +0 -86
  150. package/build/migrations/0000000000040-hostaway-region.ts +0 -72
  151. package/build/migrations/0000000000041-audit-tenant-fk.ts +0 -66
  152. package/build/migrations/0000000000042-ramp-staging-connect-params.ts +0 -35
  153. package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +0 -125
  154. package/build/migrations/0000000000044-tenant-cross-region-fks.ts +0 -45
  155. package/build/migrations/0000000000045-cloudflare-region-env.ts +0 -100
  156. package/build/migrations/0000000000046-control-plane-outbox-alias.ts +0 -46
  157. package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +0 -16
  158. package/build/migrations/0000000000047-tenant-status-backfill.ts +0 -40
  159. package/build/migrations/0000000000048-tenant-status-constraint.ts +0 -24
  160. package/build/migrations/0000000000049-health-tenant-issues.ts +0 -69
  161. package/build/migrations/0000000000050-partner-webhooks.ts +0 -135
  162. package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +0 -42
  163. package/build/migrations/0000000000052-feature-approval-team-enablement.ts +0 -13
  164. package/build/migrations/0000000000053-health-webhook-enums.ts +0 -296
  165. package/build/migrations/0000000000054-user-secondary-emails-jsonb.ts +0 -25
  166. package/build/migrations/0000000000055-outbound-webhooks-v1.ts +0 -221
  167. package/build/migrations/0000000000056-connection-webhook-version.ts +0 -18
  168. package/build/migrations/0000000000057-sync-webhook-version.ts +0 -18
  169. package/build/migrations/0000000000058-reservation-webhook-version.ts +0 -18
  170. package/build/migrations/0000000000059-listing-webhook-version.ts +0 -18
  171. package/build/migrations/0000000000060-owner-statement-webhook-version.ts +0 -19
  172. package/build/migrations/0000000000061-transaction-webhook-version.ts +0 -18
  173. package/build/migrations/0000000000062-plaid-connect-session.ts +0 -102
  174. package/build/migrations/0000000000063-pgcrypto.ts +0 -27
  175. package/build/migrations/0000000000064-partner-api-foundation.ts +0 -36
  176. package/build/migrations/0000000000065-canonical-jsonb-shapes.ts +0 -231
  177. package/build/migrations/0000000000066-source-delete-fk-indexes.ts +0 -20
  178. package/build/migrations/0000000000067-remove-opening-trial-balance-account-columns.ts +0 -34
  179. package/build/migrations/0000000000068-bank-record-account-delete-cascade.ts +0 -26
  180. package/build/migrations/0000000000069-account-connections.ts +0 -204
  181. package/build/migrations/0000000000070-provider-payment-projection-indexes.ts +0 -53
  182. package/build/migrations/0000000000071-tenant-app-settings-shape.ts +0 -39
  183. package/build/migrations/0000000000072-tenant-app-settings-shape-validation.ts +0 -11
@@ -1,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
- }