Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

v15.go 803B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2016 Gitea. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "fmt"
  7. "github.com/go-xorm/xorm"
  8. )
  9. // UserV15 describes the added field for User
  10. type UserV15 struct {
  11. AllowCreateOrganization bool
  12. }
  13. // TableName will be invoked by XORM to customrize the table name
  14. func (*UserV15) TableName() string {
  15. return "user"
  16. }
  17. func createAllowCreateOrganizationColumn(x *xorm.Engine) error {
  18. if err := x.Sync2(new(UserV15)); err != nil {
  19. return fmt.Errorf("Sync2: %v", err)
  20. } else if _, err = x.Where("type=0").Cols("allow_create_organization").Update(&UserV15{AllowCreateOrganization: true}); err != nil {
  21. return fmt.Errorf("set allow_create_organization: %v", err)
  22. }
  23. return nil
  24. }