mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-22 23:01:38 +02:00
Migrations should never use model structs directly, because the model structs can be different in different releases. e.g. if one migration uses "User" model, it works in the early releases, then one day, when the User model changes, the migration breaks because it will use the new (incorrect) User model, it should only use the old User model. The same to "modules/structs". --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package v1_25
|
|
|
|
import (
|
|
"gitea.dev/modelmigration/base"
|
|
"gitea.dev/modules/setting"
|
|
|
|
"xorm.io/xorm/schemas"
|
|
)
|
|
|
|
func UseLongTextInSomeColumnsAndFixBugs(x base.EngineMigration) error {
|
|
if !setting.Database.Type.IsMySQL() {
|
|
return nil // Only mysql need to change from text to long text, for other databases, they are the same
|
|
}
|
|
|
|
if err := base.ModifyColumn(x, "review_state", &schemas.Column{
|
|
Name: "updated_files",
|
|
SQLType: schemas.SQLType{
|
|
Name: "LONGTEXT",
|
|
},
|
|
Length: 0,
|
|
Nullable: false,
|
|
DefaultIsEmpty: true,
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := base.ModifyColumn(x, "package_property", &schemas.Column{
|
|
Name: "value",
|
|
SQLType: schemas.SQLType{
|
|
Name: "LONGTEXT",
|
|
},
|
|
Length: 0,
|
|
Nullable: false,
|
|
DefaultIsEmpty: true,
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
|
|
return base.ModifyColumn(x, "notice", &schemas.Column{
|
|
Name: "description",
|
|
SQLType: schemas.SQLType{
|
|
Name: "LONGTEXT",
|
|
},
|
|
Length: 0,
|
|
Nullable: false,
|
|
DefaultIsEmpty: true,
|
|
})
|
|
}
|