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.

feat: allow update and delete on tracked entities

Brad Barbin384e2be15c63
diff --git a/packages/database/supabase/migrations/20260327171223_tracked-entity-rls.sql b/packages/database/supabase/migrations/20260327171223_tracked-entity-rls.sql
new file mode 100644
index 0000000000..37392f2fb8
--- /dev/null
+++ b/packages/database/supabase/migrations/20260327171223_tracked-entity-rls.sql
@@ -0,0 +1,79 @@
+CREATE POLICY "UPDATE" ON "public"."trackedEntity"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "public"."trackedEntity"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_delete')
+ )::text[]
+ )
+);
+
+CREATE POLICY "UPDATE" ON "public"."trackedActivity"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "public"."trackedActivity"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_delete')
+ )::text[]
+ )
+);
+
+CREATE POLICY "UPDATE" ON "public"."trackedActivityInput"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "public"."trackedActivityInput"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_delete')
+ )::text[]
+ )
+);
+
+CREATE POLICY "UPDATE" ON "public"."trackedActivityOutput"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "public"."trackedActivityOutput"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('inventory_delete')
+ )::text[]
+ )
+);