2016-12-31 11:33:30 +09:00
|
|
|
// Copyright 2016 Gitea. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package migrations
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2019-10-17 18:26:49 +09:00
|
|
|
"xorm.io/xorm"
|
2016-12-31 11:33:30 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
func createAllowCreateOrganizationColumn(x *xorm.Engine) error {
|
2017-10-08 20:08:18 +09:00
|
|
|
type User struct {
|
|
|
|
KeepEmailPrivate bool
|
|
|
|
AllowCreateOrganization bool
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := x.Sync2(new(User)); err != nil {
|
2016-12-31 11:33:30 +09:00
|
|
|
return fmt.Errorf("Sync2: %v", err)
|
2017-10-08 20:08:18 +09:00
|
|
|
} else if _, err = x.Where("`type` = 0").Cols("allow_create_organization").Update(&User{AllowCreateOrganization: true}); err != nil {
|
2016-12-31 11:33:30 +09:00
|
|
|
return fmt.Errorf("set allow_create_organization: %v", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|