Skip to content

Commit f464ecb

Browse files
committed
Merge branch 'master' into guestupload
2 parents bd8385b + 638b29f commit f464ecb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/configuration/database/Database.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"net/url"
7+
"os"
78
"strings"
89

910
"github.com/forceu/gokapi/internal/configuration/database/dbabstraction"
@@ -100,10 +101,17 @@ func RunGarbageCollection() {
100101
db.RunGarbageCollection()
101102
}
102103

104+
var osExit = os.Exit
105+
103106
// Upgrade migrates the DB to a new Gokapi version, if required
104107
func Upgrade() {
105108
dbVersion := db.GetDbVersion()
106109
expectedVersion := db.GetSchemaVersion()
110+
if dbVersion > expectedVersion {
111+
fmt.Println("Error: Database is from a newer Gokapi version. Unable to continue.")
112+
osExit(1)
113+
return
114+
}
107115
if dbVersion < expectedVersion {
108116
db.Upgrade(dbVersion)
109117
db.SetDbVersion(expectedVersion)

0 commit comments

Comments
 (0)