2022-01-04 23:13:52 +08:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package migrations
|
|
|
|
|
|
|
|
import (
|
|
|
|
"xorm.io/xorm"
|
|
|
|
"xorm.io/xorm/schemas"
|
|
|
|
)
|
|
|
|
|
|
|
|
func migrateUserPasswordSalt(x *xorm.Engine) error {
|
|
|
|
dbType := x.Dialect().URI().DBType
|
|
|
|
// For SQLITE, the max length doesn't matter.
|
|
|
|
if dbType == schemas.SQLITE {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := modifyColumn(x, "user", &schemas.Column{
|
|
|
|
Name: "rands",
|
|
|
|
SQLType: schemas.SQLType{
|
|
|
|
Name: "VARCHAR",
|
|
|
|
},
|
|
|
|
Length: 32,
|
|
|
|
// MySQL will like us again.
|
2022-06-05 03:18:50 +08:00
|
|
|
Nullable: true,
|
|
|
|
DefaultIsEmpty: true,
|
2022-01-04 23:13:52 +08:00
|
|
|
}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return modifyColumn(x, "user", &schemas.Column{
|
|
|
|
Name: "salt",
|
|
|
|
SQLType: schemas.SQLType{
|
|
|
|
Name: "VARCHAR",
|
|
|
|
},
|
2022-06-05 03:18:50 +08:00
|
|
|
Length: 32,
|
|
|
|
Nullable: true,
|
|
|
|
DefaultIsEmpty: true,
|
2022-01-04 23:13:52 +08:00
|
|
|
})
|
|
|
|
}
|