Minor improvement to DB upgrade code