]> git.openstreetmap.org Git - nominatim.git/blob - lib-sql/table-triggers.sql
Switches associatedStreet handling to dedicated table
[nominatim.git] / lib-sql / table-triggers.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 -- insert creates the location tables, creates location indexes if indexed == true
9 CREATE TRIGGER placex_before_insert BEFORE INSERT ON placex
10     FOR EACH ROW EXECUTE PROCEDURE placex_insert();
11 CREATE TRIGGER osmline_before_insert BEFORE INSERT ON location_property_osmline
12     FOR EACH ROW EXECUTE PROCEDURE osmline_insert();
13
14 -- update insert creates the location tables
15 CREATE TRIGGER placex_before_update BEFORE UPDATE ON placex
16     FOR EACH ROW EXECUTE PROCEDURE placex_update();
17 CREATE TRIGGER osmline_before_update BEFORE UPDATE ON location_property_osmline
18     FOR EACH ROW EXECUTE PROCEDURE osmline_update();
19
20 -- diff update triggers
21 CREATE TRIGGER placex_before_delete AFTER DELETE ON placex
22     FOR EACH ROW EXECUTE PROCEDURE placex_delete();
23 CREATE TRIGGER place_before_delete BEFORE DELETE ON place
24     FOR EACH ROW EXECUTE PROCEDURE place_delete();
25 CREATE TRIGGER place_before_insert BEFORE INSERT ON place
26     FOR EACH ROW EXECUTE PROCEDURE place_insert();
27
28 CREATE TRIGGER location_postcode_before_update BEFORE UPDATE ON location_postcodes
29     FOR EACH ROW EXECUTE PROCEDURE postcodes_update();
30 CREATE TRIGGER location_postcodes_before_delete BEFORE DELETE ON location_postcodes
31     FOR EACH ROW EXECUTE PROCEDURE postcodes_delete();
32 CREATE TRIGGER location_postcodes_before_insert BEFORE INSERT ON location_postcodes
33     FOR EACH ROW EXECUTE PROCEDURE postcodes_insert();
34
35 CREATE TRIGGER place_interpolation_before_insert BEFORE INSERT ON place_interpolation
36     FOR EACH ROW EXECUTE PROCEDURE place_interpolation_insert();
37 CREATE TRIGGER place_interpolation_before_delete BEFORE DELETE ON place_interpolation
38     FOR EACH ROW EXECUTE PROCEDURE place_interpolation_delete();
39
40 -- Propagate changes to associatedStreet relations to house members
41 -- so that the indexer re-computes their parent_place_id.
42 {% if 'place_associated_street' in db.tables %}
43 CREATE TRIGGER place_associated_street_update
44     AFTER INSERT OR DELETE ON place_associated_street
45     FOR EACH ROW EXECUTE FUNCTION invalidate_associated_street_members();
46 {% endif %}