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
- new flow accounting for partial indexes (#536)
Gaurav Bhatt63bce0cfa764
diff --git a/packages/database/supabase/functions/sync/index.ts b/packages/database/supabase/functions/sync/index.tsindex dca537b309..1c7f37678c 100644--- a/packages/database/supabase/functions/sync/index.ts+++ b/packages/database/supabase/functions/sync/index.ts@@ -379,7 +379,10 @@ serve(async (req: Request) => {// Track newly created items and make methods to avoid duplicate insertsconst newlyCreatedItemsByPartId = new Map<string, string>();- const newlyCreatedMakeMethodsByItemId = new Map<string, MakeMethodInfo>();+ const newlyCreatedMakeMethodsByItemId = new Map<+ string,+ MakeMethodInfo+ >();async function traverseTree(node: TreeNode,@@ -416,7 +419,6 @@ serve(async (req: Request) => {.where("id", "=", itemId).execute();- // Upsert OnShape mapping — update if this entity already has a mappingawait trx.insertInto("externalIntegrationMapping").values({@@ -430,10 +432,17 @@ serve(async (req: Request) => {}).onConflict((oc) =>oc- .columns(["entityType", "entityId", "integration", "companyId"])+ .columns([+ "integration",+ "externalId",+ "entityType",+ "companyId",+ ])+ .where("allowDuplicateExternalId", "=", false).doUpdateSet({- externalId: externalPartId,+ entityId: itemId,metadata: data.data,+ updatedAt: new Date().toISOString(),})).execute();@@ -462,7 +471,7 @@ serve(async (req: Request) => {itemId = item?.id;- // Upsert OnShape mapping for the new item+ // Create OnShape mapping for the new itemif (itemId) {await trx.insertInto("externalIntegrationMapping")@@ -477,10 +486,17 @@ serve(async (req: Request) => {}).onConflict((oc) =>oc- .columns(["integration", "externalId", "entityType", "companyId"])+ .columns([+ "integration",+ "externalId",+ "entityType",+ "companyId",+ ])+ .where("allowDuplicateExternalId", "=", false).doUpdateSet({entityId: itemId,metadata: data.data,+ updatedAt: new Date().toISOString(),})).execute();@@ -626,8 +642,14 @@ serve(async (req: Request) => {version: newVersion,status: "Draft",};- newlyCreatedMakeMethodsByItemId.set(itemId, newMakeMethodInfo);- existingMakeMethodsByItemId.set(itemId, newMakeMethodInfo);+ newlyCreatedMakeMethodsByItemId.set(+ itemId,+ newMakeMethodInfo+ );+ existingMakeMethodsByItemId.set(+ itemId,+ newMakeMethodInfo+ );}}}