gitea源码

v81.go 709B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_8
  4. import (
  5. "fmt"
  6. "xorm.io/xorm"
  7. "xorm.io/xorm/schemas"
  8. )
  9. func ChangeU2FCounterType(x *xorm.Engine) error {
  10. var err error
  11. switch x.Dialect().URI().DBType {
  12. case schemas.MYSQL:
  13. _, err = x.Exec("ALTER TABLE `u2f_registration` MODIFY `counter` BIGINT")
  14. case schemas.POSTGRES:
  15. _, err = x.Exec("ALTER TABLE `u2f_registration` ALTER COLUMN `counter` SET DATA TYPE bigint")
  16. case schemas.MSSQL:
  17. _, err = x.Exec("ALTER TABLE `u2f_registration` ALTER COLUMN `counter` BIGINT")
  18. }
  19. if err != nil {
  20. return fmt.Errorf("Error changing u2f_registration counter column type: %w", err)
  21. }
  22. return nil
  23. }