Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: shipment rls for update/delete

Brad Barbin3dd2716b095a
diff --git a/packages/database/supabase/migrations/20251209184716_shipment-rls-fix.sql b/packages/database/supabase/migrations/20251209184716_shipment-rls-fix.sql
new file mode 100644
index 0000000000..f8d16d5122
--- /dev/null
+++ b/packages/database/supabase/migrations/20251209184716_shipment-rls-fix.sql
@@ -0,0 +1,23 @@
+-- Fix shipment RLS policies to use inventory permissions instead of sales permissions
+DROP POLICY "UPDATE" ON "shipment";
+DROP POLICY "DELETE" ON "shipment";
+
+CREATE POLICY "UPDATE" ON "shipment"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission ('inventory_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "shipment"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission ('inventory_delete')
+ )::text[]
+ )
+);