Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
-- AK-P20 · Billing + Onboarding — RLS ROLLOUT ARTIFACT (deferred, NOT in the auto-migration)
|
||||
-- =============================================================================
|
||||
-- Companion to R-P2b's prisma/rls/tenant-isolation.sql. This file documents the
|
||||
-- RLS block for the tenant-scoped tables introduced or tightened by AK-P20.
|
||||
-- Activation is deferred until all runtime paths set app.tenant_id via
|
||||
-- withTenantRLS(), matching the existing module rollout pattern.
|
||||
--
|
||||
-- Inverse per table:
|
||||
-- REVOKE SELECT, INSERT, UPDATE, DELETE ON "<tbl>" FROM hivegrid_app;
|
||||
-- DROP POLICY IF EXISTS "<tbl>_tenant_isolation" ON "<tbl>";
|
||||
-- ALTER TABLE "<tbl>" NO FORCE ROW LEVEL SECURITY;
|
||||
-- ALTER TABLE "<tbl>" DISABLE ROW LEVEL SECURITY;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
tbl text;
|
||||
BEGIN
|
||||
FOREACH tbl IN ARRAY ARRAY[
|
||||
'TenantSubscription',
|
||||
'TenantSubscriptionUsageRecord',
|
||||
'TenantFeatureOverride',
|
||||
'TenantProductConfiguration',
|
||||
'Credit',
|
||||
'OnboardingSession',
|
||||
'OnboardingDemoProvisioning'
|
||||
]
|
||||
LOOP
|
||||
EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY;', tbl);
|
||||
EXECUTE format('ALTER TABLE %I FORCE ROW LEVEL SECURITY;', tbl);
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_policies
|
||||
WHERE schemaname = current_schema()
|
||||
AND tablename = tbl
|
||||
AND policyname = tbl || '_tenant_isolation'
|
||||
) THEN
|
||||
EXECUTE format(
|
||||
'CREATE POLICY %I ON %I USING ("tenantId" = current_setting(''app.tenant_id'', true)) WITH CHECK ("tenantId" = current_setting(''app.tenant_id'', true));',
|
||||
tbl || '_tenant_isolation', tbl
|
||||
);
|
||||
END IF;
|
||||
|
||||
EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON %I TO hivegrid_app;', tbl);
|
||||
END LOOP;
|
||||
END
|
||||
$$;
|
||||
|
||||
Reference in new issue
Block a user