File tree 2 files changed +49
-0
lines changed
2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -475,6 +475,8 @@ var migrations = []Migration{
475
475
NewMigration ("Fix incorrect project type" , v1_20 .FixIncorrectProjectType ),
476
476
// v248 -> v249
477
477
NewMigration ("Add version column to action_runner table" , v1_20 .AddVersionToActionRunner ),
478
+ // v249 -> v250
479
+ NewMigration ("Fix incorrect owner team unit access mode" , v1_20 .FixIncorrectOwnerTeamUnitAccessMode ),
478
480
}
479
481
480
482
// GetCurrentDBVersion returns the current db version
Original file line number Diff line number Diff line change
1
+ // Copyright 2023 The Gitea Authors. All rights reserved.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ package v1_20 //nolint
5
+
6
+ import (
7
+ "code.gitea.io/gitea/modules/log"
8
+
9
+ "xorm.io/xorm"
10
+ )
11
+
12
+ func FixIncorrectOwnerTeamUnitAccessMode (x * xorm.Engine ) error {
13
+ type UnitType int
14
+ type AccessMode int
15
+
16
+ type TeamUnit struct {
17
+ ID int64 `xorm:"pk autoincr"`
18
+ OrgID int64 `xorm:"INDEX"`
19
+ TeamID int64 `xorm:"UNIQUE(s)"`
20
+ Type UnitType `xorm:"UNIQUE(s)"`
21
+ AccessMode AccessMode
22
+ }
23
+
24
+ const (
25
+ // AccessModeOwner owner access
26
+ AccessModeOwner = 4
27
+ )
28
+
29
+ sess := x .NewSession ()
30
+ defer sess .Close ()
31
+
32
+ if err := sess .Begin (); err != nil {
33
+ return err
34
+ }
35
+
36
+ count , err := sess .Table ("team_unit" ).
37
+ Where ("team_id IN (SELECT id FROM team WHERE authorize = ?)" , AccessModeOwner ).
38
+ Update (& TeamUnit {
39
+ AccessMode : AccessModeOwner ,
40
+ })
41
+ if err != nil {
42
+ return err
43
+ }
44
+ log .Debug ("Updated %d owner team unit access mode to belong to owner instead of none" , count )
45
+
46
+ return sess .Commit ()
47
+ }
You can’t perform that action at this time.
0 commit comments