@vrplatform/kysely 1.3.45-4695 → 1.3.45-4699
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.
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
update public.connection
|
|
7
|
+
set credentials = (credentials #>> '{}')::jsonb
|
|
8
|
+
where jsonb_typeof(credentials) = 'string'
|
|
9
|
+
`.execute(db);
|
|
10
|
+
await sql`
|
|
11
|
+
update public.connection
|
|
12
|
+
set persistent_state = (persistent_state #>> '{}')::jsonb
|
|
13
|
+
where jsonb_typeof(persistent_state) = 'string'
|
|
14
|
+
`.execute(db);
|
|
15
|
+
await sql`
|
|
16
|
+
update public.feature
|
|
17
|
+
set required_approvals = (required_approvals #>> '{}')::jsonb
|
|
18
|
+
where jsonb_typeof(required_approvals) = 'string'
|
|
19
|
+
`.execute(db);
|
|
20
|
+
await sql`
|
|
21
|
+
update accounting.transaction
|
|
22
|
+
set recurring_pattern = (recurring_pattern #>> '{}')::jsonb
|
|
23
|
+
where jsonb_typeof(recurring_pattern) = 'string'
|
|
24
|
+
`.execute(db);
|
|
25
|
+
await sql`
|
|
26
|
+
update public.source
|
|
27
|
+
set json = (json #>> '{}')::jsonb
|
|
28
|
+
where type = 'ownerStatement'
|
|
29
|
+
and jsonb_typeof(json) = 'string'
|
|
30
|
+
`.execute(db);
|
|
31
|
+
await sql`
|
|
32
|
+
update accounting.owner_statement_projection
|
|
33
|
+
set payload = (payload #>> '{}')::jsonb
|
|
34
|
+
where jsonb_typeof(payload) = 'string'
|
|
35
|
+
`.execute(db);
|
|
36
|
+
await sql`
|
|
37
|
+
alter table public.connection
|
|
38
|
+
add constraint connection_credentials_object_check
|
|
39
|
+
check (credentials is null or jsonb_typeof(credentials) = 'object'),
|
|
40
|
+
add constraint connection_persistent_state_object_check
|
|
41
|
+
check (
|
|
42
|
+
persistent_state is null
|
|
43
|
+
or jsonb_typeof(persistent_state) = 'object'
|
|
44
|
+
)
|
|
45
|
+
`.execute(db);
|
|
46
|
+
await sql`
|
|
47
|
+
alter table public.feature
|
|
48
|
+
add constraint feature_required_approvals_array_check
|
|
49
|
+
check (
|
|
50
|
+
required_approvals is null
|
|
51
|
+
or jsonb_typeof(required_approvals) = 'array'
|
|
52
|
+
)
|
|
53
|
+
`.execute(db);
|
|
54
|
+
await sql`
|
|
55
|
+
alter table accounting.transaction
|
|
56
|
+
add constraint transaction_recurring_pattern_object_check
|
|
57
|
+
check (
|
|
58
|
+
recurring_pattern is null
|
|
59
|
+
or jsonb_typeof(recurring_pattern) = 'object'
|
|
60
|
+
)
|
|
61
|
+
`.execute(db);
|
|
62
|
+
await sql`
|
|
63
|
+
alter table public.source
|
|
64
|
+
add constraint source_owner_statement_json_object_check
|
|
65
|
+
check (
|
|
66
|
+
type <> 'ownerStatement'
|
|
67
|
+
or json is null
|
|
68
|
+
or jsonb_typeof(json) = 'object'
|
|
69
|
+
)
|
|
70
|
+
`.execute(db);
|
|
71
|
+
await sql`
|
|
72
|
+
alter table accounting.owner_statement_projection
|
|
73
|
+
add constraint owner_statement_projection_payload_container_check
|
|
74
|
+
check (jsonb_typeof(payload) in ('array', 'object'))
|
|
75
|
+
`.execute(db);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
79
|
+
await sql`
|
|
80
|
+
alter table accounting.owner_statement_projection
|
|
81
|
+
drop constraint if exists owner_statement_projection_payload_container_check
|
|
82
|
+
`.execute(db);
|
|
83
|
+
await sql`
|
|
84
|
+
alter table public.source
|
|
85
|
+
drop constraint if exists source_owner_statement_json_object_check
|
|
86
|
+
`.execute(db);
|
|
87
|
+
await sql`
|
|
88
|
+
alter table accounting.transaction
|
|
89
|
+
drop constraint if exists transaction_recurring_pattern_object_check
|
|
90
|
+
`.execute(db);
|
|
91
|
+
await sql`
|
|
92
|
+
alter table public.feature
|
|
93
|
+
drop constraint if exists feature_required_approvals_array_check
|
|
94
|
+
`.execute(db);
|
|
95
|
+
await sql`
|
|
96
|
+
alter table public.connection
|
|
97
|
+
drop constraint if exists connection_persistent_state_object_check,
|
|
98
|
+
drop constraint if exists connection_credentials_object_check
|
|
99
|
+
`.execute(db);
|
|
100
|
+
}
|