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.
-- document
DO $authz$
DECLARE p record;
BEGIN
FOR p IN SELECT policyname FROM pg_policies WHERE schemaname = 'public' AND tablename = 'document' LOOP
EXECUTE format('DROP POLICY %I ON public.%I', p.policyname, 'document');
END LOOP;
END
$authz$;
ALTER TABLE public."document" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "DELETE" ON "public"."document" AS PERMISSIVE FOR DELETE TO public USING ((("companyId" = ANY (( SELECT get_companies_with_employee_permission('documents_delete'::text) AS get_companies_with_employee_permission)::text[])) AND (("writeGroups" && ( SELECT groups_for_user((( SELECT auth.uid() AS uid))::text) AS groups_for_user)) OR has_valid_api_key_for_company("companyId"))));
CREATE POLICY "INSERT" ON "public"."document" AS PERMISSIVE FOR INSERT TO public WITH CHECK ((("companyId" = ANY (( SELECT get_companies_with_employee_permission('documents_create'::text) AS get_companies_with_employee_permission)::text[])) AND (("writeGroups" && ( SELECT groups_for_user((( SELECT auth.uid() AS uid))::text) AS groups_for_user)) OR has_valid_api_key_for_company("companyId"))));
CREATE POLICY "SELECT" ON "public"."document" AS PERMISSIVE FOR SELECT TO public USING ((("companyId" = ANY (( SELECT get_companies_with_employee_permission('documents_view'::text) AS get_companies_with_employee_permission)::text[])) AND (("readGroups" && ( SELECT groups_for_user((( SELECT auth.uid() AS uid))::text) AS groups_for_user)) OR has_valid_api_key_for_company("companyId"))));
CREATE POLICY "UPDATE" ON "public"."document" AS PERMISSIVE FOR UPDATE TO public USING ((("companyId" = ANY (( SELECT get_companies_with_employee_permission('documents_update'::text) AS get_companies_with_employee_permission)::text[])) AND (("writeGroups" && ( SELECT groups_for_user((( SELECT auth.uid() AS uid))::text) AS groups_for_user)) OR has_valid_api_key_for_company("companyId"))));