Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/prisma/rls/automation-isolation.sql
T
2026-07-08 16:15:37 +02:00

63 lines
3.2 KiB
SQL

-- R-P12a Automation isolation artifact.
-- Companion to prisma/rls/tenant-isolation.sql. Enable during the merge
-- migration once the schema lands and the automation service has shipped.
--
-- Verification:
-- psql "$DIRECT_URL" -f prisma/rls/automation-isolation.sql
ALTER TABLE "AutomationRule" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "AutomationRule" FORCE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "tenant_isolation_automation_rule" ON "AutomationRule";
CREATE POLICY "tenant_isolation_automation_rule" ON "AutomationRule"
USING ("tenantId" = current_setting('app.tenant_id', true))
WITH CHECK ("tenantId" = current_setting('app.tenant_id', true));
ALTER TABLE "AutomationRuleStep" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "AutomationRuleStep" FORCE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "tenant_isolation_automation_rule_step" ON "AutomationRuleStep";
CREATE POLICY "tenant_isolation_automation_rule_step" ON "AutomationRuleStep"
USING ("tenantId" = current_setting('app.tenant_id', true))
WITH CHECK ("tenantId" = current_setting('app.tenant_id', true));
ALTER TABLE "AutomationExecution" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "AutomationExecution" FORCE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "tenant_isolation_automation_execution" ON "AutomationExecution";
CREATE POLICY "tenant_isolation_automation_execution" ON "AutomationExecution"
USING ("tenantId" = current_setting('app.tenant_id', true))
WITH CHECK ("tenantId" = current_setting('app.tenant_id', true));
ALTER TABLE "AutomationStepExecution" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "AutomationStepExecution" FORCE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "tenant_isolation_automation_step_execution" ON "AutomationStepExecution";
CREATE POLICY "tenant_isolation_automation_step_execution" ON "AutomationStepExecution"
USING ("tenantId" = current_setting('app.tenant_id', true))
WITH CHECK ("tenantId" = current_setting('app.tenant_id', true));
ALTER TABLE "AutomationCredential" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "AutomationCredential" FORCE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "tenant_isolation_automation_credential" ON "AutomationCredential";
CREATE POLICY "tenant_isolation_automation_credential" ON "AutomationCredential"
USING ("tenantId" = current_setting('app.tenant_id', true))
WITH CHECK ("tenantId" = current_setting('app.tenant_id', true));
ALTER TABLE "AutomationTemplate" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "AutomationTemplate" FORCE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "tenant_isolation_automation_template" ON "AutomationTemplate";
CREATE POLICY "tenant_isolation_automation_template" ON "AutomationTemplate"
USING ("tenantId" IS NULL OR "tenantId" = current_setting('app.tenant_id', true))
WITH CHECK ("tenantId" IS NULL OR "tenantId" = current_setting('app.tenant_id', true));
ALTER TABLE "AutomationTriggerMeter" ENABLE ROW LEVEL SECURITY;
ALTER TABLE "AutomationTriggerMeter" FORCE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "tenant_isolation_automation_trigger_meter" ON "AutomationTriggerMeter";
CREATE POLICY "tenant_isolation_automation_trigger_meter" ON "AutomationTriggerMeter"
USING ("tenantId" = current_setting('app.tenant_id', true))
WITH CHECK ("tenantId" = current_setting('app.tenant_id', true));