Fix --ignore-unsupported-database flag

This commit is contained in:
Tulir Asokan 2020-11-02 16:16:36 +02:00
parent 63933d0c7e
commit 0c60516702

View file

@ -222,10 +222,10 @@ func (bridge *Bridge) Init() {
} }
bridge.AS.Log = log.Sub("Matrix") bridge.AS.Log = log.Sub("Matrix")
bridge.Log.Debugln("Initializing database") bridge.Log.Debugln("Initializing database connection")
bridge.DB, err = database.New(bridge.Config.AppService.Database.Type, bridge.Config.AppService.Database.URI) bridge.DB, err = database.New(bridge.Config.AppService.Database.Type, bridge.Config.AppService.Database.URI)
if err != nil && (err != upgrades.UnsupportedDatabaseVersion || !*ignoreUnsupportedDatabase) { if err != nil {
bridge.Log.Fatalln("Failed to initialize database:", err) bridge.Log.Fatalln("Failed to initialize database connection:", err)
os.Exit(14) os.Exit(14)
} }
@ -260,8 +260,9 @@ func (bridge *Bridge) Init() {
} }
func (bridge *Bridge) Start() { func (bridge *Bridge) Start() {
bridge.Log.Debugln("Running database upgrades")
err := bridge.DB.Init() err := bridge.DB.Init()
if err != nil { if err != nil && (err != upgrades.UnsupportedDatabaseVersion || !*ignoreUnsupportedDatabase) {
bridge.Log.Fatalln("Failed to initialize database:", err) bridge.Log.Fatalln("Failed to initialize database:", err)
os.Exit(15) os.Exit(15)
} }