]> git.openstreetmap.org Git - nominatim.git/blob - lib-sql/tables/postcodes.sql
Merge pull request #4163 from Itz-Agasta/category-support
[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   is_area BOOLEAN NOT NULL DEFAULT FALSE,
19   centroid GEOMETRY(Geometry, 4326) NOT NULL,
20   geometry GEOMETRY(Geometry, 4326) NOT NULL
21   );
22
23 CREATE UNIQUE INDEX idx_location_postcodes_id ON location_postcodes
24   USING BTREE (place_id) {{db.tablespace.search_index}};
25 CREATE INDEX idx_location_postcodes_geometry ON location_postcodes
26   USING GIST (geometry) {{db.tablespace.search_index}};
27 CREATE INDEX idx_location_postcodes_centroid ON location_postcodes
28   USING GIST (centroid) {{db.tablespace.search_index}};
29 CREATE INDEX IF NOT EXISTS idx_location_postcodes_postcode ON location_postcodes
30   USING BTREE (postcode, country_code) {{db.tablespace.search_index}};
31 CREATE INDEX IF NOT EXISTS idx_location_postcodes_osmid ON location_postcodes
32   USING BTREE (osm_id) {{db.tablespace.search_index}};
33