A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix(migrations): add question rank default level
LinkinStar0fa30bbbaac2
diff --git a/internal/migrations/v4.go b/internal/migrations/v4.goindex 33bec96a..e41d20fe 100644--- a/internal/migrations/v4.go+++ b/internal/migrations/v4.go@@ -1,8 +1,11 @@package migrationsimport (+ "fmt"+"github.com/answerdev/answer/internal/entity""github.com/answerdev/answer/internal/service/permission"+ "github.com/segmentfault/pacman/log""xorm.io/xorm")@@ -183,5 +186,27 @@ func addRoleFeatures(x *xorm.Engine) error {return err}}++ defaultConfigTable := []*entity.Config{+ {ID: 115, Key: "rank.question.close", Value: `-1`},+ {ID: 116, Key: "rank.question.reopen", Value: `-1`},+ }+ for _, c := range defaultConfigTable {+ exist, err := x.Get(&entity.Config{ID: c.ID, Key: c.Key})+ if err != nil {+ return fmt.Errorf("get config failed: %w", err)+ }+ if exist {+ if _, err = x.Update(c, &entity.Config{ID: c.ID, Key: c.Key}); err != nil {+ log.Errorf("update %+v config failed: %s", c, err)+ return fmt.Errorf("update config failed: %w", err)+ }+ continue+ }+ if _, err = x.Insert(&entity.Config{ID: c.ID, Key: c.Key, Value: c.Value}); err != nil {+ log.Errorf("insert %+v config failed: %s", c, err)+ return fmt.Errorf("add config failed: %w", err)+ }+ }return nil}