Fixed a bug in --upgrade-db