2019-03-05 08:04:52 +05:30
|
|
|
// Copyright 2019 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.
|
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
package v1_8 // nolint
|
2019-03-05 08:04:52 +05:30
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2019-10-17 14:56:49 +05:30
|
|
|
"xorm.io/xorm"
|
2020-03-22 20:42:55 +05:30
|
|
|
"xorm.io/xorm/schemas"
|
2019-03-05 08:04:52 +05:30
|
|
|
)
|
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
func ChangeU2FCounterType(x *xorm.Engine) error {
|
2019-03-05 08:04:52 +05:30
|
|
|
var err error
|
|
|
|
|
2020-03-22 20:42:55 +05:30
|
|
|
switch x.Dialect().URI().DBType {
|
|
|
|
case schemas.MYSQL:
|
2019-03-05 08:04:52 +05:30
|
|
|
_, err = x.Exec("ALTER TABLE `u2f_registration` MODIFY `counter` BIGINT")
|
2020-03-22 20:42:55 +05:30
|
|
|
case schemas.POSTGRES:
|
2019-03-05 08:04:52 +05:30
|
|
|
_, err = x.Exec("ALTER TABLE `u2f_registration` ALTER COLUMN `counter` SET DATA TYPE bigint")
|
2020-03-22 20:42:55 +05:30
|
|
|
case schemas.MSSQL:
|
2019-03-05 08:04:52 +05:30
|
|
|
_, err = x.Exec("ALTER TABLE `u2f_registration` ALTER COLUMN `counter` BIGINT")
|
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
2022-10-25 00:59:17 +05:30
|
|
|
return fmt.Errorf("Error changing u2f_registration counter column type: %w", err)
|
2019-03-05 08:04:52 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|