1
- // Copyright 2017 The Gitea Authors. All rights reserved.
1
+ // Copyright 2018 The Gitea Authors. All rights reserved.
2
2
// Use of this source code is governed by a MIT-style
3
3
// license that can be found in the LICENSE file.
4
4
@@ -7,51 +7,17 @@ package migrations
7
7
import (
8
8
"fmt"
9
9
10
- "code.gitea.io/gitea/modules/util"
11
-
10
+ "code.gitea.io/gitea/models"
12
11
"github.com/go-xorm/xorm"
13
12
)
14
13
15
- func addPullRequestOptions (x * xorm.Engine ) error {
16
- // RepoUnit describes all units of a repository
17
- type RepoUnit struct {
18
- ID int64
19
- RepoID int64 `xorm:"INDEX(s)"`
20
- Type int `xorm:"INDEX(s)"`
21
- Config map [string ]interface {} `xorm:"JSON"`
22
- CreatedUnix util.TimeStamp `xorm:"INDEX CREATED"`
23
- }
24
-
25
- sess := x .NewSession ()
26
- defer sess .Close ()
27
- if err := sess .Begin (); err != nil {
28
- return err
14
+ func addModeToDeploKeys (x * xorm.Engine ) error {
15
+ type DeployKey struct {
16
+ Mode models.AccessMode `xorm:"NOT NULL DEFAULT 1"`
29
17
}
30
18
31
- //Updating existing issue units
32
- units := make ([]* RepoUnit , 0 , 100 )
33
- if err := sess .Where ("`type` = ?" , V16UnitTypePRs ).Find (& units ); err != nil {
34
- return fmt .Errorf ("Query repo units: %v" , err )
35
- }
36
- for _ , unit := range units {
37
- if unit .Config == nil {
38
- unit .Config = make (map [string ]interface {})
39
- }
40
- if _ , ok := unit .Config ["IgnoreWhitespaceConflicts" ]; ! ok {
41
- unit .Config ["IgnoreWhitespaceConflicts" ] = false
42
- }
43
- if _ , ok := unit .Config ["AllowMerge" ]; ! ok {
44
- unit .Config ["AllowMerge" ] = true
45
- }
46
- if _ , ok := unit .Config ["AllowRebase" ]; ! ok {
47
- unit .Config ["AllowRebase" ] = true
48
- }
49
- if _ , ok := unit .Config ["AllowSquash" ]; ! ok {
50
- unit .Config ["AllowSquash" ] = true
51
- }
52
- if _ , err := sess .ID (unit .ID ).Cols ("config" ).Update (unit ); err != nil {
53
- return err
54
- }
19
+ if err := x .Sync2 (new (DeployKey )); err != nil {
20
+ return fmt .Errorf ("Sync2: %v" , err )
55
21
}
56
- return sess . Commit ()
22
+ return nil
57
23
}
0 commit comments