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
-- Drop the unique constraint since we'll handle this via trigger
ALTER TABLE "contact"
DROP CONSTRAINT IF EXISTS "contact_email_companyId_unique";
ALTER TABLE "contact" ADD COLUMN "isCustomer" BOOLEAN NOT NULL DEFAULT TRUE;
-- Update existing supplier contacts to have isCustomer = FALSE
UPDATE "contact" c
SET "isCustomer" = FALSE
FROM "supplierContact" sc
WHERE c.id = sc."contactId";
ALTER TABLE "contact" ADD CONSTRAINT "contact_email_companyId_unique" UNIQUE ("email", "companyId", "isCustomer");