fixed bug in database upgrade procedure (move flags)