@vrplatform/kysely 1.3.45-stage.4399 → 1.3.45-stage.4403
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,42 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// CUS-2503: legacy /me exposed approved feature flags globally per user. The
|
|
5
|
+
// consolidated /me requires a team-level row before applying user approval.
|
|
6
|
+
// Seed missing rows as partial so the new rule preserves the legacy scope,
|
|
7
|
+
// while existing all, partially, or disabled team settings remain authoritative.
|
|
8
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
9
|
+
await sql`
|
|
10
|
+
insert into public.feature_enabled_team (tenant_id, feature_id, status)
|
|
11
|
+
select tenant.id, approved_feature.id, 'partially'
|
|
12
|
+
from public.tenant as tenant
|
|
13
|
+
join (
|
|
14
|
+
select distinct feature.id, feature.tenant_id
|
|
15
|
+
from public.feature as feature
|
|
16
|
+
inner join public.feature_approval as approval
|
|
17
|
+
on approval.feature_id = feature.id
|
|
18
|
+
where approval.status in ('partially', 'all')
|
|
19
|
+
) as approved_feature
|
|
20
|
+
on approved_feature.tenant_id is null
|
|
21
|
+
or approved_feature.tenant_id = tenant.id
|
|
22
|
+
where tenant.status = 'active'
|
|
23
|
+
on conflict (tenant_id, feature_id) do nothing;
|
|
24
|
+
`.execute(db);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function down(): Promise<void> {
|
|
28
|
+
// The backfill is intentionally irreversible because inserted rows cannot
|
|
29
|
+
// be distinguished from partial enablements created after this migration.
|
|
30
|
+
}
|