if_,err:=sess.Exec("UPDATE `protected_branch` SET `can_push` = `enable_whitelist`");err!=nil{
returnerr
}
if_,err:=sess.Exec("UPDATE `protected_branch` SET `enable_approvals_whitelist` = ? WHERE `required_approvals` > ?",true,0);err!=nil{
returnerr
}
varpageSizeint64=20
qresult,err:=sess.QueryInterface("SELECT max(id) as max_id FROM issue")
iferr!=nil{
returnerr
}
vartotalIssuesint64
totalIssues,ok:=qresult[0]["max_id"].(int64)
if!ok{
// If there are no issues at all we ignore it
returnnil
}
totalPages:=totalIssues/pageSize
// Find latest review of each user in each pull request, and set official field if appropriate
reviews:=[]*models.Review{}
varpageint64
forpage=0;page<=totalPages;page++{
iferr:=sess.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id > ? AND issue_id <= ? AND type in (?, ?) GROUP BY issue_id, reviewer_id)",