2021-04-14 08:02:12 -04:00
|
|
|
// Copyright 2021 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-04-14 08:02:12 -04:00
|
|
|
|
2022-11-02 04:54:36 -04:00
|
|
|
package v1_15 //nolint
|
2021-04-14 08:02:12 -04:00
|
|
|
|
|
|
|
import (
|
2022-11-02 04:54:36 -04:00
|
|
|
"code.gitea.io/gitea/models/migrations/base"
|
|
|
|
|
2021-04-14 08:02:12 -04:00
|
|
|
"xorm.io/xorm"
|
|
|
|
"xorm.io/xorm/schemas"
|
|
|
|
)
|
|
|
|
|
2022-11-02 04:54:36 -04:00
|
|
|
func ConvertAvatarURLToText(x *xorm.Engine) error {
|
2021-04-14 08:02:12 -04:00
|
|
|
dbType := x.Dialect().URI().DBType
|
|
|
|
if dbType == schemas.SQLITE { // For SQLITE, varchar or char will always be represented as TEXT
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some oauth2 providers may give very long avatar urls (i.e. Google)
|
2022-11-02 04:54:36 -04:00
|
|
|
return base.ModifyColumn(x, "external_login_user", &schemas.Column{
|
2021-04-14 08:02:12 -04:00
|
|
|
Name: "avatar_url",
|
|
|
|
SQLType: schemas.SQLType{
|
|
|
|
Name: schemas.Text,
|
|
|
|
},
|
2022-06-04 15:18:50 -04:00
|
|
|
Nullable: true,
|
|
|
|
DefaultIsEmpty: true,
|
2021-04-14 08:02:12 -04:00
|
|
|
})
|
|
|
|
}
|