Skip to content

Commit 3d08e3a

Browse files
authored
No longer show the db-downgrade SQL in production (#18654)
1 parent d4a075d commit 3d08e3a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ _testmain.go
3636
coverage.all
3737
cpu.out
3838

39+
/modules/migration/bindata.go
40+
/modules/migration/bindata.go.hash
3941
/modules/options/bindata.go
4042
/modules/options/bindata.go.hash
4143
/modules/public/bindata.go

models/migrations/migrations.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,12 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
450450

451451
// Downgrading Gitea's database version not supported
452452
if int(v-minDBVersion) > len(migrations) {
453-
msg := fmt.Sprintf("Downgrading database version from '%d' to '%d' is not supported and may result in loss of data integrity.\nIf you really know what you're doing, execute `UPDATE version SET version=%d WHERE id=1;`\n",
454-
v, minDBVersion+len(migrations), minDBVersion+len(migrations))
455-
fmt.Fprint(os.Stderr, msg)
453+
msg := fmt.Sprintf("Your database (migration version: %d) is for a newer Gita, you can not use the newer database for this old Gitea release (%d).", v, minDBVersion+len(migrations))
454+
msg += "\nGitea will exit to keep your database safe and unchanged. Please use the correct Gitea release, do not change the migration version manually (incorrect manual operation may lose data)."
455+
if !setting.IsProd {
456+
msg += fmt.Sprintf("\nIf you are in development and really know what you're doing, you can force changing the migration version by executing: UPDATE version SET version=%d WHERE id=1;", minDBVersion+len(migrations))
457+
}
458+
_, _ = fmt.Fprintln(os.Stderr, msg)
456459
log.Fatal(msg)
457460
return nil
458461
}

0 commit comments

Comments
 (0)