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.

1.0 KB
Raw Blame
-- "Include work instructions" is now a Job Traveler template option (operations
-- block "Show work instructions"). The company flag used to be authoritative at
-- render, so bake each company's actual flag value into its jobTraveler
-- template's operations block before dropping the column — true OR false — so
-- travelers render identically. (Companies with no stored template fall back to
-- the template default of OFF, matching the old column default of false.)
UPDATE "documentTemplate" dt
SET blocks = (
  SELECT jsonb_agg(
    CASE
      WHEN block->>'type' = 'operations' THEN block
        || jsonb_build_object(
             'showWorkInstructions', cs."jobTravelerIncludeWorkInstructions"
           )
      ELSE block
    END
  )
  FROM jsonb_array_elements(dt.blocks) AS block
)
FROM "companySettings" cs
WHERE cs.id = dt."companyId"
  AND dt."documentType" = 'jobTraveler'
  AND dt.blocks @> '[{"type":"operations"}]';

ALTER TABLE "companySettings"
  DROP COLUMN IF EXISTS "jobTravelerIncludeWorkInstructions";