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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: rls for attribute tables
Brad Barbin60bbd10f7aef
diff --git a/apps/erp/app/modules/account/ui/UserAttributes/UserAttributesForm.tsx b/apps/erp/app/modules/account/ui/UserAttributes/UserAttributesForm.tsxindex 223d6a5607..1bebef128e 100644--- a/apps/erp/app/modules/account/ui/UserAttributes/UserAttributesForm.tsx+++ b/apps/erp/app/modules/account/ui/UserAttributes/UserAttributesForm.tsx@@ -171,7 +171,9 @@ function TypedForm(<Hidden name="type" value="boolean" /><Hidden name="userAttributeId" /><Hidden name="userAttributeValueId" />- <BooleanInput name="value" />+ <div>+ <BooleanInput name="value" />+ </div></div><HStack className="justify-end w-full self-center"><Submit type="submit">Save</Submit>@@ -455,7 +457,9 @@ function TypedDisplay({displayValue === "N/A" ? (<p className="self-center">{displayValue}</p>) : (- <Switch disabled checked={displayValue === true} />+ <div>+ <Switch disabled checked={displayValue === true} />+ </div>)}<HStack className="justify-end w-full self-center"><Buttondiff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.tsindex ea6ef6780e..015e0bc01c 100644--- a/apps/erp/app/modules/production/production.service.ts+++ b/apps/erp/app/modules/production/production.service.ts@@ -321,7 +321,7 @@ export async function calculateJobPriority(// Define deadline type priority order (lower number = higher priority)const deadlineTypePriority: Record<string, number> = {- "ASAP": 0,+ ASAP: 0,"Hard Deadline": 1,"Soft Deadline": 2,"No Deadline": 3,@@ -359,7 +359,8 @@ export async function calculateJobPriority(let insertBeforeIndex = existingJobs.length; // Default to end of listfor (let i = 0; i < existingJobs.length; i++) {- const existingJobPriority = deadlineTypePriority[existingJobs[i].deadlineType];+ const existingJobPriority =+ deadlineTypePriority[existingJobs[i].deadlineType];// If the current job has higher priority (lower number) than this existing job,// we should insert before this job@@ -2488,9 +2489,7 @@ export async function triggerJobSchedule(mode: "initial" | "reschedule" = "reschedule",direction: "backward" | "forward" = "backward") {- const { scheduleJob } = await import(- "@carbon/jobs/trigger/reschedule-job"- );+ const { scheduleJob } = await import("@carbon/jobs/trigger/reschedule-job");const handle = await scheduleJob.trigger({jobId,diff --git a/packages/database/supabase/migrations/20251203001955_attributes-rls.sql b/packages/database/supabase/migrations/20251203001955_attributes-rls.sqlnew file mode 100644index 0000000000..5a6263d3c7--- /dev/null+++ b/packages/database/supabase/migrations/20251203001955_attributes-rls.sql@@ -0,0 +1,76 @@+++ALTER TABLE "userAttribute" ENABLE ROW LEVEL SECURITY;+CREATE POLICY "SELECT" ON "public"."userAttribute"+FOR SELECT USING (+ "userAttributeCategoryId" IN (+ SELECT "id" FROM "userAttributeCategory" WHERE "companyId" = ANY (+ get_permission_companies('resources_view')+ )+ )+);++CREATE POLICY "INSERT" ON "public"."userAttribute"+FOR INSERT WITH CHECK (+ "userAttributeCategoryId" IN (+ SELECT "id" FROM "userAttributeCategory" WHERE "companyId" = ANY (+ get_permission_companies('resources_create')+ )+ )+);++CREATE POLICY "UPDATE" ON "public"."userAttribute"+FOR UPDATE USING (+ "userAttributeCategoryId" IN (+ SELECT "id" FROM "userAttributeCategory" WHERE "companyId" = ANY (+ get_permission_companies('resources_update')+ )+ )+);++CREATE POLICY "DELETE" ON "public"."userAttribute"+FOR DELETE USING (+ "userAttributeCategoryId" IN (+ SELECT "id" FROM "userAttributeCategory" WHERE "companyId" = ANY (+ get_permission_companies('resources_delete')+ )+ )+);++ALTER TABLE "userAttributeCategory" ENABLE ROW LEVEL SECURITY;++CREATE POLICY "SELECT" ON "public"."userAttributeCategory"+FOR SELECT USING (+ "companyId" = ANY (+ (+ SELECT get_permission_companies('resources_view')::text[]+ )::text[]+ )+);++CREATE POLICY "INSERT" ON "public"."userAttributeCategory"+FOR INSERT WITH CHECK (+ "companyId" = ANY (+ (+ SELECT get_permission_companies('resources_create')::text[]+ )::text[]+ )+);++CREATE POLICY "UPDATE" ON "public"."userAttributeCategory"+FOR UPDATE USING (+ "companyId" = ANY (+ (+ SELECT get_permission_companies('resources_update')::text[]+ )::text[]+ )+);++CREATE POLICY "DELETE" ON "public"."userAttributeCategory"+FOR DELETE USING (+ "companyId" = ANY (+ (+ SELECT get_permission_companies('resources_delete')::text[]+ )::text[]+ )+);\ No newline at end of file