Fixing db upgrade bug