diff --git a/models/migrations/v68.go b/models/migrations/v68.go index e76e5a5bd..560d25162 100644 --- a/models/migrations/v68.go +++ b/models/migrations/v68.go @@ -60,7 +60,7 @@ func reformatAndRemoveIncorrectTopics(x *xorm.Engine) (err error) { if models.ValidateTopic(topic.Name) { unifiedTopic := Topic{Name:topic.Name} exists, err := sess.Get(&unifiedTopic) - log.Info("Exists topic with the name %q? %v id = %v", topic.Name, exists, unifiedTopic.ID) + log.Info("Exists topic with the name %q? %v, id = %v", topic.Name, exists, unifiedTopic.ID) if err != nil { return err } @@ -72,6 +72,12 @@ func reformatAndRemoveIncorrectTopics(x *xorm.Engine) (err error) { topic.ID, topic.ID, unifiedTopic.ID).Update(&models.RepoTopic{TopicID:unifiedTopic.ID}); err != nil { return err } + log.Info("Updating topic `repo_count` field") + if _, err := sess.Exec( + "UPDATE topic SET repo_count = (SELECT COUNT(*) FROM repo_topic WHERE topic_id = ? GROUP BY topic_id) WHERE id = ?", + unifiedTopic.ID, unifiedTopic.ID); err != nil { + return err + } } else { log.Info("Updating topic: id = %v, name = %q", topic.ID, topic.Name) if _, err := sess.Table("topic").ID(topic.ID).