aboutsummaryrefslogtreecommitdiffstats
path: root/models/migrations
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-03-17 22:24:51 +0800
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-03-20 02:55:07 +0100
commit608cd54a685a2de0f7ba2888f36d86307bd5b310 (patch)
tree1be964618dbd19d9206955ccb4e92bb2c782a06d /models/migrations
parent430cc4f42ae0a1186de30b8eae2f1660af6fea35 (diff)
downloadgitea-608cd54a685a2de0f7ba2888f36d86307bd5b310.tar.gz
gitea-608cd54a685a2de0f7ba2888f36d86307bd5b310.zip
fix gpg wrong column types
Diffstat (limited to 'models/migrations')
-rw-r--r--models/migrations/migrations.go2
-rw-r--r--models/migrations/v24.go50
2 files changed, 52 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index 4f1254b960..d06a4473b8 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -96,6 +96,8 @@ var migrations = []Migration{
NewMigration("generate and migrate wiki Git hooks", generateAndMigrateWikiGitHooks),
// v23 -> v24
NewMigration("add user openid table", addUserOpenID),
+ // v24 -> v25
+ NewMigration("change the key_id and primary_key_id type", changeGPGKeysColumns),
}
// Migrate database to current version
diff --git a/models/migrations/v24.go b/models/migrations/v24.go
new file mode 100644
index 0000000000..076c710cc3
--- /dev/null
+++ b/models/migrations/v24.go
@@ -0,0 +1,50 @@
+// Copyright 2017 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 (
+ "time"
+
+ "github.com/go-xorm/xorm"
+)
+
+func changeGPGKeysColumns(x *xorm.Engine) error {
+ // EmailAddress is the list of all email addresses of a user. Can contain the
+ // primary email address, but is not obligatory.
+ type EmailAddress struct {
+ ID int64 `xorm:"pk autoincr"`
+ UID int64 `xorm:"INDEX NOT NULL"`
+ Email string `xorm:"UNIQUE NOT NULL"`
+ IsActivated bool
+ IsPrimary bool `xorm:"-"`
+ }
+
+ // GPGKey represents a GPG key.
+ type GPGKey struct {
+ ID int64 `xorm:"pk autoincr"`
+ OwnerID int64 `xorm:"INDEX NOT NULL"`
+ KeyID string `xorm:"INDEX CHAR(16) NOT NULL"`
+ PrimaryKeyID string `xorm:"CHAR(16)"`
+ Content string `xorm:"TEXT NOT NULL"`
+ Created time.Time `xorm:"-"`
+ CreatedUnix int64
+ Expired time.Time `xorm:"-"`
+ ExpiredUnix int64
+ Added time.Time `xorm:"-"`
+ AddedUnix int64
+ SubsKey []*GPGKey `xorm:"-"`
+ Emails []*EmailAddress
+ CanSign bool
+ CanEncryptComms bool
+ CanEncryptStorage bool
+ CanCertify bool
+ }
+
+ if err := x.DropTables(new(GPGKey)); err != nil {
+ return err
+ }
+
+ return x.Sync(new(GPGKey))
+}