XDB::rawExecute('DROP TABLE IF EXISTS fusionax_import');
// Fills pid fields in all table, to avoid to many joins.
-foreach (array('fusionax_activites', 'fusionax_adresses', 'fusionax_anciens', 'fusionax_formations') as $table) {
+foreach (array('fusionax_activites', 'fusionax_adresses', 'fusionax_anciens', 'fusionax_formations', 'fusionax_formations_md') as $table) {
XDB::rawExecute("UPDATE $table AS f
INNER JOIN profiles AS p ON (f.ax_id = p.ax_id)
SET f.pid = p.pid");
XDB::rawExecute('ALTER TABLE geoloc_countries DROP INDEX licensePlate');
// Updates corps.
+XDB::rawExecute("INSERT IGNORE INTO profile_corps_enum (name, abbreviation)
+ VALUES ('Ancien élève étranger', 'Z')");
+XDB::rawExecute("INSERT IGNORE INTO profile_corps_rank_enum (name, abbreviation)
+ VALUES ('Ing.ch.P.C.hon.', 'DEL1'), ('Ing.Mil.Air Retr.', 'DEL2'),
+ ('Col.hon.Tra.', 'DEL3'), ('Colonel CR', 'DEL4'),
+ ('Conseil d\'Etat', 'DEL5'), ('Commiss.Gén. Brigade aérienne', 'DEL6'),
+ ('Off. Mar. dém.', 'DEL7'), ('Maître des Requêtes', 'DEL8'),
+ ('', 'DEL9'), ('autres', 'DEL10')");
XDB::rawExecute('UPDATE profile_corps AS pc
INNER JOIN fusionax_anciens AS f ON (f.pid = pc.pid)
INNER JOIN profile_corps_enum AS c ON (f.corps_sortie = c.abbreviation)
WHERE name = 'Aucun (anc. démissionnaire)'");
XDB::rawExecute("DELETE FROM profile_corps_enum
WHERE name = 'Ancien élève étranger'");
+XDB::rawExecute("UPDATE profile_corps AS c
+ INNER JOIN profile_corps_rank_enum AS r ON (c.rankid = r.id)
+ INNER JOIN profile_corps_rank_enum AS a ON (a.name = 'Aucun')
+ SET c.rankid = a.id
+ WHERE r.name LIKE 'DEL%'");
+XDB::rawExecute("DELETE FROM profile_corps_rank_enum
+ WHERE name LIKE 'DEL%'");
// Updates email_directory.
XDB::rawExecute("UPDATE profiles AS p
INNER JOIN profile_addresses AS pa ON (pa.pid = f.pid AND pa.type = 'home' AND pa.id = 0)
WHERE f.text IS NOT NULL");
-XDB::rawExecute("INSERT INTO profile_addresses (pid, type, id, pub, text)
- SELECT f.pid, 'home', IF(pa.id IS NULL , 0, MAX(pa.id) + 1), 'ax', f.text
+XDB::rawExecute("INSERT INTO profile_addresses (pid, type, id, pub, text, flags)
+ SELECT f.pid, 'home', IF(pa.id IS NULL , 0, MAX(pa.id) + 1), 'ax', f.text, 'mail'
FROM fusionax_adresses AS f
LEFT JOIN profile_addresses AS pa ON (pa.pid = f.pid AND pa.type = 'home')
WHERE f.text IS NOT NULL
// Retrieves education from AX database. This is the hardest part since AX only kept education as an unformated string.
echo "Starts educations inclusions.\n";
+// Updates master and doctorate educational fields.
+XDB::rawExecute("UPDATE profile_education AS e
+ INNER JOIN fusionax_formations_md AS f ON (f.pid = e.pid AND FIND_IN_SET('primary', e.flags))
+ SET e.program = f.field, e.fieldid = f.fieldid");
+XDB::rawExecute('DROP TABLE IF EXISTS fusionax_formations_md');
+
// Deletes empty educations.
XDB::rawExecute("DELETE FROM fusionax_formations
WHERE Intitule_formation = '' AND Intitule_diplome = '' AND Descr_formation = ''");