]> source.dussan.org Git - gitea.git/commitdiff
Fix can_push value to false in protected_branch (#2560)
authorLauris BH <lauris@nix.lv>
Wed, 20 Sep 2017 14:52:23 +0000 (17:52 +0300)
committerGitHub <noreply@github.com>
Wed, 20 Sep 2017 14:52:23 +0000 (17:52 +0300)
models/branches.go
models/migrations/migrations.go
models/migrations/v43.go [new file with mode: 0644]

index 1c3c0d17be79a50c8e5041c695c838bc35c45c8e..c26ee7d8905fc3abccefb482d50419bbde0881cc 100644 (file)
@@ -26,6 +26,7 @@ type ProtectedBranch struct {
        ID               int64  `xorm:"pk autoincr"`
        RepoID           int64  `xorm:"UNIQUE(s)"`
        BranchName       string `xorm:"UNIQUE(s)"`
+       CanPush          bool   `xorm:"NOT NULL DEFAULT false"`
        EnableWhitelist  bool
        WhitelistUserIDs []int64   `xorm:"JSON TEXT"`
        WhitelistTeamIDs []int64   `xorm:"JSON TEXT"`
index d302b2c075f810b67a6450d7c23d09df3522eaed..95b8e0774f0a61ef85a151869c314e8d00206ad5 100644 (file)
@@ -134,6 +134,8 @@ var migrations = []Migration{
        NewMigration("add default value to user prohibit_login", addDefaultValueToUserProhibitLogin),
        // v42 -> v43
        NewMigration("add tags to releases and sync existing repositories", releaseAddColumnIsTagAndSyncTags),
+       // v43 -> v44
+       NewMigration("fix protected branch can push value to false", fixProtectedBranchCanPushValue),
 }
 
 // Migrate database to current version
diff --git a/models/migrations/v43.go b/models/migrations/v43.go
new file mode 100644 (file)
index 0000000..b6351fa
--- /dev/null
@@ -0,0 +1,18 @@
+// 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 (
+       "code.gitea.io/gitea/models"
+
+       "github.com/go-xorm/xorm"
+)
+
+func fixProtectedBranchCanPushValue(x *xorm.Engine) error {
+       _, err := x.Cols("can_push").Update(&models.ProtectedBranch{
+               CanPush: false,
+       })
+       return err
+}