-- Mise à jour complète des départements limitrophes pour tous les départements français
-- Format : liste des codes départements séparés par des virgules

-- Auvergne-Rhône-Alpes
UPDATE x_departements SET dept_limitrophes = '07,15,43,48' WHERE code = '01'; -- Ain : Ardèche, Cantal, Haute-Loire, Lozère
UPDATE x_departements SET dept_limitrophes = '04,05,26,84' WHERE code = '03'; -- Allier : Alpes-de-Haute-Provence, Hautes-Alpes, Drôme, Vaucluse
UPDATE x_departements SET dept_limitrophes = '01,26,30,43,48,84' WHERE code = '07'; -- Ardèche : Ain, Drôme, Gard, Haute-Loire, Lozère, Vaucluse
UPDATE x_departements SET dept_limitrophes = '12,19,43,46,48' WHERE code = '15'; -- Cantal : Aveyron, Corrèze, Haute-Loire, Lot, Lozère
UPDATE x_departements SET dept_limitrophes = '04,05,73,84' WHERE code = '26'; -- Drôme : Alpes-de-Haute-Provence, Hautes-Alpes, Savoie, Vaucluse
UPDATE x_departements SET dept_limitrophes = '05,06,13,73' WHERE code = '38'; -- Isère : Hautes-Alpes, Alpes-Maritimes, Bouches-du-Rhône, Savoie
UPDATE x_departements SET dept_limitrophes = '07,15,19,43,48,63' WHERE code = '42'; -- Loire : Ardèche, Cantal, Corrèze, Haute-Loire, Lozère, Puy-de-Dôme
UPDATE x_departements SET dept_limitrophes = '01,07,15,42,48,63' WHERE code = '43'; -- Haute-Loire : Ain, Ardèche, Cantal, Loire, Lozère, Puy-de-Dôme
UPDATE x_departements SET dept_limitrophes = '03,15,23,42,43' WHERE code = '63'; -- Puy-de-Dôme : Allier, Cantal, Creuse, Loire, Haute-Loire
UPDATE x_departements SET dept_limitrophes = '01,38,39,71' WHERE code = '69'; -- Rhône : Ain, Isère, Jura, Saône-et-Loire
UPDATE x_departements SET dept_limitrophes = '01,25,38,39,74' WHERE code = '73'; -- Savoie : Ain, Doubs, Isère, Jura, Haute-Savoie
UPDATE x_departements SET dept_limitrophes = '01,73' WHERE code = '74'; -- Haute-Savoie : Ain, Savoie (+ frontières Suisse et Italie)

-- Bourgogne-Franche-Comté
UPDATE x_departements SET dept_limitrophes = '10,45,52,58,77,89' WHERE code = '21'; -- Côte-d'Or : Aube, Loiret, Haute-Marne, Nièvre, Seine-et-Marne, Yonne
UPDATE x_departements SET dept_limitrophes = '39,68,70,73,90' WHERE code = '25'; -- Doubs : Jura, Haut-Rhin, Haute-Saône, Savoie, Territoire de Belfort (+ frontière Suisse)
UPDATE x_departements SET dept_limitrophes = '01,25,69,70,71,73' WHERE code = '39'; -- Jura : Ain, Doubs, Rhône, Haute-Saône, Saône-et-Loire, Savoie
UPDATE x_departements SET dept_limitrophes = '03,18,21,45,71,89' WHERE code = '58'; -- Nièvre : Allier, Cher, Côte-d'Or, Loiret, Saône-et-Loire, Yonne
UPDATE x_departements SET dept_limitrophes = '21,25,39,52,88' WHERE code = '70'; -- Haute-Saône : Côte-d'Or, Doubs, Jura, Haute-Marne, Vosges
UPDATE x_departements SET dept_limitrophes = '01,03,21,39,58,69' WHERE code = '71'; -- Saône-et-Loire : Ain, Allier, Côte-d'Or, Jura, Nièvre, Rhône
UPDATE x_departements SET dept_limitrophes = '10,21,45,58,77' WHERE code = '89'; -- Yonne : Aube, Côte-d'Or, Loiret, Nièvre, Seine-et-Marne
UPDATE x_departements SET dept_limitrophes = '25,68,70' WHERE code = '90'; -- Territoire de Belfort : Doubs, Haut-Rhin, Haute-Saône

-- Bretagne
UPDATE x_departements SET dept_limitrophes = '29,35,56' WHERE code = '22'; -- Côtes-d'Armor
UPDATE x_departements SET dept_limitrophes = '22,56' WHERE code = '29'; -- Finistère
UPDATE x_departements SET dept_limitrophes = '22,44,49,50,53,56' WHERE code = '35'; -- Ille-et-Vilaine
UPDATE x_departements SET dept_limitrophes = '22,29,35,44' WHERE code = '56'; -- Morbihan

