DELETE FROM public.cities WHERE city_en = 'Selenginsk' AND city_ru = 'Улан-Удэ' AND city_uk = 'Selenginsk';
DELETE FROM public.cities WHERE city_en = 'Lisitsina' AND city_ru = 'Киржач' AND city_uk = 'Lisitsina';
DELETE FROM public.cities WHERE city_en = 'Suvorova' AND city_ru = 'Хилок' AND city_uk = 'Suvorova';

-- Fix city entries
-- Zabaykalskiy kray
UPDATE public.cities SET region = 'RU-95' WHERE region = 'RU-93';
-- Kamchatka
UPDATE public.cities SET region = 'RU-26' WHERE region = 'RU-92';
-- Perm
UPDATE public.cities SET region = 'RU-58' WHERE region = 'RU-90';
-- Krasnoyarsk
UPDATE public.cities SET region = 'RU-91' WHERE region = 'RU-39';

-- Same for locations
UPDATE public.locations SET region_id = 'RU-95', region = 'Zabaykalsky Krai' WHERE region = 'RU-93';
UPDATE public.locations SET region_id = 'RU-26', region = 'Kamchatka' WHERE region = 'RU-92';
UPDATE public.locations SET region_id = 'RU-58', region = 'Perm' WHERE region = 'RU-90';
UPDATE public.locations SET region_id = 'RU-91', region = 'Krasnoyarsk' WHERE region = 'RU-39';
-- Same for answer_links
UPDATE public.questionnaire_answer_links SET region_id = 'RU-95', region = 'Zabaykalsky Krai' WHERE region_id = 'RU-93';
UPDATE public.questionnaire_answer_links SET region_id = 'RU-26', region = 'Kamchatka' WHERE region_id = 'RU-92';
UPDATE public.questionnaire_answer_links SET region_id = 'RU-58', region = 'Perm' WHERE region_id = 'RU-90';
UPDATE public.questionnaire_answer_links SET region_id = 'RU-91', region = 'Krasnoyarsk' WHERE region_id = 'RU-39';
-- Same for users
UPDATE public.users SET region = 'RU-95' WHERE region = 'RU-93';
UPDATE public.users SET region = 'RU-26' WHERE region = 'RU-92';
UPDATE public.users SET region = 'RU-58' WHERE region = 'RU-90';
UPDATE public.users SET region = 'RU-91' WHERE region = 'RU-39';

DELETE FROM public.regions WHERE region = 'RU-93';
DELETE FROM public.regions WHERE region = 'RU-92';
DELETE FROM public.regions WHERE region = 'RU-90';
DELETE FROM public.regions WHERE region = 'RU-39';


-- Set city Achinsk where city is Ачинск
UPDATE public.locations SET city = 'Achinsk', city_id = '37486' WHERE city_id = '65525';
UPDATE public.questionnaire_answer_links SET city = 'Achinsk', city_id = '37486' WHERE city_id = '65525';
UPDATE public.user_city_access SET city_id = '37486' WHERE city_id = '65525';
UPDATE public.users SET city = '37486' WHERE city = '65525';


-- Set city Surikova where city is Сурикова
UPDATE public.locations SET city = 'Surikova', city_id = '37401' WHERE city_id = '65627';
UPDATE public.questionnaire_answer_links SET city = 'Surikova', city_id = '37401' WHERE city_id = '65627';
UPDATE public.user_city_access SET city_id = '37401' WHERE city_id = '65627';
UPDATE public.users SET city = '37401' WHERE city = '65627';


-- Set city Boguchany where city is Богучаны
UPDATE public.locations SET city = 'Boguchany', city_id = '37314' WHERE city_id = '65669';
UPDATE public.questionnaire_answer_links SET city = 'Boguchany', city_id = '37314' WHERE city_id = '65669';
UPDATE public.user_city_access SET city_id = '37314' WHERE city_id = '65669';
UPDATE public.users SET city = '37314' WHERE city = '65669';


-- Set city Eniseisk where city is Енисейск
UPDATE public.locations SET city = 'Eniseisk', city_id = '37258' WHERE city_id = '65848';
UPDATE public.questionnaire_answer_links SET city = 'Eniseisk', city_id = '37258' WHERE city_id = '65848';
UPDATE public.user_city_access SET city_id = '37258' WHERE city_id = '65848';
UPDATE public.users SET city = '37258' WHERE city = '65848';


-- Set city Lesosibirsk where city is Лесосибирск
UPDATE public.locations SET city = 'Lesosibirsk', city_id = '37318' WHERE city_id = '65854';
UPDATE public.questionnaire_answer_links SET city = 'Lesosibirsk', city_id = '37318' WHERE city_id = '65854';
UPDATE public.user_city_access SET city_id = '37318' WHERE city_id = '65854';
UPDATE public.users SET city = '37318' WHERE city = '65854';


-- Set city Ilanskiy where city is Иланский
UPDATE public.locations SET city = 'Ilanskiy', city_id = '37029' WHERE city_id = '65946';
UPDATE public.questionnaire_answer_links SET city = 'Ilanskiy', city_id = '37029' WHERE city_id = '65946';
UPDATE public.user_city_access SET city_id = '37029' WHERE city_id = '65946';
UPDATE public.users SET city = '37029' WHERE city = '65946';


-- Set city Kansk where city is Канск
UPDATE public.locations SET city = 'Kansk', city_id = '37574' WHERE city_id = '66014';
UPDATE public.questionnaire_answer_links SET city = 'Kansk', city_id = '37574' WHERE city_id = '66014';
UPDATE public.user_city_access SET city_id = '37574' WHERE city_id = '66014';
UPDATE public.users SET city = '37574' WHERE city = '66014';


-- Set city Kodinsk where city is Кодинск
UPDATE public.locations SET city = 'Kodinsk', city_id = '37586' WHERE city_id = '66070';
UPDATE public.questionnaire_answer_links SET city = 'Kodinsk', city_id = '37586' WHERE city_id = '66070';
UPDATE public.user_city_access SET city_id = '37586' WHERE city_id = '66070';
UPDATE public.users SET city = '37586' WHERE city = '66070';


-- Set city Kuragino where city is Курагино
UPDATE public.locations SET city = 'Kuragino', city_id = '36948' WHERE city_id = '66118';
UPDATE public.questionnaire_answer_links SET city = 'Kuragino', city_id = '36948' WHERE city_id = '66118';
UPDATE public.user_city_access SET city_id = '36948' WHERE city_id = '66118';
UPDATE public.users SET city = '36948' WHERE city = '66118';


-- Set city Minusinsk where city is Минусинск
UPDATE public.locations SET city = 'Minusinsk', city_id = '37546' WHERE city_id = '66185';
UPDATE public.questionnaire_answer_links SET city = 'Minusinsk', city_id = '37546' WHERE city_id = '66185';
UPDATE public.user_city_access SET city_id = '37546' WHERE city_id = '66185';
UPDATE public.users SET city = '37546' WHERE city = '66185';


-- Set city Yaga where city is Яга
UPDATE public.locations SET city = 'Yaga', city_id = '36919' WHERE city_id = '66579';
UPDATE public.questionnaire_answer_links SET city = 'Yaga', city_id = '36919' WHERE city_id = '66579';
UPDATE public.user_city_access SET city_id = '36919' WHERE city_id = '66579';
UPDATE public.users SET city = '36919' WHERE city = '66579';

