]> git.openstreetmap.org Git - nominatim.git/blob - lib-sql/tables/postcodes.sql
Merge pull request #3982 from lonvia/split-table-creation
[nominatim.git] / lib-sql / tables / postcodes.sql
1 -- SPDX-License-Identifier: GPL-2.0-only
2 --
3 -- This file is part of Nominatim. (https://nominatim.org)
4 --
5 -- Copyright (C) 2026 by the Nominatim developer community.
6 -- For a full list of authors see the git log.
7
8 DROP TABLE IF EXISTS location_postcodes;
9 CREATE TABLE location_postcodes (
10   place_id BIGINT NOT NULL,
11   parent_place_id BIGINT,
12   osm_id BIGINT,
13   rank_search SMALLINT NOT NULL,
14   indexed_status SMALLINT NOT NULL,
15   indexed_date TIMESTAMP,
16   country_code varchar(2) NOT NULL,
17   postcode TEXT NOT NULL,
18   centroid GEOMETRY(Geometry, 4326) NOT NULL,
19   geometry GEOMETRY(Geometry, 4326) NOT NULL
20   );
21
22 CREATE UNIQUE INDEX idx_location_postcodes_id ON location_postcodes
23   USING BTREE (place_id) {{db.tablespace.search_index}};
24 CREATE INDEX idx_location_postcodes_geometry ON location_postcodes
25   USING GIST (geometry) {{db.tablespace.search_index}};
26 CREATE INDEX IF NOT EXISTS idx_location_postcodes_postcode ON location_postcodes
27   USING BTREE (postcode, country_code) {{db.tablespace.search_index}};
28 CREATE INDEX IF NOT EXISTS idx_location_postcodes_osmid ON location_postcodes
29   USING BTREE (osm_id) {{db.tablespace.search_index}};
30