code.gitea.io/gitea@v1.21.7/models/migrations/v1_15/v179.go (about)

     1  // Copyright 2021 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package v1_15 //nolint
     5  
     6  import (
     7  	"code.gitea.io/gitea/models/migrations/base"
     8  
     9  	"xorm.io/xorm"
    10  	"xorm.io/xorm/schemas"
    11  )
    12  
    13  func ConvertAvatarURLToText(x *xorm.Engine) error {
    14  	dbType := x.Dialect().URI().DBType
    15  	if dbType == schemas.SQLITE { // For SQLITE, varchar or char will always be represented as TEXT
    16  		return nil
    17  	}
    18  
    19  	// Some oauth2 providers may give very long avatar urls (i.e. Google)
    20  	return base.ModifyColumn(x, "external_login_user", &schemas.Column{
    21  		Name: "avatar_url",
    22  		SQLType: schemas.SQLType{
    23  			Name: schemas.Text,
    24  		},
    25  		Nullable:       true,
    26  		DefaultIsEmpty: true,
    27  	})
    28  }