3 Nominatim offers automatic migrations for versions 4.3+. Please follow
6 * Stop any updates that are potentially running
7 * Update the backend: `pip install -U nominatim-db`
8 * Go to your project directory and run `nominatim admin --migrate`
9 * Update the frontend: `pip install -U nominatim-api`
10 * (optionally) Restart updates
12 Below you find additional migrations and hints about other structural and
13 breaking changes. **Please read them before running the migration.**
16 If you are migrating from a version <4.3, you need to install 4.3
17 and migrate to 4.3 first. Then you can migrate to the current
18 version. It is strongly recommended to do a reimport instead.
22 ### The place_classtype tables are not used anymore
24 Category search now runs against the `categories` column of `placex`, so the
25 per-category `place_classtype_*` tables are not created or updated anymore.
26 The migration leaves the existing tables in place because the old frontend
27 code still queries them until you have restarted it with the new version.
29 Once all your frontends run the new version, you can drop the tables to free
30 the disk space. On a planet database that is a couple of hundred tables and
31 several GB. To generate the necessary SQL, run:
34 SELECT format('DROP TABLE IF EXISTS %I;', tablename)
36 WHERE schemaname = 'public' AND tablename LIKE 'place\_classtype\_%';
39 The `--min` option of `nominatim special-phrases` only restricted which of
40 those tables were created. It has no effect anymore and is deprecated. It
41 will be removed in a future version.
45 #### Expensive table migrations
47 This version introduces new tables for postcodes, interpolations and
48 associatedStreet relations. Migration is possible but will take a bit
49 longer. It is recommended to take Nominatim offline while migrating to 5.3.
53 ### Lua import style: required extratags removed
55 Tags that are required by Nominatim as extratags are now always included
56 independent of what is defined in the style. The line
58 flex.add_for_extratags('required')
60 is no longer required in custom styles and will throw an error. Simply
61 remove the line from your style.
65 ### PHP frontend removed
67 The PHP frontend has been completely removed. Please switch to the Python
70 Without the PHP code, the `nominatim refresh --website` command is no longer
71 needed. It currently omits a warning and does otherwise nothing. It will be
72 removed in later versions of Nominatim. So make sure you remove it from your
75 ### CMake building removed
77 Nominatim can now only be installed via pip. Please follow the installation
78 instructions for the current version to change to pip.
80 ### osm2pgsql no longer vendored in
82 Nominatim no longer ships its own version of osm2pgsql. Please install a
83 stock version of osm2pgsql from your distribution. See the
84 [installation instruction for osm2pgsql](https://osm2pgsql.org/doc/install.html)
85 for details. A minimum version of 1.8 is required. The current stable versions
86 of Ubuntu and Debian already ship with an appropriate versions. For older
87 installations, you may have to compile a newer osm2pgsql yourself.
89 ### Legacy tokenizer removed
91 The `legacy` tokenizer is no longer enabled. This tokenizer has been superseded
92 by the `ICU` tokenizer a long time ago. In the unlikely case that your database
93 still uses the `legacy` tokenizer, you must reimport your database.
95 ### osm2pgsql style overhauled
97 There are some fundamental changes to how customized osm2pgsql styles should
98 be written. The changes are mostly backwards compatible, i.e. custom styles
99 should still work with the new implementation. The only exception is a
100 customization of the `process_tags()` function. This function is no longer
101 considered public and neither are the helper functions used in it.
102 They currently still work but will be removed at some point. If you have
103 been making changes to `process_tags`, please review your style and try
104 to switch to the new convenience functions.
106 For more information on the changes, see the
107 [pull request](https://github.com/osm-search/Nominatim/pull/3615)
109 [customization documentation](https://nominatim.org/release-docs/latest/customize/Import-Styles/).
113 ### New structure for Python packages
115 The nominatim Python package has been split into `nominatim-db` and `nominatim-api`.
116 Any imports need to be adapted accordingly.
118 If you are running the Python frontend, change the server module from
119 `nominatim.server.falcon.server` to `nominatim_api.server.falcon.server`.
121 If you are using the Nominatim library, all imports need to be changed
122 from `nominatim.api.<module>` to `nominatim_api.<module>`.
124 If you have written custom tokenizers or sanitizers, the appropriate modules
125 are now found in `nominatim_db`.
129 ### New indexes for reverse lookup
131 The reverse lookup algorithm has changed slightly to improve performance.
132 This change needs a different index in the database. The required index
133 will be automatically build during migration. Until the new index is available
134 performance of the /reverse endpoint is significantly reduced. You should
135 therefore either remove traffic from the machine before attempting a
136 version update or create the index manually **before** starting the update
137 using the following SQL:
140 CREATE INDEX IF NOT EXISTS idx_placex_geometry_reverse_lookupPlaceNode
141 ON placex USING gist (ST_Buffer(geometry, reverse_place_diameter(rank_search)))
142 WHERE rank_address between 4 and 25 AND type != 'postcode'
143 AND name is not null AND linked_place_id is null AND osm_type = 'N';
148 ### ICU tokenizer is the new default
150 Nominatim now installs the [ICU tokenizer](../customize/Tokenizers.md#icu-tokenizer)
151 by default. This only has an effect on newly installed databases. When
152 updating older databases, it keeps its installed tokenizer. If you still
153 run with the legacy tokenizer, make sure to compile Nominatim with the
154 PostgreSQL module, see [Installation](Installation.md#building-nominatim).
156 ### geocodejson output changed
158 The `type` field of the geocodejson output has changed. It now contains
159 the address class of the object instead of the value of the OSM tag. If
160 your client has used the `type` field, switch them to read `osm_value`
165 ### NOMINATIM_PHRASE_CONFIG removed
167 Custom blacklist configurations for special phrases now need to be handed
168 with the `--config` parameter to `nominatim special-phrases`. Alternatively
169 you can put your custom configuration in the project directory in a file
170 named `phrase-settings.json`.
172 Version 3.8 also removes the automatic converter for the php format of
173 the configuration in older versions. If you are updating from Nominatim < 3.7
174 and still work with a custom `phrase-settings.php`, you need to manually
175 convert it into a json format.
177 ### PHP utils removed
179 The old PHP utils have now been removed completely. You need to switch to
180 the appropriate functions of the nominatim command line tool. See
181 [Introducing `nominatim` command line tool](#introducing-nominatim-command-line-tool)
186 ### New format and name of configuration file
188 The configuration for an import is now saved in a `.env` file in the project
189 directory. This file follows the dotenv format. For more information, see
190 the [installation chapter](Import.md#configuration-setup-in-env).
192 To migrate to the new system, create a new project directory, add the `.env`
193 file and port your custom configuration from `settings/local.php`. Most
194 settings are named similar and only have received a `NOMINATIM_` prefix.
195 Use the default settings in `settings/env.defaults` as a reference.
197 ### New location for data files
199 External data files for Wikipedia importance, postcodes etc. are no longer
200 expected to reside in the source tree by default. Instead they will be searched
201 in the project directory. If you have an automated setup script you must
202 either adapt the download location or explicitly set the location of the
203 files to the old place in your `.env`.
205 ### Introducing `nominatim` command line tool
207 The various php utilities have been replaced with a single `nominatim`
208 command line tool. Make sure to adapt any scripts. There is no direct 1:1
209 matching between the old utilities and the commands of nominatim CLI. The
210 following list gives you a list of nominatim sub-commands that contain
211 functionality of each script:
213 * ./utils/setup.php: `import`, `freeze`, `refresh`
214 * ./utils/update.php: `replication`, `add-data`, `index`, `refresh`
215 * ./utils/specialphrases.php: `special-phrases`
216 * ./utils/check_import_finished.php: `admin`
217 * ./utils/warm.php: `admin`
218 * ./utils/export.php: `export`
220 Try `nominatim <command> --help` for more information about each subcommand.
222 `./utils/query.php` no longer exists in its old form. `nominatim search`
223 provides a replacement but returns different output.
225 ### Switch to normalized house numbers
227 The housenumber column in the placex table uses now normalized version.
228 The automatic migration step will convert the column but this may take a
229 very long time. It is advisable to take the machine offline while doing that.
233 ### Change of layout of search_name_* tables
235 The table need a different index for nearest place lookup. Recreate the
236 indexes using the following shell script:
239 for table in `psql -d nominatim -c "SELECT tablename FROM pg_tables WHERE tablename LIKE 'search_name_%'" -tA | grep -v search_name_blank`;
241 psql -d nominatim -c "DROP INDEX idx_${table}_centroid_place; CREATE INDEX idx_${table}_centroid_place ON ${table} USING gist (centroid) WHERE ((address_rank >= 2) AND (address_rank <= 25)); DROP INDEX idx_${table}_centroid_street; CREATE INDEX idx_${table}_centroid_street ON ${table} USING gist (centroid) WHERE ((address_rank >= 26) AND (address_rank <= 27))";
245 ### Removal of html output
247 The debugging UI is no longer directly provided with Nominatim. Instead we
248 now provide a simple Javascript application. Please refer to
249 [Setting up the Nominatim UI](Setup-Nominatim-UI.md) for details on how to
252 The icons served together with the API responses have been moved to the
253 nominatim-ui project as well. If you want to keep the `icon` field in the
254 response, you need to set `CONST_MapIcon_URL` to the URL of the `/mapicon`
255 directory of nominatim-ui.
257 ### Change order during indexing
259 When reindexing places during updates, there is now a different order used
260 which needs a different database index. Create it with the following SQL command:
263 CREATE INDEX idx_placex_pendingsector_rank_address
265 USING BTREE (rank_address, geometry_sector)
266 WHERE indexed_status > 0;
269 You can then drop the old index with:
272 DROP INDEX idx_placex_pendingsector;
277 This index has been unused ever since the query using it was changed two years ago. Saves about 12GB on a planet installation.
280 DROP INDEX idx_placex_geometry_reverse_lookupPoint;
283 ### Switching to dotenv
285 As part of the work changing the configuration format, the configuration for
286 the website is now using a separate configuration file. To create the
287 configuration file, run the following command after updating:
290 ./utils/setup.php --setup-website
295 To update the SQL code to the leatest version run:
298 ./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
303 ### New Wikipedia/Wikidata importance tables
305 The `wikipedia_*` tables have a new format that also includes references to
306 Wikidata. You need to update the computation functions and the tables as
309 * download the new Wikipedia tables as described in the import section
310 * reimport the tables: `./utils/setup.php --import-wikipedia-articles`
311 * update the functions: `./utils/setup.php --create-functions --enable-diff-updates`
312 * create a new lookup index:
314 CREATE INDEX idx_placex_wikidata
316 USING BTREE ((extratags -> 'wikidata'))
317 WHERE extratags ? 'wikidata'
320 AND rank_search < 26;
322 * compute importance: `./utils/update.php --recompute-importance`
324 The last step takes about 10 hours on the full planet.
326 Remove one function (it will be recreated in the next step):
329 DROP FUNCTION create_country(hstore,character varying);
332 Finally, update all SQL functions:
335 ./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
340 ### Reorganisation of location_area_country table
342 The table `location_area_country` has been optimized. You need to switch to the
343 new format when you run updates. While updates are disabled, run the following
347 CREATE TABLE location_area_country_new AS
348 SELECT place_id, country_code, geometry FROM location_area_country;
349 DROP TABLE location_area_country;
350 ALTER TABLE location_area_country_new RENAME TO location_area_country;
351 CREATE INDEX idx_location_area_country_geometry ON location_area_country USING GIST (geometry);
352 CREATE INDEX idx_location_area_country_place_id ON location_area_country USING BTREE (place_id);
355 Finally, update all SQL functions:
358 ./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
363 ### New database connection string (DSN) format
365 Previously database connection setting (`CONST_Database_DSN` in `settings/*.php`) had the format
367 * (simple) `pgsql://@/nominatim`
368 * (complex) `pgsql://johndoe:secret@machine1.domain.com:1234/db1`
372 * (simple) `pgsql:dbname=nominatim`
373 * (complex) `pgsql:dbname=db1;host=machine1.domain.com;port=1234;user=johndoe;password=secret`
375 ### Natural Earth country boundaries no longer needed as fallback
378 DROP TABLE country_naturalearthdata;
381 Finally, update all SQL functions:
384 ./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
387 ### Configurable Address Levels
389 The new configurable address levels require a new table. Create it with the
393 ./utils/update.php --update-address-levels
398 ### New reverse algorithm
400 The reverse algorithm has changed and requires new indexes. Run the following
401 SQL statements to create the indexes:
404 CREATE INDEX idx_placex_geometry_reverse_lookupPoint
406 USING gist (geometry)
407 WHERE (name IS NOT null or housenumber IS NOT null or rank_address BETWEEN 26 AND 27)
408 AND class NOT IN ('railway','tunnel','bridge','man_made')
409 AND rank_address >= 26
410 AND indexed_status = 0
411 AND linked_place_id IS null;
412 CREATE INDEX idx_placex_geometry_reverse_lookupPolygon
413 ON placex USING gist (geometry)
414 WHERE St_GeometryType(geometry) in ('ST_Polygon', 'ST_MultiPolygon')
415 AND rank_address between 4 and 25
416 AND type != 'postcode'
418 AND indexed_status = 0
419 AND linked_place_id is null;
420 CREATE INDEX idx_placex_geometry_reverse_placeNode
421 ON placex USING gist (geometry)
423 AND rank_search between 5 and 25
425 AND type != 'postcode'
427 AND indexed_status = 0
428 AND linked_place_id is null;
431 You also need to grant the website user access to the `country_osm_grid` table:
434 GRANT SELECT ON table country_osm_grid to "www-user";
437 Replace the `www-user` with the user name of your website server if necessary.
439 You can now drop the unused indexes:
442 DROP INDEX idx_placex_reverse_geometry;
445 Finally, update all SQL functions:
448 ./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
455 A new separate table for artificially computed postcode centroids was introduced.
456 Migration to the new format is possible but **not recommended**.
458 Create postcode table and indexes, running the following SQL statements:
461 CREATE TABLE location_postcode
462 (place_id BIGINT, parent_place_id BIGINT, rank_search SMALLINT,
463 rank_address SMALLINT, indexed_status SMALLINT, indexed_date TIMESTAMP,
464 country_code varchar(2), postcode TEXT,
465 geometry GEOMETRY(Geometry, 4326));
466 CREATE INDEX idx_postcode_geometry ON location_postcode USING GIST (geometry);
467 CREATE UNIQUE INDEX idx_postcode_id ON location_postcode USING BTREE (place_id);
468 CREATE INDEX idx_postcode_postcode ON location_postcode USING BTREE (postcode);
469 GRANT SELECT ON location_postcode TO "www-data";
470 DROP TYPE IF EXISTS nearfeaturecentr CASCADE;
471 CREATE TYPE nearfeaturecentr AS (
474 rank_address smallint,
475 rank_search smallint,
483 Add postcode column to `location_area` tables with SQL statement:
486 ALTER TABLE location_area ADD COLUMN postcode TEXT;
489 Then reimport the functions:
492 ./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
495 Create appropriate triggers with SQL:
498 CREATE TRIGGER location_postcode_before_update BEFORE UPDATE ON location_postcode
499 FOR EACH ROW EXECUTE PROCEDURE postcode_update();
502 Finally populate the postcode table (will take a while):
505 ./utils/setup.php --calculate-postcodes --index --index-noanalyse
508 This will create a working database. You may also delete the old artificial
509 postcodes now. Note that this may be expensive and is not absolutely necessary.
510 The following SQL statement will remove them:
513 DELETE FROM place_addressline a USING placex p
514 WHERE a.address_place_id = p.place_id and p.osm_type = 'P';
515 ALTER TABLE placex DISABLE TRIGGER USER;
516 DELETE FROM placex WHERE osm_type = 'P';
517 ALTER TABLE placex ENABLE TRIGGER USER;