Skip to content

Commit 81e6b16

Browse files
committed
Migration to fix existing owner team units
1 parent e7ae13d commit 81e6b16

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ var migrations = []Migration{
116116
NewMigration("add units for team", addUnitsToRepoTeam),
117117
// v33 -> v34
118118
NewMigration("remove columns from action", removeActionColumns),
119+
// v34 -> v35
120+
NewMigration("give all units to owner teams", giveAllUnitsToOwnerTeams),
119121
}
120122

121123
// Migrate database to current version

models/migrations/v34.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2017 Gitea. 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+
"github.com/go-xorm/xorm"
9+
)
10+
11+
// Team see models/team.go
12+
type Team struct {
13+
UnitTypes []int `xorm:"json"`
14+
}
15+
16+
const ownerAccessMode = 4
17+
18+
var allUnitTypes = []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
19+
20+
func giveAllUnitsToOwnerTeams(x *xorm.Engine) error {
21+
_, err := x.Cols("unit_types").
22+
Where("authorize = ?", ownerAccessMode).
23+
Update(&Team{UnitTypes: allUnitTypes})
24+
return err
25+
}

0 commit comments

Comments
 (0)