SELECT util.search_path_append('util');

-- Remove 56 duplicate symbols of type 'Old' (these are ambiguous)
DELETE FROM "REF_PLANT_DICTIONARY"
WHERE "*PLANT_SYMBOL" IN (
    SELECT "*PLANT_SYMBOL"
    FROM "REF_PLANT_DICTIONARY"
    WHERE "*PLANT_SYMBOL_TYPE" = 'Old'
    GROUP BY "*PLANT_SYMBOL"
    HAVING count(*) > 1
);

SELECT create_if_not_exists($$ALTER TABLE "REF_PLANT_DICTIONARY" ADD CONSTRAINT "REF_PLANT_DICTIONARY.unique" UNIQUE ("*PLANT_SYMBOL_TYPE", "*PLANT_SYMBOL")$$);
