]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
location-importer.in: add source column for overrides as well
authorPeter Müller <peter.mueller@ipfire.org>
Tue, 8 Jun 2021 09:55:40 +0000 (09:55 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Jun 2021 08:54:31 +0000 (08:54 +0000)
This allows us to track changes introduced by IP feeds from 3rd parties,
such as Amazon AWS, on the SQL server side.

In order not to break existing tables (which would required TRUNCATE),
there currently is no constraint set for the new column, but "NOT NULL"
is planned in the future.

Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/location-importer.in

index 6ccee3b2afd1ada6d3122badf4c15811ab322e3c..10e9c4ac9e77f57d7ea15574508f5cb32f3b763f 100644 (file)
@@ -183,6 +183,7 @@ class CLI(object):
                                );
                                CREATE UNIQUE INDEX IF NOT EXISTS autnum_overrides_number
                                        ON autnum_overrides(number);
+                               ALTER TABLE autnum_overrides ADD COLUMN IF NOT EXISTS source text;
                                ALTER TABLE autnum_overrides ADD COLUMN IF NOT EXISTS is_drop boolean;
 
                                CREATE TABLE IF NOT EXISTS network_overrides(
@@ -196,6 +197,7 @@ class CLI(object):
                                        ON network_overrides(network);
                                CREATE INDEX IF NOT EXISTS network_overrides_search
                                        ON network_overrides USING GIST(network inet_ops);
+                               ALTER TABLE network_overrides ADD COLUMN IF NOT EXISTS source text;
                                ALTER TABLE network_overrides ADD COLUMN IF NOT EXISTS is_drop boolean;
                        """)
 
@@ -1052,14 +1054,16 @@ class CLI(object):
                                                                INSERT INTO network_overrides(
                                                                        network,
                                                                        country,
+                                                                       source,
                                                                        is_anonymous_proxy,
                                                                        is_satellite_provider,
                                                                        is_anycast,
                                                                        is_drop
-                                                               ) VALUES (%s, %s, %s, %s, %s, %s)
+                                                               ) VALUES (%s, %s, %s, %s, %s, %s, %s)
                                                                ON CONFLICT (network) DO NOTHING""",
                                                                "%s" % network,
                                                                block.get("country"),
+                                                               "manual",
                                                                self._parse_bool(block, "is-anonymous-proxy"),
                                                                self._parse_bool(block, "is-satellite-provider"),
                                                                self._parse_bool(block, "is-anycast"),
@@ -1082,15 +1086,17 @@ class CLI(object):
                                                                        number,
                                                                        name,
                                                                        country,
+                                                                       source,
                                                                        is_anonymous_proxy,
                                                                        is_satellite_provider,
                                                                        is_anycast,
                                                                        is_drop
-                                                               ) VALUES(%s, %s, %s, %s, %s, %s, %s)
+                                                               ) VALUES(%s, %s, %s, %s, %s, %s, %s, %s)
                                                                ON CONFLICT DO NOTHING""",
                                                                autnum,
                                                                block.get("name"),
                                                                block.get("country"),
+                                                               "manual",
                                                                self._parse_bool(block, "is-anonymous-proxy"),
                                                                self._parse_bool(block, "is-satellite-provider"),
                                                                self._parse_bool(block, "is-anycast"),