From 72625dc72a628d843d7a3ebc0c813689408b4cf8 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 2 Jun 2021 11:08:48 +0200 Subject: [PATCH] call freeze after running and non-updateable import Some of the tables will have already been removed but the tables for indexing are still there and should be dropped. --- nominatim/clicmd/setup.py | 8 +++++--- nominatim/db/status.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/nominatim/clicmd/setup.py b/nominatim/clicmd/setup.py index 3f590686..878c8826 100644 --- a/nominatim/clicmd/setup.py +++ b/nominatim/clicmd/setup.py @@ -52,10 +52,8 @@ class SetupAll: @staticmethod def run(args): # pylint: disable=too-many-statements - from ..tools import database_import - from ..tools import refresh + from ..tools import database_import, refresh, postcodes, freeze from ..indexer.indexer import Indexer - from ..tools import postcodes from ..tokenizer import factory as tokenizer_factory if args.osm_file and not Path(args.osm_file).is_file(): @@ -135,8 +133,12 @@ class SetupAll: LOG.warning('Create search index for default country names.') database_import.create_country_names(conn, tokenizer, args.config.LANGUAGES) + conn.commit() + if args.no_updates: + freeze.drop_update_tables(conn) tokenizer.finalize_import(args.config) + webdir = args.project_dir / 'website' LOG.warning('Setup website at %s', webdir) with connect(args.config.get_libpq_dsn()) as conn: diff --git a/nominatim/db/status.py b/nominatim/db/status.py index c2ff63db..71e58787 100644 --- a/nominatim/db/status.py +++ b/nominatim/db/status.py @@ -17,7 +17,10 @@ def compute_database_date(conn): """ # First, find the node with the highest ID in the database with conn.cursor() as cur: - osmid = cur.scalar("SELECT max(osm_id) FROM place WHERE osm_type='N'") + if conn.table_exists('place'): + osmid = cur.scalar("SELECT max(osm_id) FROM place WHERE osm_type='N'") + else: + osmid = cur.scalar("SELECT max(osm_id) FROM placex WHERE osm_type='N'") if osmid is None: LOG.fatal("No data found in the database.") -- 2.39.5