ALTER TABLE gateway_worker_instances
  ADD COLUMN capacity_limit integer NOT NULL DEFAULT 0,
  ADD CONSTRAINT gateway_worker_instances_capacity_limit_check
    CHECK (capacity_limit >= 0);

UPDATE gateway_worker_instances
SET capacity_limit = GREATEST(allocated_capacity, 1)
WHERE capacity_limit = 0;
