summaryrefslogtreecommitdiffstats
path: root/models/migrations
diff options
context:
space:
mode:
authorChri-s <Chri-s@users.noreply.github.com>2018-03-25 12:01:32 +0200
committerLauris BH <lauris@nix.lv>2018-03-25 13:01:32 +0300
commit9350ba7947d8caa6e7338d7c9e54df2f3aef2146 (patch)
treee40e1f9810c03221073742040c7fc2c93b3b7546 /models/migrations
parent04b7fd87b9d74aa6a0c559ac218546978bbf6f33 (diff)
downloadgitea-9350ba7947d8caa6e7338d7c9e54df2f3aef2146.tar.gz
gitea-9350ba7947d8caa6e7338d7c9e54df2f3aef2146.zip
Add protected branch whitelists for merging (#3689)
* Add database migrations for merge whitelist * Add merge whitelist settings for protected branches * Add checks for merge whitelists
Diffstat (limited to 'models/migrations')
-rw-r--r--models/migrations/migrations.go2
-rw-r--r--models/migrations/v59.go24
2 files changed, 26 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index cc5d0bae81..6c3404bcd7 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -170,6 +170,8 @@ var migrations = []Migration{
NewMigration("add closed_unix column for issues", addIssueClosedTime),
// v58 -> v59
NewMigration("add label descriptions", addLabelsDescriptions),
+ // v59 -> v60
+ NewMigration("add merge whitelist for protected branches", addProtectedBranchMergeWhitelist),
}
// Migrate database to current version
diff --git a/models/migrations/v59.go b/models/migrations/v59.go
new file mode 100644
index 0000000000..0a05495e76
--- /dev/null
+++ b/models/migrations/v59.go
@@ -0,0 +1,24 @@
+// Copyright 2018 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"
+
+ "github.com/go-xorm/xorm"
+)
+
+func addProtectedBranchMergeWhitelist(x *xorm.Engine) error {
+ type ProtectedBranch struct {
+ EnableMergeWhitelist bool `xorm:"NOT NULL DEFAULT false"`
+ MergeWhitelistUserIDs []int64 `xorm:"JSON TEXT"`
+ MergeWhitelistTeamIDs []int64 `xorm:"JSON TEXT"`
+ }
+
+ if err := x.Sync2(new(ProtectedBranch)); err != nil {
+ return fmt.Errorf("Sync2: %v", err)
+ }
+ return nil
+}