]> git.openstreetmap.org Git - nominatim.git/commitdiff
Added version check for PostGis and Postgres
authorRobbe Haesendonck <googleit@inuits.eu>
Wed, 20 Sep 2023 14:05:12 +0000 (16:05 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 7 Dec 2023 08:04:33 +0000 (09:04 +0100)
nominatim/clicmd/setup.py
nominatim/tools/database_import.py

index 5114db83664c47604dc2a8a6d621038d1c298e18..d93a118fa987d75828d00917c790ccf35b23b869 100644 (file)
@@ -99,6 +99,8 @@ class SetupAll:
                     return 0
                 
             if not args.prepare_database or args.no_superuser or complete_import:
+                # Check if the correct plugins are installed
+                database_import.check_existing_database_plugins(args.config.get_libpq_dsn())
                 LOG.warning('Setting up country tables')
                 country_info.setup_country_tables(args.config.get_libpq_dsn(),
                                                 args.config.lib_dir.data,
index cb620d41fb8f31126fe69a622bf14130e38494d1..7251329c48976b3adc3e266689aa7040e708187c 100644 (file)
@@ -38,6 +38,16 @@ def _require_version(module: str, actual: Tuple[int, int], expected: Tuple[int,
         raise UsageError(f'{module} is too old.')
 
 
+def check_existing_database_plugins(dsn: str):
+    with connect(dsn) as conn:
+        _require_version('PostgreSQL server',
+                         conn.server_version_tuple(),
+                         POSTGRESQL_REQUIRED_VERSION)
+        _require_version('PostGIS',
+                         conn.postgis_version_tuple(),
+                         POSTGIS_REQUIRED_VERSION)
+
+
 def setup_database_skeleton(dsn: str, rouser: Optional[str] = None) -> None:
     """ Create a new database for Nominatim and populate it with the
         essential extensions.