Skip to content

Commit de62b05

Browse files
committed
add db migration
1 parent f5992a7 commit de62b05

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ var migrations = []Migration{
467467

468468
// v244 -> v245
469469
NewMigration("Add NeedApproval to actions tables", v1_20.AddNeedApprovalToActionRun),
470+
// v245 -> v246
471+
NewMigration("Fix incorrect project type", v1_20.FixIncorrectProjectType),
470472
}
471473

472474
// GetCurrentDBVersion returns the current db version

models/migrations/v1_20/v245.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_20 //nolint
5+
6+
import (
7+
"xorm.io/xorm"
8+
)
9+
10+
// FixIncorrectProjectType: set individual project's type from 3(TypeOrganization) to 1(TypeIndividual)
11+
func FixIncorrectProjectType(x *xorm.Engine) error {
12+
_, err := x.Exec("UPDATE project SET type = ? FROM user WHERE user.id = project.owner_id AND project.type = ? AND user.type = ?", 1, 3, 0)
13+
14+
return err
15+
}

0 commit comments

Comments
 (0)