diff options
author | Maurizio Porrato <maurizio.porrato@gmail.com> | 2019-03-05 02:34:52 +0000 |
---|---|---|
committer | techknowlogick <matti@mdranta.net> | 2019-03-04 21:34:52 -0500 |
commit | 19862699cd4fcac672cf87310b192d3182357086 (patch) | |
tree | daf50ff68513844f2b065dac4888872ab9b0058d /models/migrations | |
parent | 141c58f5a6353a3e9173ababd1532819ba2ee284 (diff) | |
download | gitea-19862699cd4fcac672cf87310b192d3182357086.tar.gz gitea-19862699cd4fcac672cf87310b192d3182357086.zip |
Override xorm type mapping for U2F counter (#6232)
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v81.go | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 652abd122a..1fde096fbe 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -215,6 +215,8 @@ var migrations = []Migration{ NewMigration("add can close issues via commit in any branch", addCanCloseIssuesViaCommitInAnyBranch), // v80 -> v81 NewMigration("add is locked to issues", addIsLockedToIssues), + // v81 -> v82 + NewMigration("update U2F counter type", changeU2FCounterType), } // Migrate database to current version diff --git a/models/migrations/v81.go b/models/migrations/v81.go new file mode 100644 index 0000000000..56bb8477e6 --- /dev/null +++ b/models/migrations/v81.go @@ -0,0 +1,32 @@ +// 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. + +package migrations + +import ( + "fmt" + + "github.com/go-xorm/xorm" +) + +func changeU2FCounterType(x *xorm.Engine) error { + var err error + + switch x.Dialect().DriverName() { + case "tidb": + fallthrough + case "mysql": + _, err = x.Exec("ALTER TABLE `u2f_registration` MODIFY `counter` BIGINT") + case "postgres": + _, err = x.Exec("ALTER TABLE `u2f_registration` ALTER COLUMN `counter` SET DATA TYPE bigint") + case "mssql": + _, err = x.Exec("ALTER TABLE `u2f_registration` ALTER COLUMN `counter` BIGINT") + } + + if err != nil { + return fmt.Errorf("Error changing u2f_registration counter column type: %v", err) + } + + return nil +} |