summaryrefslogtreecommitdiff
path: root/util/sql/func.sql
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-08-09 16:53:54 +0200
committerYorhel <git@yorhel.nl>2019-08-09 16:53:56 +0200
commit414daab355c8392dc21d5623cd458426d221fedf (patch)
tree14853fa252b5130e24dcad779505f8b86b9c909b /util/sql/func.sql
parent76da9bdcf9a6492888f02457a9c7a23454da1092 (diff)
Replace Wikipedia links with Wikidata IDs
+ Automatically fetch other links from Wikidata
Diffstat (limited to 'util/sql/func.sql')
-rw-r--r--util/sql/func.sql11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/sql/func.sql b/util/sql/func.sql
index 93025dfe..af01e0fe 100644
--- a/util/sql/func.sql
+++ b/util/sql/func.sql
@@ -479,6 +479,17 @@ $$ LANGUAGE plpgsql;
+-- insert rows into wikidata for new l_wikidata items
+-- (this is a BEFORE trigger)
+CREATE OR REPLACE FUNCTION wikidata_insert() RETURNS trigger AS $$
+BEGIN
+ INSERT INTO wikidata (id) VALUES (NEW.l_wikidata) ON CONFLICT (id) DO NOTHING;
+ RETURN NEW;
+END;
+$$ LANGUAGE plpgsql;
+
+
+
-- For each row in rlists, there should be at least one corresponding row in
-- vnlists for at least one of the VNs linked to that release.
-- 1. When a row is deleted from vnlists, also remove all rows from rlists that