diff options
author | Unknwon <u@gogs.io> | 2017-03-27 13:13:04 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-03-27 13:13:04 -0400 |
commit | 1038916460a7ed2fa559bcf2f14b2eecb6ddaad6 (patch) | |
tree | b1a537a8c25d0331e925c5d2600adf62294be34f /models/migrations | |
parent | 73de9f9d6ac806634b22c150d42c66cb942d1088 (diff) |
models/protect_branch: fix whitelist with invalid 'protect_branch_id' (#4333)
If user creates a protect branch for the first time (which has ID=0),
it generates invalid whitelist records with 'protect_branch_id=0'.
This prevents future updates of protect branch whitelist.
Migration: remove existing invalid protect branch whitelist records.
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v17.go | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 99ba8a43..7acd7259 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -62,6 +62,8 @@ var migrations = []Migration{ NewMigration("generate and migrate Git hooks", generateAndMigrateGitHooks), // v15 -> v16:v0.10.16 NewMigration("update repository sizes", updateRepositorySizes), + // v16 -> v17:v0.10.31 + NewMigration("remove invalid protect branch whitelist", removeInvalidProtectBranchWhitelist), } // Migrate database to current version diff --git a/models/migrations/v17.go b/models/migrations/v17.go new file mode 100644 index 00000000..6769b754 --- /dev/null +++ b/models/migrations/v17.go @@ -0,0 +1,14 @@ +// Copyright 2017 The Gogs 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 ( + "github.com/go-xorm/xorm" +) + +func removeInvalidProtectBranchWhitelist(x *xorm.Engine) error { + _, err := x.Exec("DELETE FROM protect_branch_whitelist WHERE protect_branch_id = 0") + return err +} |