Fixing issue with database upgrade