mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
Better hint to user if database import didnt finish
This commit is contained in:
@@ -92,7 +92,7 @@ but executes against the code in the source tree. For example:
|
|||||||
```
|
```
|
||||||
me@machine:~$ cd Nominatim
|
me@machine:~$ cd Nominatim
|
||||||
me@machine:~Nominatim$ ./nominatim-cli.py --version
|
me@machine:~Nominatim$ ./nominatim-cli.py --version
|
||||||
Nominatim version 4.4.99-1
|
Nominatim version 5.1.0-0
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure you have activated the virtual environment holding all
|
Make sure you have activated the virtual environment holding all
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2024 by the Nominatim developer community.
|
# Copyright (C) 2025 by the Nominatim developer community.
|
||||||
# For a full list of authors see the git log.
|
# For a full list of authors see the git log.
|
||||||
"""
|
"""
|
||||||
Collection of functions that check if the database is complete and functional.
|
Collection of functions that check if the database is complete and functional.
|
||||||
@@ -163,12 +163,8 @@ def check_connection(conn: Any, config: Configuration) -> CheckResult:
|
|||||||
Database version ({db_version}) doesn't match Nominatim version ({nom_version})
|
Database version ({db_version}) doesn't match Nominatim version ({nom_version})
|
||||||
|
|
||||||
Hints:
|
Hints:
|
||||||
* Are you connecting to the correct database?
|
|
||||||
|
|
||||||
{instruction}
|
{instruction}
|
||||||
|
|
||||||
Check the Migration chapter of the Administration Guide.
|
|
||||||
|
|
||||||
Project directory: {config.project_dir}
|
Project directory: {config.project_dir}
|
||||||
Current setting of NOMINATIM_DATABASE_DSN: {config.DATABASE_DSN}
|
Current setting of NOMINATIM_DATABASE_DSN: {config.DATABASE_DSN}
|
||||||
""")
|
""")
|
||||||
@@ -176,24 +172,25 @@ def check_database_version(conn: Connection, config: Configuration) -> CheckResu
|
|||||||
""" Checking database_version matches Nominatim software version
|
""" Checking database_version matches Nominatim software version
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if table_exists(conn, 'nominatim_properties'):
|
db_version_str = None
|
||||||
|
if not table_exists(conn, 'nominatim_properties'):
|
||||||
|
instruction = 'Are you connecting to the correct database?'
|
||||||
|
else:
|
||||||
db_version_str = properties.get_property(conn, 'database_version')
|
db_version_str = properties.get_property(conn, 'database_version')
|
||||||
else:
|
|
||||||
db_version_str = None
|
|
||||||
|
|
||||||
if db_version_str is not None:
|
if db_version_str is None:
|
||||||
db_version = parse_version(db_version_str)
|
instruction = 'Database version not found. Did the import finish?'
|
||||||
|
else:
|
||||||
|
db_version = parse_version(db_version_str)
|
||||||
|
|
||||||
if db_version == NOMINATIM_VERSION:
|
if db_version == NOMINATIM_VERSION:
|
||||||
return CheckState.OK
|
return CheckState.OK
|
||||||
|
|
||||||
instruction = (
|
instruction = (
|
||||||
'Run migrations: nominatim admin --migrate'
|
"Run migrations: 'nominatim admin --migrate'"
|
||||||
if db_version < NOMINATIM_VERSION
|
if db_version < NOMINATIM_VERSION
|
||||||
else 'You need to upgrade the Nominatim software.'
|
else 'You need to upgrade the Nominatim software.'
|
||||||
)
|
) + ' Check the Migration chapter of the Administration Guide.'
|
||||||
else:
|
|
||||||
instruction = ''
|
|
||||||
|
|
||||||
return CheckState.FATAL, dict(db_version=db_version_str,
|
return CheckState.FATAL, dict(db_version=db_version_str,
|
||||||
nom_version=NOMINATIM_VERSION,
|
nom_version=NOMINATIM_VERSION,
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ def test_check_connection_bad(def_config):
|
|||||||
assert chkdb.check_connection(badconn, def_config) == chkdb.CheckState.FATAL
|
assert chkdb.check_connection(badconn, def_config) == chkdb.CheckState.FATAL
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_database_version_not_found(property_table, temp_db_conn, def_config):
|
||||||
|
assert chkdb.check_database_version(temp_db_conn, def_config) == chkdb.CheckState.FATAL
|
||||||
|
|
||||||
|
|
||||||
def test_check_database_version_good(property_table, temp_db_conn, def_config):
|
def test_check_database_version_good(property_table, temp_db_conn, def_config):
|
||||||
property_table.set('database_version',
|
property_table.set('database_version',
|
||||||
str(nominatim_db.version.NOMINATIM_VERSION))
|
str(nominatim_db.version.NOMINATIM_VERSION))
|
||||||
|
|||||||
Reference in New Issue
Block a user