2022-01-05 00:13:52 +09:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-28 03:20:29 +09:00
|
|
|
// SPDX-License-Identifier: MIT
|
2022-01-05 00:13:52 +09:00
|
|
|
|
2022-11-02 17:54:36 +09:00
|
|
|
package v1_16 //nolint
|
2022-01-05 00:13:52 +09:00
|
|
|
|
|
|
|
import (
|
2022-11-02 17:54:36 +09:00
|
|
|
"code.gitea.io/gitea/models/migrations/base"
|
|
|
|
|
2022-01-05 00:13:52 +09:00
|
|
|
"xorm.io/xorm"
|
|
|
|
"xorm.io/xorm/schemas"
|
|
|
|
)
|
|
|
|
|
2022-11-02 17:54:36 +09:00
|
|
|
func MigrateUserPasswordSalt(x *xorm.Engine) error {
|
2022-01-05 00:13:52 +09:00
|
|
|
dbType := x.Dialect().URI().DBType
|
|
|
|
// For SQLITE, the max length doesn't matter.
|
|
|
|
if dbType == schemas.SQLITE {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-11-02 17:54:36 +09:00
|
|
|
if err := base.ModifyColumn(x, "user", &schemas.Column{
|
2022-01-05 00:13:52 +09:00
|
|
|
Name: "rands",
|
|
|
|
SQLType: schemas.SQLType{
|
|
|
|
Name: "VARCHAR",
|
|
|
|
},
|
|
|
|
Length: 32,
|
|
|
|
// MySQL will like us again.
|
2022-06-05 04:18:50 +09:00
|
|
|
Nullable: true,
|
|
|
|
DefaultIsEmpty: true,
|
2022-01-05 00:13:52 +09:00
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-11-02 17:54:36 +09:00
|
|
|
return base.ModifyColumn(x, "user", &schemas.Column{
|
2022-01-05 00:13:52 +09:00
|
|
|
Name: "salt",
|
|
|
|
SQLType: schemas.SQLType{
|
|
|
|
Name: "VARCHAR",
|
|
|
|
},
|
2022-06-05 04:18:50 +09:00
|
|
|
Length: 32,
|
|
|
|
Nullable: true,
|
|
|
|
DefaultIsEmpty: true,
|
2022-01-05 00:13:52 +09:00
|
|
|
})
|
|
|
|
}
|