Semaphore/db/bolt/migration_2_8_91.go
2023-07-22 22:48:10 +02:00

40 lines
756 B
Go

package bolt
type migration_2_8_91 struct {
migration
}
func (d migration_2_8_91) Apply() (err error) {
projectIDs, err := d.getProjectIDs()
if err != nil {
return
}
usersByProjectMap := make(map[string]map[string]map[string]interface{})
for _, projectID := range projectIDs {
usersByProjectMap[projectID], err = d.getObjects(projectID, "user")
if err != nil {
return
}
}
for projectID, projectUsers := range usersByProjectMap {
for userId, userData := range projectUsers {
if userData["admin"] == true {
userData["role"] = "owner"
} else {
userData["role"] = "manager"
}
delete(userData, "admin")
err = d.setObject(projectID, "user", userId, userData)
if err != nil {
return
}
}
}
return
}