diff options
author | techknowlogick <techknowlogick@gitea.io> | 2021-11-22 04:47:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 04:47:23 -0500 |
commit | 499b05da222deff73666f877964d5a92f0f16ac7 (patch) | |
tree | b5920b204e9638609e9b7793f1e2258338c88637 /models/migrations | |
parent | a159c3175f5f60a9de00f4d3c73787ffa6c63ddd (diff) | |
download | gitea-499b05da222deff73666f877964d5a92f0f16ac7.tar.gz gitea-499b05da222deff73666f877964d5a92f0f16ac7.zip |
Add user settings key/value DB table (#16834)
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v202.go | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index c0d8f111d3..6b7caba897 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -357,6 +357,8 @@ var migrations = []Migration{ NewMigration("Add table app_state", addTableAppState), // v201 -> v202 NewMigration("Drop table remote_version (if exists)", dropTableRemoteVersion), + // v202 -> v203 + NewMigration("Create key/value table for user settings", createUserSettingsTable), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v202.go b/models/migrations/v202.go new file mode 100644 index 0000000000..3e023543e4 --- /dev/null +++ b/models/migrations/v202.go @@ -0,0 +1,25 @@ +// Copyright 2021 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" + + "xorm.io/xorm" +) + +func createUserSettingsTable(x *xorm.Engine) error { + type UserSetting struct { + ID int64 `xorm:"pk autoincr"` + UserID int64 `xorm:"index unique(key_userid)"` // to load all of someone's settings + SettingKey string `xorm:"varchar(255) index unique(key_userid)"` // ensure key is always lowercase + SettingValue string `xorm:"text"` + } + if err := x.Sync2(new(UserSetting)); err != nil { + return fmt.Errorf("sync2: %v", err) + } + return nil + +} |