gitea/models/migrations/v15.go
David Schneiderbauer ebac051e72 Rewrite migrations to not depend on future code changes (#2604)
* v38 migration used an outdated version of RepoUnit model (#2602)

* change repoUnit model in migration

* fix v16 migration repo_unit table

* fix lint error

* move type definition inside function

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>

* fix lint error

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>

* Fix time tracking migration

* Refactor code

* Fix migration from Gogs

* v38 migration used an outdated version of RepoUnit model (#2602)

* change repoUnit model in migration

* fix v16 migration repo_unit table

* fix lint error

* move type definition inside function

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>

* fix lint error

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>

* Fix time tracking migration

* Refactor code

* Fix migration from Gogs

* add error check

Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>

* Additiomal fixes for migrations

* Fix timetracking migration

* Add back nil check
2017-10-08 19:08:18 +08:00

26 lines
665 B
Go

// 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 {
type User struct {
KeepEmailPrivate bool
AllowCreateOrganization bool
}
if err := x.Sync2(new(User)); err != nil {
return fmt.Errorf("Sync2: %v", err)
} else if _, err = x.Where("`type` = 0").Cols("allow_create_organization").Update(&User{AllowCreateOrganization: true}); err != nil {
return fmt.Errorf("set allow_create_organization: %v", err)
}
return nil
}