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.

665 B
Raw Blame
-- Make the price-break (parent, quantity) UNIQUE deferrable so upsertCustomerItem-
-- PriceOverride can shift a quantity ladder one rung at a time without tripping a
-- transient duplicate. INITIALLY IMMEDIATE keeps default checking for other writers;
-- the break sync opts in with SET CONSTRAINTS ... DEFERRED to move the check to commit.

ALTER TABLE "customerItemPriceOverrideBreak"
  DROP CONSTRAINT IF EXISTS "customerItemPriceOverrideBreak_override_qty_uq";

ALTER TABLE "customerItemPriceOverrideBreak"
  ADD CONSTRAINT "customerItemPriceOverrideBreak_override_qty_uq"
  UNIQUE ("customerItemPriceOverrideId", "quantity")
  DEFERRABLE INITIALLY IMMEDIATE;