-- Centre-Val de Loire
UPDATE x_departements SET dept_limitrophes = '03,23,36,41,58' WHERE code = '18'; -- Cher
UPDATE x_departements SET dept_limitrophes = '27,37,41,45,61,72,78,91' WHERE code = '28'; -- Eure-et-Loir
UPDATE x_departements SET dept_limitrophes = '18,23,37,41,86,87' WHERE code = '36'; -- Indre
UPDATE x_departements SET dept_limitrophes = '36,41,49,72,86' WHERE code = '37'; -- Indre-et-Loire
UPDATE x_departements SET dept_limitrophes = '18,28,36,37,45,72' WHERE code = '41'; -- Loir-et-Cher
UPDATE x_departements SET dept_limitrophes = '18,21,28,41,58,77,89,91' WHERE code = '45'; -- Loiret

-- Corse
UPDATE x_departements SET dept_limitrophes = '2B' WHERE code = '2A'; -- Corse-du-Sud : Haute-Corse
UPDATE x_departements SET dept_limitrophes = '2A' WHERE code = '2B'; -- Haute-Corse : Corse-du-Sud

-- Grand Est
UPDATE x_departements SET dept_limitrophes = '02,51,55' WHERE code = '08'; -- Ardennes (+ frontière Belgique)
UPDATE x_departements SET dept_limitrophes = '21,51,52,77,89' WHERE code = '10'; -- Aube
UPDATE x_departements SET dept_limitrophes = '02,08,10,52,77' WHERE code = '51'; -- Marne
UPDATE x_departements SET dept_limitrophes = '10,21,51,55,70,88' WHERE code = '52'; -- Haute-Marne
UPDATE x_departements SET dept_limitrophes = '55,57,88' WHERE code = '54'; -- Meurthe-et-Moselle
UPDATE x_departements SET dept_limitrophes = '08,52,54,57' WHERE code = '55'; -- Meuse (+ frontière Belgique)
UPDATE x_departements SET dept_limitrophes = '54,55,67' WHERE code = '57'; -- Moselle (+ frontières Luxembourg et Allemagne)
UPDATE x_departements SET dept_limitrophes = '25,57,68,88,90' WHERE code = '67'; -- Bas-Rhin (+ frontière Allemagne)
UPDATE x_departements SET dept_limitrophes = '67,70,88,90' WHERE code = '68'; -- Haut-Rhin (+ frontières Allemagne et Suisse)
UPDATE x_departements SET dept_limitrophes = '52,54,67,68,70' WHERE code = '88'; -- Vosges

-- Hauts-de-France
UPDATE x_departements SET dept_limitrophes = '08,51,59,60,77,80' WHERE code = '02'; -- Aisne
UPDATE x_departements SET dept_limitrophes = '02,62,80' WHERE code = '59'; -- Nord (+ frontière Belgique)
UPDATE x_departements SET dept_limitrophes = '02,27,76,77,80,95' WHERE code = '60'; -- Oise
UPDATE x_departements SET dept_limitrophes = '59,80' WHERE code = '62'; -- Pas-de-Calais (+ frontière Belgique)
UPDATE x_departements SET dept_limitrophes = '02,27,59,60,62,76' WHERE code = '80'; -- Somme

-- Île-de-France
UPDATE x_departements SET dept_limitrophes = '92,93,94' WHERE code = '75'; -- Paris
UPDATE x_departements SET dept_limitrophes = '02,10,45,51,60,89,91,93,94,95' WHERE code = '77'; -- Seine-et-Marne
UPDATE x_departements SET dept_limitrophes = '27,28,91,92,95' WHERE code = '78'; -- Yvelines
UPDATE x_departements SET dept_limitrophes = '28,45,77,78,92,94' WHERE code = '91'; -- Essonne
UPDATE x_departements SET dept_limitrophes = '75,78,91,93,94,95' WHERE code = '92'; -- Hauts-de-Seine
UPDATE x_departements SET dept_limitrophes = '75,77,92,94,95' WHERE code = '93'; -- Seine-Saint-Denis
UPDATE x_departements SET dept_limitrophes = '75,77,91,92,93' WHERE code = '94'; -- Val-de-Marne
UPDATE x_departements SET dept_limitrophes = '27,60,77,78,92,93' WHERE code = '95'; -- Val-d'Oise

-- Normandie
UPDATE x_departements SET dept_limitrophes = '27,50,53,61,72' WHERE code = '14'; -- Calvados
UPDATE x_departements SET dept_limitrophes = '14,28,60,61,72,76,78,95' WHERE code = '27'; -- Eure
UPDATE x_departements SET dept_limitrophes = '14,35,53,61' WHERE code = '50'; -- Manche
UPDATE x_departements SET dept_limitrophes = '14,27,28,35,41,50,53,72' WHERE code = '61'; -- Orne
UPDATE x_departements SET dept_limitrophes = '27,60,80' WHERE code = '76'; -- Seine-Maritime

