@vrplatform/kysely 1.3.45-stage.11 → 1.3.45-stage.146

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,70 @@
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`set local lock_timeout = '5s'`.execute(db);
6
+ await sql`
7
+ alter table public.tenant_user
8
+ disable trigger set_public_tenant_user_updated_at
9
+ `.execute(db);
10
+ await sql`
11
+ update public.tenant_user as tenant_user
12
+ set permission_bundles = (
13
+ select array_agg(mapped.bundle order by mapped.first_ordinal)
14
+ from (
15
+ select
16
+ case existing.bundle
17
+ when 'ui:accounting:v1' then 'ui:standard-member:v1'
18
+ when 'ui:owner-statements:v1' then 'ui:operations:v1'
19
+ when 'ui:reports-viewer:v1' then 'ui:read-only:v1'
20
+ else existing.bundle
21
+ end as bundle,
22
+ min(existing.ordinality) as first_ordinal
23
+ from unnest(tenant_user.permission_bundles)
24
+ with ordinality as existing(bundle, ordinality)
25
+ group by
26
+ case existing.bundle
27
+ when 'ui:accounting:v1' then 'ui:standard-member:v1'
28
+ when 'ui:owner-statements:v1' then 'ui:operations:v1'
29
+ when 'ui:reports-viewer:v1' then 'ui:read-only:v1'
30
+ else existing.bundle
31
+ end
32
+ ) as mapped
33
+ )
34
+ where tenant_user.permission_bundles && array[
35
+ 'ui:accounting:v1',
36
+ 'ui:owner-statements:v1',
37
+ 'ui:reports-viewer:v1'
38
+ ]::text[]
39
+ `.execute(db);
40
+ await sql`
41
+ alter table public.tenant_user
42
+ enable trigger set_public_tenant_user_updated_at
43
+ `.execute(db);
44
+ await sql`alter table public.tenant disable trigger user`.execute(db);
45
+ await sql`
46
+ update public.tenant as tenant
47
+ set partner_denied_permissions = (
48
+ select array_agg(rewritten.permission order by rewritten.first_ordinal)
49
+ from (
50
+ select
51
+ permission,
52
+ min(ordinality) as first_ordinal
53
+ from unnest(
54
+ array_remove(tenant.partner_denied_permissions, 'transactions:write')
55
+ || array[
56
+ 'transactions:deposits:write',
57
+ 'transactions:expenses:write',
58
+ 'transactions:transfers:write',
59
+ 'transactions:payouts:write'
60
+ ]::text[]
61
+ ) with ordinality as expanded(permission, ordinality)
62
+ group by permission
63
+ ) as rewritten
64
+ )
65
+ where 'transactions:write' = any(tenant.partner_denied_permissions)
66
+ `.execute(db);
67
+ await sql`alter table public.tenant enable trigger user`.execute(db);
68
+ }
69
+
70
+ export async function down(_db: Kysely<unknown>): Promise<void> {}
@@ -0,0 +1,44 @@
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.connection
7
+ drop constraint connection_tenant_id_fkey,
8
+ add constraint connection_tenant_id_fkey
9
+ foreign key (tenant_id)
10
+ references public.tenant(id)
11
+ on update restrict
12
+ on delete cascade
13
+ `.execute(db);
14
+ await sql`
15
+ alter table accounting.account_reservation_line_type
16
+ drop constraint account_reservation_line_type_account_id_fkey,
17
+ add constraint account_reservation_line_type_account_id_fkey
18
+ foreign key (account_id)
19
+ references accounting.account(id)
20
+ on update restrict
21
+ on delete cascade
22
+ `.execute(db);
23
+ }
24
+
25
+ export async function down(db: Kysely<unknown>): Promise<void> {
26
+ await sql`
27
+ alter table accounting.account_reservation_line_type
28
+ drop constraint account_reservation_line_type_account_id_fkey,
29
+ add constraint account_reservation_line_type_account_id_fkey
30
+ foreign key (account_id)
31
+ references accounting.account(id)
32
+ on update restrict
33
+ on delete restrict
34
+ `.execute(db);
35
+ await sql`
36
+ alter table public.connection
37
+ drop constraint connection_tenant_id_fkey,
38
+ add constraint connection_tenant_id_fkey
39
+ foreign key (tenant_id)
40
+ references public.tenant(id)
41
+ on update restrict
42
+ on delete restrict
43
+ `.execute(db);
44
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.3.45-stage.11",
6
+ "version": "1.3.45-stage.146",
7
7
  "description": "",
8
8
  "main": "build/main/index.js",
9
9
  "module": "build/module/index.js",