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
-- Generated by `pnpm --filter @carbon/database authz migration` from packages/database/src/authz. Do not edit.
-- Ships these rules to databases where `authz sync` does not run after migrations yet.
-- userAttributeValue
DO $authz$
DECLARE p record;
BEGIN
FOR p IN SELECT policyname FROM pg_policies WHERE schemaname = 'public' AND tablename = 'userAttributeValue' LOOP
EXECUTE format('DROP POLICY %I ON public.%I', p.policyname, 'userAttributeValue');
END LOOP;
END
$authz$;
ALTER TABLE public."userAttributeValue" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "SELECT" ON "public"."userAttributeValue" FOR SELECT USING ((("userId" = ((SELECT auth.uid()))::text AND "userAttributeId" IN (SELECT "userAttribute"."id" FROM "public"."userAttribute" WHERE ("canSelfManage" = true AND "userAttributeCategoryId" IN (SELECT "userAttributeCategory"."id" FROM "public"."userAttributeCategory" WHERE "companyId" IN (SELECT "userToCompany"."companyId" FROM "public"."userToCompany" WHERE "userId" = ((SELECT auth.uid()))::text))))) OR "userAttributeId" IN (SELECT "userAttribute"."id" FROM "public"."userAttribute" WHERE "userAttributeCategoryId" IN (SELECT "userAttributeCategory"."id" FROM "public"."userAttributeCategory" WHERE "companyId" = ANY ((SELECT get_companies_with_employee_permission('resources_update'))::text[])))));
CREATE POLICY "INSERT" ON "public"."userAttributeValue" FOR INSERT WITH CHECK ((("userId" = ((SELECT auth.uid()))::text AND "userAttributeId" IN (SELECT "userAttribute"."id" FROM "public"."userAttribute" WHERE ("canSelfManage" = true AND "userAttributeCategoryId" IN (SELECT "userAttributeCategory"."id" FROM "public"."userAttributeCategory" WHERE "companyId" IN (SELECT "userToCompany"."companyId" FROM "public"."userToCompany" WHERE "userId" = ((SELECT auth.uid()))::text))))) OR "userAttributeId" IN (SELECT "userAttribute"."id" FROM "public"."userAttribute" WHERE "userAttributeCategoryId" IN (SELECT "userAttributeCategory"."id" FROM "public"."userAttributeCategory" WHERE "companyId" = ANY ((SELECT get_companies_with_employee_permission('resources_update'))::text[])))));
CREATE POLICY "UPDATE" ON "public"."userAttributeValue" FOR UPDATE USING ((("userId" = ((SELECT auth.uid()))::text AND "userAttributeId" IN (SELECT "userAttribute"."id" FROM "public"."userAttribute" WHERE ("canSelfManage" = true AND "userAttributeCategoryId" IN (SELECT "userAttributeCategory"."id" FROM "public"."userAttributeCategory" WHERE "companyId" IN (SELECT "userToCompany"."companyId" FROM "public"."userToCompany" WHERE "userId" = ((SELECT auth.uid()))::text))))) OR "userAttributeId" IN (SELECT "userAttribute"."id" FROM "public"."userAttribute" WHERE "userAttributeCategoryId" IN (SELECT "userAttributeCategory"."id" FROM "public"."userAttributeCategory" WHERE "companyId" = ANY ((SELECT get_companies_with_employee_permission('resources_update'))::text[])))));
CREATE POLICY "DELETE" ON "public"."userAttributeValue" FOR DELETE USING ((("userId" = ((SELECT auth.uid()))::text AND "userAttributeId" IN (SELECT "userAttribute"."id" FROM "public"."userAttribute" WHERE ("canSelfManage" = true AND "userAttributeCategoryId" IN (SELECT "userAttributeCategory"."id" FROM "public"."userAttributeCategory" WHERE "companyId" IN (SELECT "userToCompany"."companyId" FROM "public"."userToCompany" WHERE "userId" = ((SELECT auth.uid()))::text))))) OR "userAttributeId" IN (SELECT "userAttribute"."id" FROM "public"."userAttribute" WHERE "userAttributeCategoryId" IN (SELECT "userAttributeCategory"."id" FROM "public"."userAttributeCategory" WHERE "companyId" = ANY ((SELECT get_companies_with_employee_permission('resources_update'))::text[])))));