diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2018-01-07 23:48:37 -0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-01-08 09:48:37 +0200 |
commit | f48680888c14ad3dfe9cadb8efa4c8221731b71e (patch) | |
tree | 441f01ee6e43df6e28f86242dd983b2f52af8c8b /models/migrations | |
parent | cb868b78513b666905c8cd4facca68ed54c7f814 (diff) | |
download | gitea-f48680888c14ad3dfe9cadb8efa4c8221731b71e.tar.gz gitea-f48680888c14ad3dfe9cadb8efa4c8221731b71e.zip |
Remove IsOwner, NumTeams from OrgUser (#3269)
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v56.go | 33 |
2 files changed, 35 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 37f3717ff4..23235f7819 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -164,6 +164,8 @@ var migrations = []Migration{ NewMigration("add pull request options", addPullRequestOptions), // v55 -> v56 NewMigration("add writable deploy keys", addModeToDeploKeys), + // v56 -> v57 + NewMigration("remove is_owner, num_teams columns from org_user", removeIsOwnerColumnFromOrgUser), } // Migrate database to current version diff --git a/models/migrations/v56.go b/models/migrations/v56.go new file mode 100644 index 0000000000..bbaee28a92 --- /dev/null +++ b/models/migrations/v56.go @@ -0,0 +1,33 @@ +// Copyright 2017 The Gitea Authors. 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" + + "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/setting" + + "github.com/go-xorm/xorm" +) + +func removeIsOwnerColumnFromOrgUser(x *xorm.Engine) (err error) { + switch { + case setting.UseSQLite3: + log.Warn("Unable to drop columns in SQLite") + case setting.UseMySQL, setting.UseTiDB, setting.UsePostgreSQL: + if _, err := x.Exec("ALTER TABLE org_user DROP COLUMN is_owner, DROP COLUMN num_teams"); err != nil { + return fmt.Errorf("DROP COLUMN org_user.is_owner, org_user.num_teams: %v", err) + } + case setting.UseMSSQL: + if _, err := x.Exec("ALTER TABLE org_user DROP COLUMN is_owner, num_teams"); err != nil { + return fmt.Errorf("DROP COLUMN org_user.is_owner, org_user.num_teams: %v", err) + } + default: + log.Fatal(4, "Unrecognized DB") + } + + return nil +} |