Skip to content

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.

fix(shared): repair PostgREST embeds broken by composite tenant FKs (#1144)

Naveen Kashyap27eef986ffce
diff --git a/apps/erp/app/modules/shared/shared.service.ts b/apps/erp/app/modules/shared/shared.service.ts
index ae1c5c1044..f82397c368 100644
--- a/apps/erp/app/modules/shared/shared.service.ts
+++ b/apps/erp/app/modules/shared/shared.service.ts
@@ -1077,10 +1077,9 @@ export async function getCustomerPortal(
}
>
> {
- // @ts-expect-error Supabase composite key issue
return client
.from("externalLink")
- .select("*, customer:customerId(id, name)")
+ .select("*, customer(id, name)")
.eq("id", id)
.eq("documentType", "Customer")
.single();
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
index ad31947b2d..41490067ee 100644
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
@@ -1,5 +1,5 @@
{
- "generated": "2026-07-14T01:23:55.918Z",
+ "generated": "2026-07-14T19:38:37.774Z",
"totalTools": 1327,
"modules": 15,
"tools": [
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.delete.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.delete.tsx
index 418b45600e..6e0ecab7d4 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.delete.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.$supplierPartId.delete.tsx
@@ -16,10 +16,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const { supplierPartId } = params;
if (!supplierPartId) throw notFound("supplierPartId not found");
- // @ts-expect-error TS2589 — Supabase joined-select type instantiation too deep
const result = await client
.from("supplierPart")
- .select("id, supplierId, supplier:supplierId(name)")
+ .select("id, supplierId, supplier(name)")
.eq("id", supplierPartId)
.eq("companyId", companyId)
.single();
diff --git a/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.delete.tsx b/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.delete.tsx
index 3e081be320..5ee06b0dea 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.delete.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.purchasing.$supplierPartId.delete.tsx
@@ -21,7 +21,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
// green whether or not it triggers.
const result = await client
.from("supplierPart")
- .select("id, supplierId, supplier:supplierId(name)")
+ .select("id, supplierId, supplier(name)")
.eq("id", supplierPartId)
.eq("companyId", companyId)
.single();
diff --git a/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.delete.tsx b/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.delete.tsx
index cad3442e18..0f4bcb07d7 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.delete.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.purchasing.$supplierPartId.delete.tsx
@@ -18,7 +18,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const result = await client
.from("supplierPart")
- .select("id, supplierId, supplier:supplierId(name)")
+ .select("id, supplierId, supplier(name)")
.eq("id", supplierPartId)
.eq("companyId", companyId)
.single();
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.delete.tsx b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.delete.tsx
index 94e0bc6aa4..ffa3e191d3 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.delete.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.$supplierPartId.delete.tsx
@@ -21,7 +21,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
// green whether or not it triggers.
const result = await client
.from("supplierPart")
- .select("id, supplierId, supplier:supplierId(name)")
+ .select("id, supplierId, supplier(name)")
.eq("id", supplierPartId)
.eq("companyId", companyId)
.single();