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
feat: remove the foreign key constraint updates to contacts
Brad Barbin5924ef49472d
diff --git a/packages/database/supabase/migrations/20241205132822_unique-contact-email.sql b/packages/database/supabase/migrations/20241205132822_unique-contact-email.sqlindex e356f48ff7..429c279c10 100644--- a/packages/database/supabase/migrations/20241205132822_unique-contact-email.sql+++ b/packages/database/supabase/migrations/20241205132822_unique-contact-email.sql@@ -1,46 +1,2 @@-ALTER TABLE "quote" DROP CONSTRAINT IF EXISTS "quote_customerContactId_fkey",-ADD CONSTRAINT "quote_customerContactId_fkey"-FOREIGN KEY ("customerContactId")-REFERENCES "contact"(id)-ON DELETE SET NULL;--ALTER TABLE "salesOrder" DROP CONSTRAINT IF EXISTS "salesOrder_customerContactId_fkey",-ADD CONSTRAINT "salesOrder_customerContactId_fkey"-FOREIGN KEY ("customerContactId")-REFERENCES "contact"(id)-ON DELETE SET NULL;--ALTER TABLE "purchaseOrder" DROP CONSTRAINT IF EXISTS "purchaseOrder_supplierContactId_fkey",-ADD CONSTRAINT "purchaseOrder_supplierContactId_fkey"-FOREIGN KEY ("supplierContactId")-REFERENCES "contact"(id)-ON DELETE SET NULL;---WITH- duplicates AS (- SELECT- email,- "companyId",- COUNT(*) AS count- FROM- "contact"- GROUP BY- email,- "companyId"- HAVING- COUNT(*) > 1- )-DELETE FROM "contact"-WHERE- (email, "companyId") IN (- SELECT- email,- "companyId"- FROM- duplicates- );---- Now, add the unique constraintALTER TABLE "contact"ADD CONSTRAINT "contact_email_companyId_unique" UNIQUE ("email", "companyId");\ No newline at end of file