Skip to content

Commit

Permalink
add a link to the upgrading docs in the error message
Browse files Browse the repository at this point in the history
Fixes #1854

Signed-off-by: Nicola Murino <[email protected]>
  • Loading branch information
drakkan committed Dec 31, 2024
1 parent 497c700 commit a0f781a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/dataprovider/bolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3135,7 +3135,7 @@ func (p *BoltProvider) migrateDatabase() error {
providerLog(logger.LevelDebug, "bolt database is up to date, current version: %d", version)
return ErrNoInitRequired
case version < 28:
err = fmt.Errorf("database schema version %d is too old, please see the upgrading docs", version)
err = errSchemaVersionTooOld(version)
providerLog(logger.LevelError, "%v", err)
logger.ErrorToConsole("%v", err)
return err
Expand Down
4 changes: 4 additions & 0 deletions internal/dataprovider/dataprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4631,6 +4631,10 @@ func checkReservedUsernames(username string) error {
return nil
}

func errSchemaVersionTooOld(version int) error {
return fmt.Errorf("database schema version %d is too old, please see the upgrading docs: https://docs.sftpgo.com/latest/data-provider/#upgrading", version)
}

func providerLog(level logger.LogLevel, format string, v ...any) {
logger.Log(level, logSender, "", format, v...)
}
2 changes: 1 addition & 1 deletion internal/dataprovider/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ func (p *MySQLProvider) migrateDatabase() error {
providerLog(logger.LevelDebug, "sql database is up to date, current version: %d", version)
return ErrNoInitRequired
case version < 28:
err = fmt.Errorf("database schema version %d is too old, please see the upgrading docs", version)
err = errSchemaVersionTooOld(version)
providerLog(logger.LevelError, "%v", err)
logger.ErrorToConsole("%v", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/dataprovider/pgsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ func (p *PGSQLProvider) migrateDatabase() error { //nolint:dupl
providerLog(logger.LevelDebug, "sql database is up to date, current version: %d", version)
return ErrNoInitRequired
case version < 28:
err = fmt.Errorf("database schema version %d is too old, please see the upgrading docs", version)
err = errSchemaVersionTooOld(version)
providerLog(logger.LevelError, "%v", err)
logger.ErrorToConsole("%v", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/dataprovider/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ func (p *SQLiteProvider) migrateDatabase() error { //nolint:dupl
providerLog(logger.LevelDebug, "sql database is up to date, current version: %d", version)
return ErrNoInitRequired
case version < 28:
err = fmt.Errorf("database schema version %d is too old, please see the upgrading docs", version)
err = errSchemaVersionTooOld(version)
providerLog(logger.LevelError, "%v", err)
logger.ErrorToConsole("%v", err)
return err
Expand Down

0 comments on commit a0f781a

Please sign in to comment.