batches: support `replaceBatchSpecInput` with existing batch change
requested to merge kr/replace-batch-spec-input-with-existing-batch-change into kr/create-from-raw-with-existing-batch-change
Created by: courier-new
Another part of EM2.4. I didn't initially realize replaceBatchSpecInput
deletes the existing batch spec and creates a new one, but knowing that I've now adapted it as in #28825 to update the associated batch change with the new batch spec ID once it gets created. This required flipping the order of operations (from delete, create to create, delete) so that the foreign key constraint on batch_changes.batch_spec_id
is not violated.
This PR is based on the work from #28825.