Browse Source

Fix broken migration to add can_push field back to table (#2574)

Lauris BH 2 years ago
parent
commit
2db424c3f1
1 changed files with 10 additions and 2 deletions
  1. 10 2
      models/migrations/v43.go

+ 10 - 2
models/migrations/v43.go

@@ -5,13 +5,21 @@
5 5
 package migrations
6 6
 
7 7
 import (
8
-	"code.gitea.io/gitea/models"
8
+	"fmt"
9 9
 
10 10
 	"github.com/go-xorm/xorm"
11 11
 )
12 12
 
13 13
 func fixProtectedBranchCanPushValue(x *xorm.Engine) error {
14
-	_, err := x.Cols("can_push").Update(&models.ProtectedBranch{
14
+	type ProtectedBranch struct {
15
+		CanPush bool `xorm:"NOT NULL DEFAULT false"`
16
+	}
17
+
18
+	if err := x.Sync2(new(ProtectedBranch)); err != nil {
19
+		return fmt.Errorf("Sync2: %v", err)
20
+	}
21
+
22
+	_, err := x.Cols("can_push").Update(&ProtectedBranch{
15 23
 		CanPush: false,
16 24
 	})
17 25
 	return err