make sure we use exactly the same table structure as osm2pgsql

This commit is contained in:
Sarah Hoffmann
2025-12-31 00:21:27 +01:00
parent da94d7eea3
commit c05b8f241c

View File

@@ -195,10 +195,10 @@ def create_place_postcode_table(conn: Connection, config: Configuration, **_: An
cur.execute( cur.execute(
""" """
CREATE TABLE place_postcode ( CREATE TABLE place_postcode (
osm_type VARCHAR(1), osm_type CHAR(1) NOT NULL,
osm_id BIGINT, osm_id BIGINT NOT NULL,
postcode TEXT NOT NULL, postcode TEXT NOT NULL,
country_code VARCHAR(2), country_code TEXT,
centroid GEOMETRY(Point, 4326) NOT NULL, centroid GEOMETRY(Point, 4326) NOT NULL,
geometry GEOMETRY(Geometry, 4326) geometry GEOMETRY(Geometry, 4326)
) )
@@ -224,6 +224,11 @@ def create_place_postcode_table(conn: Connection, config: Configuration, **_: An
CREATE INDEX place_postcode_osm_id_idx ON place_postcode CREATE INDEX place_postcode_osm_id_idx ON place_postcode
USING BTREE (osm_type, osm_id) USING BTREE (osm_type, osm_id)
""") """)
cur.execute(
"""
CREATE INDEX place_postcode_postcode_idx ON place_postcode
USING BTREE (postcode)
""")
cur.execute("ALTER TABLE place ENABLE TRIGGER ALL") cur.execute("ALTER TABLE place ENABLE TRIGGER ALL")
if not has_postcode_table: if not has_postcode_table:
sqlp.run_sql_file(conn, 'functions/postcode_triggers.sql') sqlp.run_sql_file(conn, 'functions/postcode_triggers.sql')