fix(migrations): add migration error log

This commit is contained in:
LinkinStars 2023-06-06 10:04:03 +08:00
parent bb5daf8003
commit 432bf21c98
2 changed files with 16 additions and 9 deletions

View File

@ -69,7 +69,7 @@ var migrations = []Migration{
NewMigration("v1.0.9", "add login limitations", addLoginLimitations, true),
NewMigration("v1.1.0-beta.1", "update user pin hide features", updateRolePinAndHideFeatures, true),
NewMigration("v1.1.0-beta.2", "update question post time", updateQuestionPostTime, true),
NewMigration("v1.1.0", "add gravatar base url", updateCount, false),
NewMigration("v1.1.0", "add gravatar base url", updateCount, true),
}
// GetCurrentDBVersion returns the current db version

View File

@ -14,14 +14,21 @@ import (
)
func updateCount(x *xorm.Engine) error {
addPrivilegeForInviteSomeoneToAnswer(x)
addGravatarBaseURL(x)
updateQuestionCount(x)
updateTagCount(x)
updateUserQuestionCount(x)
updateUserAnswerCount(x)
inviteAnswer(x)
inBoxData(x)
fns := []func(*xorm.Engine) error{
addPrivilegeForInviteSomeoneToAnswer,
addGravatarBaseURL,
updateQuestionCount,
updateTagCount,
updateUserQuestionCount,
updateUserAnswerCount,
inviteAnswer,
inBoxData,
}
for _, fn := range fns {
if err := fn(x); err != nil {
return err
}
}
return nil
}