File tree Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ import (
20
20
type GPGKey struct {
21
21
ID int64 `xorm:"pk autoincr"`
22
22
OwnerID int64 `xorm:"INDEX NOT NULL"`
23
- KeyID string `xorm:"INDEX TEXT NOT NULL"`
24
- PrimaryKeyID string `xorm:"TEXT "`
23
+ KeyID string `xorm:"INDEX CHAR(16) NOT NULL"`
24
+ PrimaryKeyID string `xorm:"CHAR(16) "`
25
25
Content string `xorm:"TEXT NOT NULL"`
26
26
Created time.Time `xorm:"-"`
27
27
CreatedUnix int64
Original file line number Diff line number Diff line change @@ -96,6 +96,8 @@ var migrations = []Migration{
96
96
NewMigration ("generate and migrate wiki Git hooks" , generateAndMigrateWikiGitHooks ),
97
97
// v23 -> v24
98
98
NewMigration ("add user openid table" , addUserOpenID ),
99
+ // v24 -> v25
100
+ NewMigration ("change the key_id and primary_key_id type" , changeGPGKeysColumns ),
99
101
}
100
102
101
103
// Migrate database to current version
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Gitea Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package migrations
6
+
7
+ import (
8
+ "time"
9
+
10
+ "github.com/go-xorm/xorm"
11
+ )
12
+
13
+ func changeGPGKeysColumns (x * xorm.Engine ) error {
14
+ // EmailAddress is the list of all email addresses of a user. Can contain the
15
+ // primary email address, but is not obligatory.
16
+ type EmailAddress struct {
17
+ ID int64 `xorm:"pk autoincr"`
18
+ UID int64 `xorm:"INDEX NOT NULL"`
19
+ Email string `xorm:"UNIQUE NOT NULL"`
20
+ IsActivated bool
21
+ IsPrimary bool `xorm:"-"`
22
+ }
23
+
24
+ // GPGKey represents a GPG key.
25
+ type GPGKey struct {
26
+ ID int64 `xorm:"pk autoincr"`
27
+ OwnerID int64 `xorm:"INDEX NOT NULL"`
28
+ KeyID string `xorm:"INDEX CHAR(16) NOT NULL"`
29
+ PrimaryKeyID string `xorm:"CHAR(16)"`
30
+ Content string `xorm:"TEXT NOT NULL"`
31
+ Created time.Time `xorm:"-"`
32
+ CreatedUnix int64
33
+ Expired time.Time `xorm:"-"`
34
+ ExpiredUnix int64
35
+ Added time.Time `xorm:"-"`
36
+ AddedUnix int64
37
+ SubsKey []* GPGKey `xorm:"-"`
38
+ Emails []* EmailAddress
39
+ CanSign bool
40
+ CanEncryptComms bool
41
+ CanEncryptStorage bool
42
+ CanCertify bool
43
+ }
44
+
45
+ if err := x .DropTables (new (GPGKey )); err != nil {
46
+ return err
47
+ }
48
+
49
+ return x .Sync (new (GPGKey ))
50
+ }
You can’t perform that action at this time.
0 commit comments