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 VIEW IF EXISTS "quoteLines";
DROP VIEW IF EXISTS "salesOrderLines";
ALTER TABLE "quoteLine" ADD COLUMN "externalNotes" jsonb;
ALTER TABLE "salesOrderLine" ADD COLUMN "externalNotes" jsonb;
ALTER TABLE "quoteLine" RENAME COLUMN "notes" TO "internalNotes";
ALTER TABLE "salesOrderLine" RENAME COLUMN "notes" TO "internalNotes";
-- Update salesRfqLines view
DROP VIEW IF EXISTS "salesRfqLines";
CREATE OR REPLACE VIEW "salesRfqLines" WITH(SECURITY_INVOKER=true) AS
SELECT
srl.*,
mu.id as "modelId",
mu."autodeskUrn",
mu."modelPath",
mu."name" as "modelName",
mu."size" as "modelSize",
CASE
WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
ELSE i."thumbnailPath"
END as "thumbnailPath",
i."name" as "itemName",
i."defaultMethodType" AS "methodType",
i."readableId" AS "itemReadableId",
i."type" AS "itemType"
FROM "salesRfqLine" srl
LEFT JOIN "item" i ON i.id = srl."itemId"
LEFT JOIN "modelUpload" mu ON mu.id = srl."modelUploadId";
-- Update quoteLines view
DROP VIEW IF EXISTS "quoteLines";
CREATE OR REPLACE VIEW "quoteLines" WITH(SECURITY_INVOKER=true) AS (
SELECT
ql.*,
CASE
WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
WHEN i."thumbnailPath" IS NULL AND imu."thumbnailPath" IS NOT NULL THEN imu."thumbnailPath"
ELSE i."thumbnailPath"
END as "thumbnailPath",
COALESCE(mu.id, imu.id) as "modelId",
COALESCE(mu."autodeskUrn", imu."autodeskUrn") as "autodeskUrn",
COALESCE(mu."modelPath", imu."modelPath") as "modelPath",
COALESCE(mu."name", imu."name") as "modelName",
COALESCE(mu."size", imu."size") as "modelSize",
ic."unitCost" as "unitCost"
FROM "quoteLine" ql
LEFT JOIN "modelUpload" mu ON ql."modelUploadId" = mu."id"
INNER JOIN "item" i ON i.id = ql."itemId"
LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
LEFT JOIN "modelUpload" imu ON imu.id = i."modelUploadId"
);
DROP VIEW IF EXISTS "salesOrderLines";
CREATE OR REPLACE VIEW "salesOrderLines" WITH(SECURITY_INVOKER=true) AS (
SELECT
sl.*,
CASE
WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
WHEN i."thumbnailPath" IS NULL AND imu."thumbnailPath" IS NOT NULL THEN imu."thumbnailPath"
ELSE i."thumbnailPath"
END as "thumbnailPath",
COALESCE(mu.id, imu.id) as "modelId",
COALESCE(mu."autodeskUrn", imu."autodeskUrn") as "autodeskUrn",
COALESCE(mu."modelPath", imu."modelPath") as "modelPath",
COALESCE(mu."name", imu."name") as "modelName",
COALESCE(mu."size", imu."size") as "modelSize",
ic."unitCost" as "unitCost",
cp."customerPartId",
cp."customerPartRevision"
FROM "salesOrderLine" sl
INNER JOIN "salesOrder" so ON so.id = sl."salesOrderId"
LEFT JOIN "modelUpload" mu ON sl."modelUploadId" = mu."id"
INNER JOIN "item" i ON i.id = sl."itemId"
LEFT JOIN "itemCost" ic ON ic."itemId" = i.id
LEFT JOIN "modelUpload" imu ON imu.id = i."modelUploadId"
LEFT JOIN "customerPartToItem" cp ON cp."customerId" = so."customerId" AND cp."itemId" = i.id
);