2023-07-07 23:15:30 +02:00
|
|
|
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 {
|
2023-07-09 11:35:52 +02:00
|
|
|
if userData["admin"] == true {
|
2023-07-07 23:15:30 +02:00
|
|
|
userData["role"] = "owner"
|
|
|
|
} else {
|
2023-07-22 22:48:10 +02:00
|
|
|
userData["role"] = "manager"
|
2023-07-07 23:15:30 +02:00
|
|
|
}
|
|
|
|
delete(userData, "admin")
|
|
|
|
err = d.setObject(projectID, "user", userId, userData)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|