Fix upgrade script