Improve diagnostics on database upgrade failure (#6570)

`Failed to upgrade database` is not helpful, and it's unlikely that UPGRADE.rst
has anything useful.
This commit is contained in:
Richard van der Hoff 2019-12-19 14:53:15 +00:00 committed by GitHub
parent 0b794cbd7b
commit bca30cefee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 8 deletions

1
changelog.d/6570.misc Normal file
View file

@ -0,0 +1 @@
Improve diagnostics on database upgrade failure.

View file

@ -342,13 +342,8 @@ def setup(config_options):
hs.setup() hs.setup()
except IncorrectDatabaseSetup as e: except IncorrectDatabaseSetup as e:
quit_with_error(str(e)) quit_with_error(str(e))
except UpgradeDatabaseException: except UpgradeDatabaseException as e:
sys.stderr.write( quit_with_error("Failed to upgrade database: %s" % (e,))
"\nFailed to upgrade database.\n"
"Have you checked for version specific instructions in"
" UPGRADES.rst?\n"
)
sys.exit(1)
hs.setup_master() hs.setup_master()

View file

@ -69,7 +69,10 @@ def prepare_database(db_conn, database_engine, config, data_stores=["main"]):
if user_version != SCHEMA_VERSION: if user_version != SCHEMA_VERSION:
# If we don't pass in a config file then we are expecting to # If we don't pass in a config file then we are expecting to
# have already upgraded the DB. # have already upgraded the DB.
raise UpgradeDatabaseException("Database needs to be upgraded") raise UpgradeDatabaseException(
"Expected database schema version %i but got %i"
% (SCHEMA_VERSION, user_version)
)
else: else:
_upgrade_existing_database( _upgrade_existing_database(
cur, cur,