aboutsummaryrefslogtreecommitdiffstats
path: root/models/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'models/migrations')
-rw-r--r--models/migrations/v1_18/v227.go42
1 files changed, 1 insertions, 41 deletions
diff --git a/models/migrations/v1_18/v227.go b/models/migrations/v1_18/v227.go
index 78c80f74ec..5fe5dcd0c9 100644
--- a/models/migrations/v1_18/v227.go
+++ b/models/migrations/v1_18/v227.go
@@ -4,10 +4,6 @@
package v1_18 //nolint
import (
- "fmt"
- "strconv"
-
- "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"xorm.io/xorm"
@@ -22,42 +18,6 @@ type SystemSetting struct {
Updated timeutil.TimeStamp `xorm:"updated"`
}
-func insertSettingsIfNotExist(x *xorm.Engine, sysSettings []*SystemSetting) error {
- sess := x.NewSession()
- defer sess.Close()
- if err := sess.Begin(); err != nil {
- return err
- }
- for _, setting := range sysSettings {
- exist, err := sess.Table("system_setting").Where("setting_key=?", setting.SettingKey).Exist()
- if err != nil {
- return err
- }
- if !exist {
- if _, err := sess.Insert(setting); err != nil {
- return err
- }
- }
- }
- return sess.Commit()
-}
-
func CreateSystemSettingsTable(x *xorm.Engine) error {
- if err := x.Sync(new(SystemSetting)); err != nil {
- return fmt.Errorf("sync2: %w", err)
- }
-
- // migrate xx to database
- sysSettings := []*SystemSetting{
- {
- SettingKey: "picture.disable_gravatar",
- SettingValue: strconv.FormatBool(setting.DisableGravatar),
- },
- {
- SettingKey: "picture.enable_federated_avatar",
- SettingValue: strconv.FormatBool(setting.EnableFederatedAvatar),
- },
- }
-
- return insertSettingsIfNotExist(x, sysSettings)
+ return x.Sync(new(SystemSetting))
}