mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-09 03:11:51 +01:00
ebac051e72
* 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
25 lines
665 B
Go
25 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
|
|
}
|