If the only change being made is to the indexes, that can be done outside of enumerateOldFiles, I think, and in that case, the enumeration would not be necessary at all.  Upgrades will be rare enough that performance is not critical here, but it might be worth moving that code.

I also wonder whether using a regular cursor rather than calling mozGetAll() would be a faster way to do the upgrade. To try that, you'd have to convert upgradeDBVer2to3 and handleClientUpgrade so that they operated on only a single record rather than an array of records. For very large databases that would be more memory efficient.  I don't know whether it would be faster or slower. And to be honest, though, if you've got a working patch now, I'm not certain that it is worth taking the time to make and test that change.