Core: fixed upgrade sql.