--liquibase formatted sql -- PANELS · core · RLS gastos y almacén --changeset panel:core-020a-rls-expense-entries endDelimiter:; splitStatements:true --preconditions onFail:MARK_RAN --precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM pg_policies WHERE schemaname='core' AND tablename='expense_entries' AND policyname='tenant_isolation' ALTER TABLE core.expense_entries ENABLE ROW LEVEL SECURITY; CREATE POLICY tenant_isolation ON core.expense_entries USING (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer) WITH CHECK (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer); --changeset panel:core-020b-rls-iva-period endDelimiter:; splitStatements:true --preconditions onFail:MARK_RAN --precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM pg_policies WHERE schemaname='core' AND tablename='iva_period_entries' AND policyname='tenant_isolation' ALTER TABLE core.iva_period_entries ENABLE ROW LEVEL SECURITY; CREATE POLICY tenant_isolation ON core.iva_period_entries USING (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer) WITH CHECK (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer); --changeset panel:core-020c-rls-warehouse-materials endDelimiter:; splitStatements:true --preconditions onFail:MARK_RAN --precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM pg_policies WHERE schemaname='core' AND tablename='warehouse_materials' AND policyname='tenant_isolation' ALTER TABLE core.warehouse_materials ENABLE ROW LEVEL SECURITY; CREATE POLICY tenant_isolation ON core.warehouse_materials USING (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer) WITH CHECK (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer); --changeset panel:core-020d-rls-warehouses endDelimiter:; splitStatements:true --preconditions onFail:MARK_RAN --precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM pg_policies WHERE schemaname='core' AND tablename='warehouses' AND policyname='tenant_isolation' ALTER TABLE core.warehouses ENABLE ROW LEVEL SECURITY; CREATE POLICY tenant_isolation ON core.warehouses USING (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer) WITH CHECK (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer); --changeset panel:core-020e-rls-warehouse-transfers endDelimiter:; splitStatements:true --preconditions onFail:MARK_RAN --precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM pg_policies WHERE schemaname='core' AND tablename='warehouse_transfers' AND policyname='tenant_isolation' ALTER TABLE core.warehouse_transfers ENABLE ROW LEVEL SECURITY; CREATE POLICY tenant_isolation ON core.warehouse_transfers USING (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer) WITH CHECK (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer); --changeset panel:core-020f-rls-warehouse-movements endDelimiter:; splitStatements:true --preconditions onFail:MARK_RAN --precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM pg_policies WHERE schemaname='core' AND tablename='warehouse_movements' AND policyname='tenant_isolation' ALTER TABLE core.warehouse_movements ENABLE ROW LEVEL SECURITY; CREATE POLICY tenant_isolation ON core.warehouse_movements USING (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer) WITH CHECK (tenant_id = NULLIF(current_setting('app.tenant_id', true), '')::integer);