@vrplatform/kysely 1.3.45-5070 → 1.3.45-5080
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/.data.tar +0 -0
- package/build/main/local/generate.js +8 -8
- package/build/main/local/generate.js.map +1 -1
- package/build/main/local/index.js +5 -4
- package/build/main/local/index.js.map +1 -1
- package/build/main/migration.d.ts +7 -0
- package/build/main/migration.js +11 -0
- package/build/main/migration.js.map +1 -0
- package/build/main/v1.generated.d.ts +142 -134
- package/build/main/v1.generated.js.map +1 -1
- package/build/migrations-v2/0000000000000-baseline.ts +5 -0
- package/build/module/local/generate.js +8 -8
- package/build/module/local/generate.js.map +1 -1
- package/build/module/local/index.js +5 -4
- package/build/module/local/index.js.map +1 -1
- package/build/module/migration.d.ts +7 -0
- package/build/module/migration.js +8 -0
- package/build/module/migration.js.map +1 -0
- package/build/module/v1.generated.d.ts +142 -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
- package/build/migrations/0000000000073-public-audit-events.ts +0 -241
|
@@ -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
|
-
}
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import type { Kysely } from 'kysely';
|
|
2
|
-
import { sql } from 'kysely';
|
|
3
|
-
|
|
4
|
-
export async function backfillCanonicalJsonbShapes(
|
|
5
|
-
db: Kysely<unknown>
|
|
6
|
-
): Promise<void> {
|
|
7
|
-
await sql`
|
|
8
|
-
update public.connection
|
|
9
|
-
set credentials = (credentials #>> '{}')::jsonb
|
|
10
|
-
where jsonb_typeof(credentials) = 'string'
|
|
11
|
-
`.execute(db);
|
|
12
|
-
await sql`
|
|
13
|
-
update public.connection
|
|
14
|
-
set persistent_state = (persistent_state #>> '{}')::jsonb
|
|
15
|
-
where jsonb_typeof(persistent_state) = 'string'
|
|
16
|
-
`.execute(db);
|
|
17
|
-
await sql`
|
|
18
|
-
update public.feature
|
|
19
|
-
set required_approvals = (required_approvals #>> '{}')::jsonb
|
|
20
|
-
where jsonb_typeof(required_approvals) = 'string'
|
|
21
|
-
`.execute(db);
|
|
22
|
-
await sql`
|
|
23
|
-
update accounting.transaction
|
|
24
|
-
set recurring_pattern = (recurring_pattern #>> '{}')::jsonb
|
|
25
|
-
where jsonb_typeof(recurring_pattern) = 'string'
|
|
26
|
-
`.execute(db);
|
|
27
|
-
await sql`
|
|
28
|
-
update public.source
|
|
29
|
-
set json = (json #>> '{}')::jsonb
|
|
30
|
-
where type = 'ownerStatement'
|
|
31
|
-
and jsonb_typeof(json) = 'string'
|
|
32
|
-
`.execute(db);
|
|
33
|
-
await sql`
|
|
34
|
-
update accounting.owner_statement_projection
|
|
35
|
-
set payload = (payload #>> '{}')::jsonb
|
|
36
|
-
where jsonb_typeof(payload) = 'string'
|
|
37
|
-
`.execute(db);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const canonicalJsonbShapeConstraintTargets = [
|
|
41
|
-
'connection',
|
|
42
|
-
'feature',
|
|
43
|
-
'transaction',
|
|
44
|
-
'source',
|
|
45
|
-
'ownerStatementProjection',
|
|
46
|
-
] as const;
|
|
47
|
-
|
|
48
|
-
type CanonicalJsonbShapeConstraintTarget =
|
|
49
|
-
(typeof canonicalJsonbShapeConstraintTargets)[number];
|
|
50
|
-
|
|
51
|
-
export async function addCanonicalJsonbShapeConstraints(
|
|
52
|
-
db: Kysely<unknown>,
|
|
53
|
-
target: CanonicalJsonbShapeConstraintTarget
|
|
54
|
-
): Promise<void> {
|
|
55
|
-
if (target === 'connection') {
|
|
56
|
-
await sql`
|
|
57
|
-
do $$
|
|
58
|
-
begin
|
|
59
|
-
if not exists (
|
|
60
|
-
select 1 from pg_constraint
|
|
61
|
-
where conname = 'connection_credentials_object_check'
|
|
62
|
-
and conrelid = 'public.connection'::regclass
|
|
63
|
-
) then
|
|
64
|
-
alter table public.connection
|
|
65
|
-
add constraint connection_credentials_object_check
|
|
66
|
-
check (
|
|
67
|
-
credentials is null
|
|
68
|
-
or jsonb_typeof(credentials) = 'object'
|
|
69
|
-
) not valid;
|
|
70
|
-
end if;
|
|
71
|
-
if not exists (
|
|
72
|
-
select 1 from pg_constraint
|
|
73
|
-
where conname = 'connection_persistent_state_object_check'
|
|
74
|
-
and conrelid = 'public.connection'::regclass
|
|
75
|
-
) then
|
|
76
|
-
alter table public.connection
|
|
77
|
-
add constraint connection_persistent_state_object_check
|
|
78
|
-
check (
|
|
79
|
-
persistent_state is null
|
|
80
|
-
or jsonb_typeof(persistent_state) = 'object'
|
|
81
|
-
) not valid;
|
|
82
|
-
end if;
|
|
83
|
-
end
|
|
84
|
-
$$
|
|
85
|
-
`.execute(db);
|
|
86
|
-
} else if (target === 'feature') {
|
|
87
|
-
await sql`
|
|
88
|
-
do $$
|
|
89
|
-
begin
|
|
90
|
-
if not exists (
|
|
91
|
-
select 1 from pg_constraint
|
|
92
|
-
where conname = 'feature_required_approvals_array_check'
|
|
93
|
-
and conrelid = 'public.feature'::regclass
|
|
94
|
-
) then
|
|
95
|
-
alter table public.feature
|
|
96
|
-
add constraint feature_required_approvals_array_check
|
|
97
|
-
check (
|
|
98
|
-
required_approvals is null
|
|
99
|
-
or jsonb_typeof(required_approvals) = 'array'
|
|
100
|
-
) not valid;
|
|
101
|
-
end if;
|
|
102
|
-
end
|
|
103
|
-
$$
|
|
104
|
-
`.execute(db);
|
|
105
|
-
} else if (target === 'transaction') {
|
|
106
|
-
await sql`
|
|
107
|
-
do $$
|
|
108
|
-
begin
|
|
109
|
-
if not exists (
|
|
110
|
-
select 1 from pg_constraint
|
|
111
|
-
where conname = 'transaction_recurring_pattern_object_check'
|
|
112
|
-
and conrelid = 'accounting.transaction'::regclass
|
|
113
|
-
) then
|
|
114
|
-
alter table accounting.transaction
|
|
115
|
-
add constraint transaction_recurring_pattern_object_check
|
|
116
|
-
check (
|
|
117
|
-
recurring_pattern is null
|
|
118
|
-
or jsonb_typeof(recurring_pattern) = 'object'
|
|
119
|
-
) not valid;
|
|
120
|
-
end if;
|
|
121
|
-
end
|
|
122
|
-
$$
|
|
123
|
-
`.execute(db);
|
|
124
|
-
} else if (target === 'source') {
|
|
125
|
-
await sql`
|
|
126
|
-
do $$
|
|
127
|
-
begin
|
|
128
|
-
if not exists (
|
|
129
|
-
select 1 from pg_constraint
|
|
130
|
-
where conname = 'source_owner_statement_json_object_check'
|
|
131
|
-
and conrelid = 'public.source'::regclass
|
|
132
|
-
) then
|
|
133
|
-
alter table public.source
|
|
134
|
-
add constraint source_owner_statement_json_object_check
|
|
135
|
-
check (
|
|
136
|
-
type <> 'ownerStatement'
|
|
137
|
-
or json is null
|
|
138
|
-
or jsonb_typeof(json) = 'object'
|
|
139
|
-
) not valid;
|
|
140
|
-
end if;
|
|
141
|
-
end
|
|
142
|
-
$$
|
|
143
|
-
`.execute(db);
|
|
144
|
-
} else {
|
|
145
|
-
await sql`
|
|
146
|
-
do $$
|
|
147
|
-
begin
|
|
148
|
-
if not exists (
|
|
149
|
-
select 1 from pg_constraint
|
|
150
|
-
where conname = 'owner_statement_projection_payload_container_check'
|
|
151
|
-
and conrelid = 'accounting.owner_statement_projection'::regclass
|
|
152
|
-
) then
|
|
153
|
-
alter table accounting.owner_statement_projection
|
|
154
|
-
add constraint owner_statement_projection_payload_container_check
|
|
155
|
-
check (jsonb_typeof(payload) in ('array', 'object')) not valid;
|
|
156
|
-
end if;
|
|
157
|
-
end
|
|
158
|
-
$$
|
|
159
|
-
`.execute(db);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export async function validateCanonicalJsonbShapeConstraints(
|
|
164
|
-
db: Kysely<unknown>,
|
|
165
|
-
target: CanonicalJsonbShapeConstraintTarget
|
|
166
|
-
): Promise<void> {
|
|
167
|
-
if (target === 'connection') {
|
|
168
|
-
await sql`
|
|
169
|
-
alter table public.connection
|
|
170
|
-
validate constraint connection_credentials_object_check
|
|
171
|
-
`.execute(db);
|
|
172
|
-
await sql`
|
|
173
|
-
alter table public.connection
|
|
174
|
-
validate constraint connection_persistent_state_object_check
|
|
175
|
-
`.execute(db);
|
|
176
|
-
} else if (target === 'feature') {
|
|
177
|
-
await sql`
|
|
178
|
-
alter table public.feature
|
|
179
|
-
validate constraint feature_required_approvals_array_check
|
|
180
|
-
`.execute(db);
|
|
181
|
-
} else if (target === 'transaction') {
|
|
182
|
-
await sql`
|
|
183
|
-
alter table accounting.transaction
|
|
184
|
-
validate constraint transaction_recurring_pattern_object_check
|
|
185
|
-
`.execute(db);
|
|
186
|
-
} else if (target === 'source') {
|
|
187
|
-
await sql`
|
|
188
|
-
alter table public.source
|
|
189
|
-
validate constraint source_owner_statement_json_object_check
|
|
190
|
-
`.execute(db);
|
|
191
|
-
} else {
|
|
192
|
-
await sql`
|
|
193
|
-
alter table accounting.owner_statement_projection
|
|
194
|
-
validate constraint owner_statement_projection_payload_container_check
|
|
195
|
-
`.execute(db);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
200
|
-
await backfillCanonicalJsonbShapes(db);
|
|
201
|
-
for (const target of canonicalJsonbShapeConstraintTargets) {
|
|
202
|
-
await addCanonicalJsonbShapeConstraints(db, target);
|
|
203
|
-
}
|
|
204
|
-
for (const target of canonicalJsonbShapeConstraintTargets) {
|
|
205
|
-
await validateCanonicalJsonbShapeConstraints(db, target);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
210
|
-
await sql`
|
|
211
|
-
alter table accounting.owner_statement_projection
|
|
212
|
-
drop constraint if exists owner_statement_projection_payload_container_check
|
|
213
|
-
`.execute(db);
|
|
214
|
-
await sql`
|
|
215
|
-
alter table public.source
|
|
216
|
-
drop constraint if exists source_owner_statement_json_object_check
|
|
217
|
-
`.execute(db);
|
|
218
|
-
await sql`
|
|
219
|
-
alter table accounting.transaction
|
|
220
|
-
drop constraint if exists transaction_recurring_pattern_object_check
|
|
221
|
-
`.execute(db);
|
|
222
|
-
await sql`
|
|
223
|
-
alter table public.feature
|
|
224
|
-
drop constraint if exists feature_required_approvals_array_check
|
|
225
|
-
`.execute(db);
|
|
226
|
-
await sql`
|
|
227
|
-
alter table public.connection
|
|
228
|
-
drop constraint if exists connection_persistent_state_object_check,
|
|
229
|
-
drop constraint if exists connection_credentials_object_check
|
|
230
|
-
`.execute(db);
|
|
231
|
-
}
|
|
@@ -1,20 +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
|
-
create index flow_mapping_source_id_idx
|
|
7
|
-
on core.flow_mapping (source_id)
|
|
8
|
-
`.execute(db);
|
|
9
|
-
await sql`
|
|
10
|
-
create index file_storage_source_link_source_id_idx
|
|
11
|
-
on public.file_storage_source_link (source_id)
|
|
12
|
-
`.execute(db);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
16
|
-
await sql`
|
|
17
|
-
drop index public.file_storage_source_link_source_id_idx
|
|
18
|
-
`.execute(db);
|
|
19
|
-
await sql`drop index core.flow_mapping_source_id_idx`.execute(db);
|
|
20
|
-
}
|
|
@@ -1,34 +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 exists (
|
|
9
|
-
select 1
|
|
10
|
-
from accounting.transaction
|
|
11
|
-
where unique_ref = 'openingTrialBalance'
|
|
12
|
-
) then
|
|
13
|
-
raise exception
|
|
14
|
-
'Run the PRO-16921 opening trial balance repository migration first';
|
|
15
|
-
end if;
|
|
16
|
-
end
|
|
17
|
-
$$
|
|
18
|
-
`.execute(db);
|
|
19
|
-
|
|
20
|
-
await sql`
|
|
21
|
-
alter table accounting.account
|
|
22
|
-
drop column if exists opening_trial_balance_combined_cent_total,
|
|
23
|
-
drop column if exists opening_trial_balance_updated_at
|
|
24
|
-
`.execute(db);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
28
|
-
await sql`
|
|
29
|
-
alter table accounting.account
|
|
30
|
-
add column if not exists opening_trial_balance_combined_cent_total
|
|
31
|
-
bigint not null default 0,
|
|
32
|
-
add column if not exists opening_trial_balance_updated_at timestamptz
|
|
33
|
-
`.execute(db);
|
|
34
|
-
}
|
|
@@ -1,26 +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 accounting.bank_record
|
|
7
|
-
drop constraint bank_record_account_id_fkey,
|
|
8
|
-
add constraint bank_record_account_id_fkey
|
|
9
|
-
foreign key (account_id)
|
|
10
|
-
references accounting.account(id)
|
|
11
|
-
on update restrict
|
|
12
|
-
on delete cascade
|
|
13
|
-
`.execute(db);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
17
|
-
await sql`
|
|
18
|
-
alter table accounting.bank_record
|
|
19
|
-
drop constraint bank_record_account_id_fkey,
|
|
20
|
-
add constraint bank_record_account_id_fkey
|
|
21
|
-
foreign key (account_id)
|
|
22
|
-
references accounting.account(id)
|
|
23
|
-
on update restrict
|
|
24
|
-
on delete restrict
|
|
25
|
-
`.execute(db);
|
|
26
|
-
}
|
|
@@ -1,204 +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 accounting.bank_account
|
|
7
|
-
rename to account_connection
|
|
8
|
-
`.execute(db);
|
|
9
|
-
await sql`
|
|
10
|
-
alter table accounting.bank_record
|
|
11
|
-
rename column bank_account_id to account_connection_id
|
|
12
|
-
`.execute(db);
|
|
13
|
-
|
|
14
|
-
await sql`
|
|
15
|
-
alter table accounting.account_connection
|
|
16
|
-
rename constraint bank_account_pkey to account_connection_pkey
|
|
17
|
-
`.execute(db);
|
|
18
|
-
await sql`
|
|
19
|
-
alter table accounting.account_connection
|
|
20
|
-
rename constraint bank_account_connection_id_unique_ref_key
|
|
21
|
-
to account_connection_connection_id_unique_ref_key
|
|
22
|
-
`.execute(db);
|
|
23
|
-
await sql`
|
|
24
|
-
alter table accounting.account_connection
|
|
25
|
-
rename constraint bank_account_source_id_key
|
|
26
|
-
to account_connection_source_id_key
|
|
27
|
-
`.execute(db);
|
|
28
|
-
await sql`
|
|
29
|
-
alter table accounting.account_connection
|
|
30
|
-
rename constraint bank_account_account_id_fkey
|
|
31
|
-
to account_connection_account_id_fkey
|
|
32
|
-
`.execute(db);
|
|
33
|
-
await sql`
|
|
34
|
-
alter table accounting.account_connection
|
|
35
|
-
rename constraint bank_account_category_fkey
|
|
36
|
-
to account_connection_category_fkey
|
|
37
|
-
`.execute(db);
|
|
38
|
-
await sql`
|
|
39
|
-
alter table accounting.account_connection
|
|
40
|
-
rename constraint bank_account_connection_id_fkey
|
|
41
|
-
to account_connection_connection_id_fkey
|
|
42
|
-
`.execute(db);
|
|
43
|
-
await sql`
|
|
44
|
-
alter table accounting.account_connection
|
|
45
|
-
rename constraint bank_account_currency_fkey
|
|
46
|
-
to account_connection_currency_fkey
|
|
47
|
-
`.execute(db);
|
|
48
|
-
await sql`
|
|
49
|
-
alter table accounting.account_connection
|
|
50
|
-
rename constraint bank_account_source_id_fkey
|
|
51
|
-
to account_connection_source_id_fkey
|
|
52
|
-
`.execute(db);
|
|
53
|
-
await sql`
|
|
54
|
-
alter table accounting.account_connection
|
|
55
|
-
rename constraint bank_account_starting_bank_record_id_fkey
|
|
56
|
-
to account_connection_starting_bank_record_id_fkey
|
|
57
|
-
`.execute(db);
|
|
58
|
-
await sql`
|
|
59
|
-
alter table accounting.account_connection
|
|
60
|
-
rename constraint bank_account_status_fkey
|
|
61
|
-
to account_connection_status_fkey
|
|
62
|
-
`.execute(db);
|
|
63
|
-
await sql`
|
|
64
|
-
alter table accounting.account_connection
|
|
65
|
-
rename constraint bank_account_tenant_id_fkey
|
|
66
|
-
to account_connection_tenant_id_fkey
|
|
67
|
-
`.execute(db);
|
|
68
|
-
await sql`
|
|
69
|
-
alter table accounting.account_connection
|
|
70
|
-
rename constraint bank_account_type_fkey
|
|
71
|
-
to account_connection_type_fkey
|
|
72
|
-
`.execute(db);
|
|
73
|
-
|
|
74
|
-
await sql`
|
|
75
|
-
alter table accounting.bank_record
|
|
76
|
-
rename constraint bank_record_bank_account_id_unique_ref_key
|
|
77
|
-
to bank_record_account_connection_id_unique_ref_key
|
|
78
|
-
`.execute(db);
|
|
79
|
-
await sql`
|
|
80
|
-
alter table accounting.bank_record
|
|
81
|
-
rename constraint bank_record_bank_account_id_fkey
|
|
82
|
-
to bank_record_account_connection_id_fkey
|
|
83
|
-
`.execute(db);
|
|
84
|
-
|
|
85
|
-
await sql`
|
|
86
|
-
alter index accounting.bank_account_connection_persistent_ref_idx
|
|
87
|
-
rename to account_connection_connection_persistent_ref_idx
|
|
88
|
-
`.execute(db);
|
|
89
|
-
await sql`
|
|
90
|
-
alter index accounting.bank_record_bank_account_id_tenant_id_idx
|
|
91
|
-
rename to bank_record_account_connection_id_tenant_id_idx
|
|
92
|
-
`.execute(db);
|
|
93
|
-
await sql`
|
|
94
|
-
alter trigger set_accounting_bank_account_updated_at
|
|
95
|
-
on accounting.account_connection
|
|
96
|
-
rename to set_accounting_account_connection_updated_at
|
|
97
|
-
`.execute(db);
|
|
98
|
-
await sql`
|
|
99
|
-
update public.source
|
|
100
|
-
set type = 'accountConnection'
|
|
101
|
-
where type = 'bankAccount'
|
|
102
|
-
`.execute(db);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
106
|
-
await sql`
|
|
107
|
-
update public.source
|
|
108
|
-
set type = 'bankAccount'
|
|
109
|
-
where type = 'accountConnection'
|
|
110
|
-
`.execute(db);
|
|
111
|
-
await sql`
|
|
112
|
-
alter trigger set_accounting_account_connection_updated_at
|
|
113
|
-
on accounting.account_connection
|
|
114
|
-
rename to set_accounting_bank_account_updated_at
|
|
115
|
-
`.execute(db);
|
|
116
|
-
await sql`
|
|
117
|
-
alter index accounting.bank_record_account_connection_id_tenant_id_idx
|
|
118
|
-
rename to bank_record_bank_account_id_tenant_id_idx
|
|
119
|
-
`.execute(db);
|
|
120
|
-
await sql`
|
|
121
|
-
alter index accounting.account_connection_connection_persistent_ref_idx
|
|
122
|
-
rename to bank_account_connection_persistent_ref_idx
|
|
123
|
-
`.execute(db);
|
|
124
|
-
|
|
125
|
-
await sql`
|
|
126
|
-
alter table accounting.bank_record
|
|
127
|
-
rename constraint bank_record_account_connection_id_fkey
|
|
128
|
-
to bank_record_bank_account_id_fkey
|
|
129
|
-
`.execute(db);
|
|
130
|
-
await sql`
|
|
131
|
-
alter table accounting.bank_record
|
|
132
|
-
rename constraint bank_record_account_connection_id_unique_ref_key
|
|
133
|
-
to bank_record_bank_account_id_unique_ref_key
|
|
134
|
-
`.execute(db);
|
|
135
|
-
|
|
136
|
-
await sql`
|
|
137
|
-
alter table accounting.account_connection
|
|
138
|
-
rename constraint account_connection_type_fkey
|
|
139
|
-
to bank_account_type_fkey
|
|
140
|
-
`.execute(db);
|
|
141
|
-
await sql`
|
|
142
|
-
alter table accounting.account_connection
|
|
143
|
-
rename constraint account_connection_tenant_id_fkey
|
|
144
|
-
to bank_account_tenant_id_fkey
|
|
145
|
-
`.execute(db);
|
|
146
|
-
await sql`
|
|
147
|
-
alter table accounting.account_connection
|
|
148
|
-
rename constraint account_connection_status_fkey
|
|
149
|
-
to bank_account_status_fkey
|
|
150
|
-
`.execute(db);
|
|
151
|
-
await sql`
|
|
152
|
-
alter table accounting.account_connection
|
|
153
|
-
rename constraint account_connection_starting_bank_record_id_fkey
|
|
154
|
-
to bank_account_starting_bank_record_id_fkey
|
|
155
|
-
`.execute(db);
|
|
156
|
-
await sql`
|
|
157
|
-
alter table accounting.account_connection
|
|
158
|
-
rename constraint account_connection_source_id_fkey
|
|
159
|
-
to bank_account_source_id_fkey
|
|
160
|
-
`.execute(db);
|
|
161
|
-
await sql`
|
|
162
|
-
alter table accounting.account_connection
|
|
163
|
-
rename constraint account_connection_currency_fkey
|
|
164
|
-
to bank_account_currency_fkey
|
|
165
|
-
`.execute(db);
|
|
166
|
-
await sql`
|
|
167
|
-
alter table accounting.account_connection
|
|
168
|
-
rename constraint account_connection_connection_id_fkey
|
|
169
|
-
to bank_account_connection_id_fkey
|
|
170
|
-
`.execute(db);
|
|
171
|
-
await sql`
|
|
172
|
-
alter table accounting.account_connection
|
|
173
|
-
rename constraint account_connection_category_fkey
|
|
174
|
-
to bank_account_category_fkey
|
|
175
|
-
`.execute(db);
|
|
176
|
-
await sql`
|
|
177
|
-
alter table accounting.account_connection
|
|
178
|
-
rename constraint account_connection_account_id_fkey
|
|
179
|
-
to bank_account_account_id_fkey
|
|
180
|
-
`.execute(db);
|
|
181
|
-
await sql`
|
|
182
|
-
alter table accounting.account_connection
|
|
183
|
-
rename constraint account_connection_source_id_key
|
|
184
|
-
to bank_account_source_id_key
|
|
185
|
-
`.execute(db);
|
|
186
|
-
await sql`
|
|
187
|
-
alter table accounting.account_connection
|
|
188
|
-
rename constraint account_connection_connection_id_unique_ref_key
|
|
189
|
-
to bank_account_connection_id_unique_ref_key
|
|
190
|
-
`.execute(db);
|
|
191
|
-
await sql`
|
|
192
|
-
alter table accounting.account_connection
|
|
193
|
-
rename constraint account_connection_pkey to bank_account_pkey
|
|
194
|
-
`.execute(db);
|
|
195
|
-
|
|
196
|
-
await sql`
|
|
197
|
-
alter table accounting.bank_record
|
|
198
|
-
rename column account_connection_id to bank_account_id
|
|
199
|
-
`.execute(db);
|
|
200
|
-
await sql`
|
|
201
|
-
alter table accounting.account_connection
|
|
202
|
-
rename to bank_account
|
|
203
|
-
`.execute(db);
|
|
204
|
-
}
|