Fix upgrade from db version 1 to 2