Fix upgrade process after issue #3314.

NOTE: This hasn't been tested yet. It's just a suggestion for how we can solve it.