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
fix: remove opportunities and interactions with null customer and supplierIds
Brad Barbin3a1d603b2945
diff --git a/packages/database/supabase/migrations/20250707135534_customer-opportunity.sql b/packages/database/supabase/migrations/20250707135534_customer-opportunity.sqlindex 2934372596..529f943659 100644--- a/packages/database/supabase/migrations/20250707135534_customer-opportunity.sql+++ b/packages/database/supabase/migrations/20250707135534_customer-opportunity.sql@@ -1,8 +1,8 @@-- Add customerId field to opportunity table-ALTER TABLE "opportunity" ADD COLUMN "customerId" TEXT;+ALTER TABLE "opportunity" ADD COLUMN IF NOT EXISTS "customerId" TEXT;-- Add supplierId field to supplierInteraction table-ALTER TABLE "supplierInteraction" ADD COLUMN "supplierId" TEXT;+ALTER TABLE "supplierInteraction" ADD COLUMN IF NOT EXISTS "supplierId" TEXT;-- Update opportunity table with customerId from various sources in order of priorityUPDATE "opportunity" o@@ -65,6 +65,10 @@ SET "supplierId" = COALESCE()WHERE si."supplierId" IS NULL;+DELETE FROM "opportunity" WHERE "customerId" IS NULL;++DELETE FROM "supplierInteraction" WHERE "supplierId" IS NULL;+-- Make customerId NOT NULL on opportunity tableALTER TABLE "opportunity" ALTER COLUMN "customerId" SET NOT NULL;