hide issues from org private repos w/o team assignment (#4034)
parent
46d19c4676
commit
0b3ea42847
@ -0,0 +1,209 @@
|
|||||||
|
-
|
||||||
|
id: 1
|
||||||
|
team_id: 1
|
||||||
|
type: 1
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 2
|
||||||
|
team_id: 1
|
||||||
|
type: 2
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 3
|
||||||
|
team_id: 1
|
||||||
|
type: 3
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 4
|
||||||
|
team_id: 1
|
||||||
|
type: 4
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 5
|
||||||
|
team_id: 1
|
||||||
|
type: 5
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 6
|
||||||
|
team_id: 1
|
||||||
|
type: 6
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 7
|
||||||
|
team_id: 1
|
||||||
|
type: 7
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 8
|
||||||
|
team_id: 2
|
||||||
|
type: 1
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 9
|
||||||
|
team_id: 2
|
||||||
|
type: 2
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 10
|
||||||
|
team_id: 2
|
||||||
|
type: 3
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 11
|
||||||
|
team_id: 2
|
||||||
|
type: 4
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 12
|
||||||
|
team_id: 2
|
||||||
|
type: 5
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 13
|
||||||
|
team_id: 2
|
||||||
|
type: 6
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 14
|
||||||
|
team_id: 2
|
||||||
|
type: 7
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 15
|
||||||
|
team_id: 3
|
||||||
|
type: 1
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 16
|
||||||
|
team_id: 3
|
||||||
|
type: 2
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 17
|
||||||
|
team_id: 3
|
||||||
|
type: 3
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 18
|
||||||
|
team_id: 3
|
||||||
|
type: 4
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 19
|
||||||
|
team_id: 3
|
||||||
|
type: 5
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 20
|
||||||
|
team_id: 3
|
||||||
|
type: 6
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 21
|
||||||
|
team_id: 3
|
||||||
|
type: 7
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 22
|
||||||
|
team_id: 4
|
||||||
|
type: 1
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 23
|
||||||
|
team_id: 4
|
||||||
|
type: 2
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 24
|
||||||
|
team_id: 4
|
||||||
|
type: 3
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 25
|
||||||
|
team_id: 4
|
||||||
|
type: 4
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 26
|
||||||
|
team_id: 4
|
||||||
|
type: 5
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 27
|
||||||
|
team_id: 4
|
||||||
|
type: 6
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 28
|
||||||
|
team_id: 4
|
||||||
|
type: 7
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 29
|
||||||
|
team_id: 5
|
||||||
|
type: 1
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 30
|
||||||
|
team_id: 5
|
||||||
|
type: 2
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 31
|
||||||
|
team_id: 5
|
||||||
|
type: 3
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 32
|
||||||
|
team_id: 5
|
||||||
|
type: 4
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 33
|
||||||
|
team_id: 5
|
||||||
|
type: 5
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 34
|
||||||
|
team_id: 5
|
||||||
|
type: 6
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 35
|
||||||
|
team_id: 5
|
||||||
|
type: 7
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 36
|
||||||
|
team_id: 6
|
||||||
|
type: 1
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 37
|
||||||
|
team_id: 6
|
||||||
|
type: 2
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 38
|
||||||
|
team_id: 6
|
||||||
|
type: 3
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 39
|
||||||
|
team_id: 6
|
||||||
|
type: 4
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 40
|
||||||
|
team_id: 6
|
||||||
|
type: 5
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 41
|
||||||
|
team_id: 6
|
||||||
|
type: 6
|
||||||
|
|
||||||
|
-
|
||||||
|
id: 42
|
||||||
|
team_id: 6
|
||||||
|
type: 7
|
@ -0,0 +1,80 @@
|
|||||||
|
// Copyright 2018 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 (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/go-xorm/xorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func moveTeamUnitsToTeamUnitTable(x *xorm.Engine) error {
|
||||||
|
// Team see models/team.go
|
||||||
|
type Team struct {
|
||||||
|
ID int64
|
||||||
|
OrgID int64
|
||||||
|
UnitTypes []int `xorm:"json"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TeamUnit see models/org_team.go
|
||||||
|
type TeamUnit struct {
|
||||||
|
ID int64 `xorm:"pk autoincr"`
|
||||||
|
OrgID int64 `xorm:"INDEX"`
|
||||||
|
TeamID int64 `xorm:"UNIQUE(s)"`
|
||||||
|
Type int `xorm:"UNIQUE(s)"`
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := x.Sync2(new(TeamUnit)); err != nil {
|
||||||
|
return fmt.Errorf("Sync2: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sess := x.NewSession()
|
||||||
|
defer sess.Close()
|
||||||
|
|
||||||
|
if err := sess.Begin(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update team unit types
|
||||||
|
const batchSize = 100
|
||||||
|
for start := 0; ; start += batchSize {
|
||||||
|
teams := make([]*Team, 0, batchSize)
|
||||||
|
if err := x.Limit(batchSize, start).Find(&teams); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(teams) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, team := range teams {
|
||||||
|
var unitTypes []int
|
||||||
|
if len(team.UnitTypes) == 0 {
|
||||||
|
unitTypes = allUnitTypes
|
||||||
|
} else {
|
||||||
|
unitTypes = team.UnitTypes
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert units for team
|
||||||
|
var units = make([]TeamUnit, 0, len(unitTypes))
|
||||||
|
for _, tp := range unitTypes {
|
||||||
|
units = append(units, TeamUnit{
|
||||||
|
OrgID: team.OrgID,
|
||||||
|
TeamID: team.ID,
|
||||||
|
Type: tp,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := sess.Insert(&units); err != nil {
|
||||||
|
return fmt.Errorf("Insert team units: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := dropTableColumns(sess, "team", "unit_types"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return sess.Commit()
|
||||||
|
}
|
Loading…
Reference in New Issue