Make the patch ideompotent

This commit is contained in:
Mario de Frutos
2018-03-06 18:46:57 +01:00
parent 0e21c4bed3
commit a468a01d9c

View File

@@ -1,3 +1,9 @@
-- Patch 0.0.1 data version -20160622
INSERT INTO admin0_synonyms (name, rank, adm0_a3) VALUES ('Republic of the Congo', 10, 'COG');
DO $$
DECLARE exiting INTEGER;
BEGIN
SELECT count(*) FROM admin0_synonyms WHERE name = 'Republic of the Congo' AND adm0_a3 = 'COG' and rank = 10 INTO exiting;
IF exiting = 0 THEN
INSERT INTO admin0_synonyms (name, rank, adm0_a3) VALUES ('Republic of the Congo', 10, 'COG');
END IF;
END$$;