Synchronise DB upgrades with other DB actions. (#591)