]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
importer: Allow storing multiple Geofeeds for the same network
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 12 Mar 2024 11:17:50 +0000 (11:17 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 12 Mar 2024 11:17:50 +0000 (11:17 +0000)
This is very likely not required except for a couple of overrides.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/location-importer.in

index 49e914c81720ef79b6477ae70ba96bf8abbd1ad4..5424b5c552c78916878561bddba0e516d3316d84 100644 (file)
@@ -241,12 +241,13 @@ class CLI(object):
                                        ON geofeed_networks USING GIST(network inet_ops);
                                CREATE TABLE IF NOT EXISTS network_geofeeds(network inet, url text);
                                ALTER TABLE network_geofeeds ADD COLUMN IF NOT EXISTS source text NOT NULL;
-                               CREATE UNIQUE INDEX IF NOT EXISTS network_geofeeds_unique
-                                       ON network_geofeeds(network);
+                               CREATE UNIQUE INDEX IF NOT EXISTS network_geofeeds_unique2
+                                       ON network_geofeeds(network, url);
                                CREATE INDEX IF NOT EXISTS network_geofeeds_search
                                        ON network_geofeeds USING GIST(network inet_ops);
                                CREATE INDEX IF NOT EXISTS network_geofeeds_url
                                        ON network_geofeeds(url);
+                               DROP INDEX IF EXISTS network_geofeeds_unique;
 
                                -- feeds
                                CREATE TABLE IF NOT EXISTS autnum_feeds(
@@ -1330,10 +1331,9 @@ class CLI(object):
                        )
                        ON CONFLICT
                        (
-                               network
+                               network, url
                        )
                        DO UPDATE SET
-                               url = excluded.url,
                                source = excluded.source
                        """, "%s" % single_network, url, source,
                )
@@ -2019,10 +2019,9 @@ class CLI(object):
                                                                )
                                                                ON CONFLICT
                                                                (
-                                                                       network
+                                                                       network, url
                                                                )
                                                                DO UPDATE SET
-                                                                       url = excluded.url,
                                                                        source = excluded.source
                                                                """, (("%s" % n, url, "overrides") for n in networks),
                                                        )