Browse Source

Fix can_push value to false in protected_branch (#2560)

Lauris BH 3 years ago
parent
commit
6718ea6ff1
3 changed files with 21 additions and 0 deletions
  1. 1 0
      models/branches.go
  2. 2 0
      models/migrations/migrations.go
  3. 18 0
      models/migrations/v43.go

+ 1 - 0
models/branches.go

@@ -26,6 +26,7 @@ type ProtectedBranch struct {
26 26
 	ID               int64  `xorm:"pk autoincr"`
27 27
 	RepoID           int64  `xorm:"UNIQUE(s)"`
28 28
 	BranchName       string `xorm:"UNIQUE(s)"`
29
+	CanPush          bool   `xorm:"NOT NULL DEFAULT false"`
29 30
 	EnableWhitelist  bool
30 31
 	WhitelistUserIDs []int64   `xorm:"JSON TEXT"`
31 32
 	WhitelistTeamIDs []int64   `xorm:"JSON TEXT"`

+ 2 - 0
models/migrations/migrations.go

@@ -134,6 +134,8 @@ var migrations = []Migration{
134 134
 	NewMigration("add default value to user prohibit_login", addDefaultValueToUserProhibitLogin),
135 135
 	// v42 -> v43
136 136
 	NewMigration("add tags to releases and sync existing repositories", releaseAddColumnIsTagAndSyncTags),
137
+	// v43 -> v44
138
+	NewMigration("fix protected branch can push value to false", fixProtectedBranchCanPushValue),
137 139
 }
138 140
 
139 141
 // Migrate database to current version

+ 18 - 0
models/migrations/v43.go

@@ -0,0 +1,18 @@
1
+// Copyright 2017 The Gitea Authors. All rights reserved.
2
+// Use of this source code is governed by a MIT-style
3
+// license that can be found in the LICENSE file.
4
+
5
+package migrations
6
+
7
+import (
8
+	"code.gitea.io/gitea/models"
9
+
10
+	"github.com/go-xorm/xorm"
11
+)
12
+
13
+func fixProtectedBranchCanPushValue(x *xorm.Engine) error {
14
+	_, err := x.Cols("can_push").Update(&models.ProtectedBranch{
15
+		CanPush: false,
16
+	})
17
+	return err
18
+}