-- Nouvelle-Aquitaine
UPDATE x_departements SET dept_limitrophes = '17,24,33,87' WHERE code = '16'; -- Charente
UPDATE x_departements SET dept_limitrophes = '16,33,79,85' WHERE code = '17'; -- Charente-Maritime
UPDATE x_departements SET dept_limitrophes = '15,23,24,46,87' WHERE code = '19'; -- Corrèze
UPDATE x_departements SET dept_limitrophes = '18,19,36,86,87' WHERE code = '23'; -- Creuse
UPDATE x_departements SET dept_limitrophes = '16,19,33,46,47,87' WHERE code = '24'; -- Dordogne
UPDATE x_departements SET dept_limitrophes = '16,17,24,40,47' WHERE code = '33'; -- Gironde
UPDATE x_departements SET dept_limitrophes = '32,33,47,64,65' WHERE code = '40'; -- Landes
UPDATE x_departements SET dept_limitrophes = '24,32,40,46,82' WHERE code = '47'; -- Lot-et-Garonne
UPDATE x_departements SET dept_limitrophes = '40,65' WHERE code = '64'; -- Pyrénées-Atlantiques (+ frontière Espagne)
UPDATE x_departements SET dept_limitrophes = '17,49,85,86' WHERE code = '79'; -- Deux-Sèvres
UPDATE x_departements SET dept_limitrophes = '16,23,36,37,79' WHERE code = '86'; -- Vienne
UPDATE x_departements SET dept_limitrophes = '16,19,23,24,36,86' WHERE code = '87'; -- Haute-Vienne

-- Occitanie
UPDATE x_departements SET dept_limitrophes = '11,31,66' WHERE code = '09'; -- Ariège : Aude, Haute-Garonne, Pyrénées-Orientales (+ frontières Espagne et Andorre)
UPDATE x_departements SET dept_limitrophes = '09,31,66' WHERE code = '11'; -- Aude
UPDATE x_departements SET dept_limitrophes = '15,30,34,46,48,81,82' WHERE code = '12'; -- Aveyron
UPDATE x_departements SET dept_limitrophes = '07,12,34,48,84' WHERE code = '30'; -- Gard
UPDATE x_departements SET dept_limitrophes = '09,32,65,82' WHERE code = '31'; -- Haute-Garonne : Ariège, Gers, Hautes-Pyrénées, Tarn-et-Garonne (+ frontière Espagne)
UPDATE x_departements SET dept_limitrophes = '31,40,47,65,82' WHERE code = '32'; -- Gers
UPDATE x_departements SET dept_limitrophes = '11,12,30' WHERE code = '34'; -- Hérault
UPDATE x_departements SET dept_limitrophes = '12,15,19,24,47,81,82' WHERE code = '46'; -- Lot
UPDATE x_departements SET dept_limitrophes = '07,12,15,30,43' WHERE code = '48'; -- Lozère
UPDATE x_departements SET dept_limitrophes = '31,32,40,64' WHERE code = '65'; -- Hautes-Pyrénées (+ frontière Espagne)
UPDATE x_departements SET dept_limitrophes = '09,11' WHERE code = '66'; -- Pyrénées-Orientales (+ frontière Espagne)
UPDATE x_departements SET dept_limitrophes = '12,34,46,82' WHERE code = '81'; -- Tarn
UPDATE x_departements SET dept_limitrophes = '12,31,32,46,47,81' WHERE code = '82'; -- Tarn-et-Garonne

-- Pays de la Loire
UPDATE x_departements SET dept_limitrophes = '35,49,56,85' WHERE code = '44'; -- Loire-Atlantique
UPDATE x_departements SET dept_limitrophes = '35,37,44,53,72,79,85,86' WHERE code = '49'; -- Maine-et-Loire
UPDATE x_departements SET dept_limitrophes = '14,35,49,50,61,72' WHERE code = '53'; -- Mayenne
UPDATE x_departements SET dept_limitrophes = '14,27,28,37,41,49,53,61' WHERE code = '72'; -- Sarthe
UPDATE x_departements SET dept_limitrophes = '17,44,49,79' WHERE code = '85'; -- Vendée

-- Provence-Alpes-Côte d'Azur
UPDATE x_departements SET dept_limitrophes = '05,06,26,83,84' WHERE code = '04'; -- Alpes-de-Haute-Provence
UPDATE x_departements SET dept_limitrophes = '04,26,38,73' WHERE code = '05'; -- Hautes-Alpes (+ frontière Italie)
UPDATE x_departements SET dept_limitrophes = '04,83' WHERE code = '06'; -- Alpes-Maritimes (+ frontières Italie et Monaco)
UPDATE x_departements SET dept_limitrophes = '30,83,84' WHERE code = '13'; -- Bouches-du-Rhône
UPDATE x_departements SET dept_limitrophes = '04,06,13,84' WHERE code = '83'; -- Var
UPDATE x_departements SET dept_limitrophes = '04,07,13,26,30,83' WHERE code = '84'; -- Vaucluse

-- Départements et régions d'outre-mer (pas de limitrophes terrestres)
UPDATE x_departements SET dept_limitrophes = NULL WHERE code = '971'; -- Guadeloupe
UPDATE x_departements SET dept_limitrophes = NULL WHERE code = '972'; -- Martinique
UPDATE x_departements SET dept_limitrophes = NULL WHERE code = '973'; -- Guyane (frontières Brésil et Suriname)
UPDATE x_departements SET dept_limitrophes = NULL WHERE code = '974'; -- La Réunion
UPDATE x_departements SET dept_limitrophes = NULL WHERE code = '976'; -- Mayotte