2016-12-31 10:33:30 +08: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"
|
|
|
|
|
|
|
|
"github.com/go-xorm/xorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
func createAllowCreateOrganizationColumn(x *xorm.Engine) error {
|
2017-10-08 19:08:18 +08:00
|
|
|
type User struct {
|
|
|
|
KeepEmailPrivate bool
|
|
|
|
AllowCreateOrganization bool
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := x.Sync2(new(User)); err != nil {
|
2016-12-31 10:33:30 +08:00
|
|
|
return fmt.Errorf("Sync2: %v", err)
|
2017-10-08 19:08:18 +08:00
|
|
|
} else if _, err = x.Where("`type` = 0").Cols("allow_create_organization").Update(&User{AllowCreateOrganization: true}); err != nil {
|
2016-12-31 10:33:30 +08:00
|
|
|
return fmt.Errorf("set allow_create_organization: %v", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|