Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -0,0 +1,39 @@
-- VR-P32b/VR-P32d · KWP inbound capability — RLS companion artifact.
--
-- Forward-only. Inverse per table:
-- REVOKE SELECT, INSERT, UPDATE, DELETE ON "<tbl>" FROM hivegrid_app, hivegrid_worker;
-- 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[
'KwpApiContractSnapshot',
'KwpCapabilityState',
'KwpErrorReport',
'KwpProjectRouting',
'KwpMaterialPosition'
]
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, hivegrid_worker;', tbl);
END LOOP;
END
$$;