chore(db): introduce db.Session and db.EngineMigration interfaces (#37746)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Copilot
2026-05-18 03:56:39 +08:00
committed by GitHub
co-authored by copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> wxiaoguang wxiaoguang
parent d9149d8a0a
commit 94e3482d1a
300 changed files with 745 additions and 864 deletions
+2 -4
View File
@@ -3,11 +3,9 @@
package v1_7
import (
"xorm.io/xorm"
)
import "code.gitea.io/gitea/models/db"
func AddMustChangePassword(x *xorm.Engine) error {
func AddMustChangePassword(x db.EngineMigration) error {
// User see models/user.go
type User struct {
ID int64 `xorm:"pk autoincr"`
+2 -2
View File
@@ -3,9 +3,9 @@
package v1_7
import "xorm.io/xorm"
import "code.gitea.io/gitea/models/db"
func AddApprovalWhitelistsToProtectedBranches(x *xorm.Engine) error {
func AddApprovalWhitelistsToProtectedBranches(x db.EngineMigration) error {
type ProtectedBranch struct {
ApprovalsWhitelistUserIDs []int64 `xorm:"JSON TEXT"`
ApprovalsWhitelistTeamIDs []int64 `xorm:"JSON TEXT"`
+3 -2
View File
@@ -4,11 +4,12 @@
package v1_7
import (
"code.gitea.io/gitea/models/db"
"xorm.io/builder"
"xorm.io/xorm"
)
func ClearNonusedData(x *xorm.Engine) error {
func ClearNonusedData(x db.EngineMigration) error {
condDelete := func(colName string) builder.Cond {
return builder.NotIn(colName, builder.Select("id").From("`user`"))
}