Skip to content

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(rank): update answer accept rank config

LinkinStars51ac1e6b76ae
diff --git a/internal/migrations/init.go b/internal/migrations/init.go
index 1d0c5a25..93bd0eec 100644
--- a/internal/migrations/init.go
+++ b/internal/migrations/init.go
@@ -270,7 +270,7 @@ func initConfigTable(engine *xorm.Engine) error {
{ID: 41, Key: "rank.answer.add", Value: `1`},
{ID: 42, Key: "rank.answer.edit", Value: `200`},
{ID: 43, Key: "rank.answer.delete", Value: `-1`},
- {ID: 44, Key: "rank.answer.accept", Value: `1`},
+ {ID: 44, Key: "rank.answer.accept", Value: `-1`},
{ID: 45, Key: "rank.answer.vote_up", Value: `15`},
{ID: 46, Key: "rank.answer.vote_down", Value: `125`},
{ID: 47, Key: "rank.comment.add", Value: `1`},
diff --git a/internal/migrations/migrations.go b/internal/migrations/migrations.go
index 00ae9bc0..787c72f4 100644
--- a/internal/migrations/migrations.go
+++ b/internal/migrations/migrations.go
@@ -57,6 +57,7 @@ var migrations = []Migration{
NewMigration("add theme and private mode", addThemeAndPrivateMode, true),
NewMigration("add new answer notification", addNewAnswerNotification, true),
NewMigration("add user pin hide features", addRolePinAndHideFeatures, true),
+ NewMigration("update accept answer rank", updateAcceptAnswerRank, true),
}
// GetCurrentDBVersion returns the current db version
diff --git a/internal/migrations/v3.go b/internal/migrations/v3.go
index 076a72b5..2d9b28eb 100644
--- a/internal/migrations/v3.go
+++ b/internal/migrations/v3.go
@@ -110,7 +110,7 @@ ON "question" (
{ID: 41, Key: "rank.answer.add", Value: `1`},
{ID: 42, Key: "rank.answer.edit", Value: `200`},
{ID: 43, Key: "rank.answer.delete", Value: `-1`},
- {ID: 44, Key: "rank.answer.accept", Value: `1`},
+ {ID: 44, Key: "rank.answer.accept", Value: `-1`},
{ID: 45, Key: "rank.answer.vote_up", Value: `15`},
{ID: 46, Key: "rank.answer.vote_down", Value: `125`},
{ID: 47, Key: "rank.comment.add", Value: `1`},
diff --git a/internal/migrations/v9.go b/internal/migrations/v9.go
new file mode 100644
index 00000000..fadd1bc6
--- /dev/null
+++ b/internal/migrations/v9.go
@@ -0,0 +1,18 @@
+package migrations
+
+import (
+ "fmt"
+
+ "github.com/answerdev/answer/internal/entity"
+ "github.com/segmentfault/pacman/log"
+ "xorm.io/xorm"
+)
+
+func updateAcceptAnswerRank(x *xorm.Engine) error {
+ c := &entity.Config{ID: 44, Key: "rank.answer.accept", Value: `-1`}
+ if _, err := x.Update(c, &entity.Config{ID: 44, Key: "rank.answer.accept"}); err != nil {
+ log.Errorf("update %+v config failed: %s", c, err)
+ return fmt.Errorf("update config failed: %w", err)
+ }
+ return nil
+}