The old migration had a few issues:
- It left old column names around
- It did not give the right access levels for owners and admins
Also, this includes a migration that fixes the authorization of owner teams, which was previously ORG_ADMIN (instead of ORG_OWNER)
if_,err:=x.Exec("UPDATE team SET authorize=4 WHERE lower_name=?","owners");err!=nil{
returnfmt.Errorf("drop table: %v",err)
}
returnnil
}
funcaccessRefactor(x*xorm.Engine)(errerror){
funcaccessRefactor(x*xorm.Engine)(errerror){
type(
type(
AccessModeint
AccessModeint
Accessstruct{
Accessstruct{
IDint64`xorm:"pk autoincr"`
IDint64`xorm:"pk autoincr"`
UserNamestring
RepoNamestring
UserIDint64`xorm:"UNIQUE(s)"`
UserIDint64`xorm:"UNIQUE(s)"`
RepoIDint64`xorm:"UNIQUE(s)"`
RepoIDint64`xorm:"UNIQUE(s)"`
ModeAccessMode
ModeAccessMode
}
}
UserRepostruct{
UserIDint64
RepoIDint64
}
)
)
varrawSQLstring
// We consiously don't start a session yet as we make only reads for now, no writes
switch{
casesetting.UseSQLite3,setting.UsePostgreSQL:
accessMap:=make(map[UserRepo]AccessMode,50)
rawSQL="DROP INDEX IF EXISTS `UQE_access_S`"
casesetting.UseMySQL:
results,err:=x.Query("SELECT r.id as `repo_id`, r.is_private as `is_private`, r.owner_id as `owner_id`, u.type as `owner_type` FROM `repository` r LEFT JOIN user u ON r.owner_id=u.id")
rawSQL="DROP INDEX `UQE_access_S` ON `access`"
iferr!=nil{
returnerr
}
}
if_,err=x.Exec(rawSQL);err!=nil&&
for_,repo:=rangeresults{
!strings.Contains(err.Error(),"check that column/key exists"){