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 <nicola.murino@gmail.com>
  • Loading branch information
drakkan committed Dec 31, 2024
1 parent 484bda7 commit 37f8fb3
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 @@ -3181,7 +3181,7 @@ func (p *BoltProvider) migrateDatabase() error {
providerLog(logger.LevelDebug, "bolt database is up to date, current version: %d", version)
return ErrNoInitRequired
case version < 29:
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 @@ -4688,6 +4688,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 @@ -798,7 +798,7 @@ func (p *MySQLProvider) migrateDatabase() error {
providerLog(logger.LevelDebug, "sql database is up to date, current version: %d", version)
return ErrNoInitRequired
case version < 29:
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 @@ -822,7 +822,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 < 29:
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 @@ -718,7 +718,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 < 29:
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 37f8fb3

Please sign in to comment.