summaryrefslogtreecommitdiffstats
path: root/modules/doctor
diff options
context:
space:
mode:
Diffstat (limited to 'modules/doctor')
-rw-r--r--modules/doctor/dbconsistency.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/doctor/dbconsistency.go b/modules/doctor/dbconsistency.go
index 942a45cb30..1e3c7258e3 100644
--- a/modules/doctor/dbconsistency.go
+++ b/modules/doctor/dbconsistency.go
@@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/migrations"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
)
func checkDBConsistency(logger log.Logger, autofix bool) error {
@@ -131,6 +132,25 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
}
// TODO: function to recalc all counters
+ if setting.Database.UsePostgreSQL {
+ count, err = models.CountBadSequences()
+ if err != nil {
+ logger.Critical("Error: %v whilst checking sequence values")
+ }
+ if count > 0 {
+ if autofix {
+ err := models.FixBadSequences()
+ if err != nil {
+ logger.Critical("Error: %v whilst attempting to fix sequences")
+ return err
+ }
+ logger.Info("%d sequences updated", count)
+ } else {
+ logger.Warn("%d sequences with incorrect values", count)
+ }
+ }
+ }
+
return nil
}