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.

490 B
Raw Blame
-- Make the customerId column nullable
ALTER TABLE "opportunity" ALTER COLUMN "customerId" DROP NOT NULL;

-- Drop the existing foreign key constraint (currently ON DELETE CASCADE)
ALTER TABLE "opportunity" DROP CONSTRAINT IF EXISTS "opportunity_customerId_fkey";

-- Add the foreign key constraint with ON DELETE SET NULL
ALTER TABLE "opportunity" ADD CONSTRAINT "opportunity_customerId_fkey"
  FOREIGN KEY ("customerId") REFERENCES "customer" ("id") ON DELETE SET NULL ON UPDATE CASCADE;