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.

feat: upgrade update migration config

LinkinStar4e1da6acec2b
diff --git a/internal/migrations/v3.go b/internal/migrations/v3.go
index d61de936..47dce2f2 100644
--- a/internal/migrations/v3.go
+++ b/internal/migrations/v3.go
@@ -30,9 +30,17 @@ func addActivityTimeline(x *xorm.Engine) error {
{ID: 105, Key: "tag.deleted", Value: `0`},
{ID: 106, Key: "tag.undeleted", Value: `0`},
}
- _, err := x.Insert(defaultConfigTable)
- if err != nil {
- return err
+ for _, c := range defaultConfigTable {
+ exist, err := x.Get(&entity.Config{ID: c.ID, Key: c.Key})
+ if err != nil {
+ return err
+ }
+ if exist {
+ continue
+ }
+ if _, err := x.Insert(&entity.Config{ID: c.ID, Key: c.Key, Value: c.Value}); err != nil {
+ return err
+ }
}
type Revision struct {