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: update the RLS policies on the currency table

Rob Carringtona68d54a71ae6
diff --git a/packages/database/supabase/migrations/20241010193506_quote-order-presentation-currency.sql b/packages/database/supabase/migrations/20241010193506_quote-order-presentation-currency.sql
index 21cfcff43a..edc47f3140 100644
--- a/packages/database/supabase/migrations/20241010193506_quote-order-presentation-currency.sql
+++ b/packages/database/supabase/migrations/20241010193506_quote-order-presentation-currency.sql
@@ -104,4 +104,16 @@ ALTER TABLE "customerPayment" DROP COLUMN "currencyCode";
ALTER TABLE "supplierPayment" DROP COLUMN "currencyCode";
ALTER TABLE "quotePayment" DROP COLUMN "currencyCode";
ALTER TABLE "salesOrderPayment" DROP COLUMN "currencyCode";
-ALTER TABLE "purchaseOrderPayment" DROP COLUMN "currencyCode";
\ No newline at end of file
+ALTER TABLE "purchaseOrderPayment" DROP COLUMN "currencyCode";
+
+-- Fix the currency RLS policies
+DROP POLICY IF EXISTS "Employees with accounting_view can view currencies" ON "currency";
+CREATE POLICY "Employees with accounting_view can view currencies" ON "currency"
+ FOR SELECT
+ USING (
+ has_role('employee', "companyId") AND
+ has_company_permission('accounting_view', "companyId")
+ );
+
+DROP POLICY IF EXISTS "Employees with accounting_create can insert currencies" ON "currency";
+DROP POLICY IF EXISTS "Employees with accounting_delete can delete currencies" ON "currency";
\ No newline at end of file