@vrplatform/kysely 1.3.45-stage.4401 → 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,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
|
+
}
|