summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-03-19 03:23:58 +0000
committerGitHub <noreply@github.com>2021-03-19 04:23:58 +0100
commit909f2be99d0c699f506f463bb6238378f12c0dc1 (patch)
treeb73bb5a00613e4328e7421b827c8d34622dec171 /cmd
parent645c0d8abd530e2725b6c6db0d3f3e28c807a829 (diff)
downloadgitea-909f2be99d0c699f506f463bb6238378f12c0dc1.tar.gz
gitea-909f2be99d0c699f506f463bb6238378f12c0dc1.zip
Fix postgres ID sequences broken by recreate-table (#15015) (#15029)
Backport #15015 Unfortunately there is a subtle problem with recreatetable on postgres which leads to the sequences not being renamed and not being left at 0. Fix #14725 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/doctor.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/cmd/doctor.go b/cmd/doctor.go
index 2ca2bb5e70..5ba0451110 100644
--- a/cmd/doctor.go
+++ b/cmd/doctor.go
@@ -670,6 +670,23 @@ func runDoctorCheckDBConsistency(ctx *cli.Context) ([]string, error) {
}
}
+ if setting.Database.UsePostgreSQL {
+ count, err = models.CountBadSequences()
+ if err != nil {
+ return nil, err
+ }
+ if count > 0 {
+ if ctx.Bool("fix") {
+ err := models.FixBadSequences()
+ if err != nil {
+ return nil, err
+ }
+ results = append(results, fmt.Sprintf("%d sequences updated", count))
+ } else {
+ results = append(results, fmt.Sprintf("%d sequences with incorrect values", count))
+ }
+ }
+ }
//ToDo: function to recalc all counters
return results, nil