Commit | Line | Data |
---|---|---|
043bbacf SJ |
1 | CREATE TABLE IF NOT EXISTS profile_education_field_enum ( |
2 | id INT(2) NOT NULL AUTO_INCREMENT, | |
3 | field VARCHAR(255) DEFAULT NULL, | |
4 | PRIMARY KEY(id), | |
5 | UNIQUE KEY(field) | |
6 | ) CHARSET=utf8; | |
7 | ||
8 | CREATE TABLE IF NOT EXISTS profile_education_degree_enum ( | |
9 | id INT(2) NOT NULL AUTO_INCREMENT, | |
10 | degree VARCHAR(255) DEFAULT NULL, | |
c7eac294 SJ |
11 | abbreviation VARCHAR(255) DEFAULT '' NOT NULL, |
12 | level TINYINT (1) UNSIGNED DEFAULT 0 NOT NULL, | |
043bbacf | 13 | PRIMARY KEY(id), |
483cbf2c | 14 | UNIQUE KEY(degree) |
043bbacf SJ |
15 | ) CHARSET=utf8; |
16 | ||
17 | CREATE TABLE IF NOT EXISTS profile_education_degree ( | |
18 | eduid INT(4) NOT NULL DEFAULT 0, | |
19 | degreeid INT(2) NOT NULL DEFAULT 0, | |
20 | PRIMARY KEY(eduid, degreeid) | |
21 | ) CHARSET=utf8; | |
22 | ||
23 | CREATE TABLE IF NOT EXISTS profile_education_enum ( | |
24 | id INT(4) NOT NULL AUTO_INCREMENT, | |
25 | name VARCHAR(255) DEFAULT NULL, | |
c7eac294 | 26 | abbreviation VARCHAR(255) DEFAULT '' NOT NULL, |
043bbacf SJ |
27 | url VARCHAR(255) DEFAULT NULL, |
28 | country CHAR(2) NOT NULL DEFAULT 'FR', | |
29 | PRIMARY KEY(id), | |
483cbf2c | 30 | UNIQUE KEY(name) |
043bbacf SJ |
31 | ) CHARSET=utf8; |
32 | ||
33 | CREATE TABLE IF NOT EXISTS profile_education ( | |
fb2c09c9 | 34 | id TINYINT(2) UNSIGNED NOT NULL DEFAULT 0, |
043bbacf SJ |
35 | uid INT(11) NOT NULL DEFAULT 0, |
36 | eduid INT(4) NOT NULL DEFAULT 0, | |
37 | degreeid INT(4) NOT NULL DEFAULT 0, | |
38 | fieldid INT(2) NOT NULL DEFAULT 0, | |
c7eac294 | 39 | entry_year INT(4) DEFAULT NULL, |
58acfe8b | 40 | grad_year INT(4) DEFAULT NULL, |
1504ac45 | 41 | program VARCHAR(255) DEFAULT NULL, |
c7eac294 | 42 | flags SET('primary') DEFAULT '' NOT NULL, |
043bbacf SJ |
43 | PRIMARY KEY(id, uid) |
44 | ) CHARSET=utf8; | |
45 | ||
46 | INSERT INTO profile_education_field_enum (field) | |
47 | VALUES ('Aéronautique'), ('Agronomie'), ('Assurance'), ('Biologie'), | |
48 | ('Chimie'), ('Droit'), ('Économie'), ('Électronique/électricité'), | |
49 | ('Environnement/développement durable'), ('Finance'), ('Géographie'), | |
50 | ('Histoire'), ('Informatique'), ('Langues'), ('Mathématiques'), | |
51 | ('Mathématiques appliquées'), ('Mécanique'), ('Médecine'), | |
52 | ('Philosophie'), ('Physique'), ('Sciences politiques'); | |
53 | ||
54 | INSERT INTO profile_education_degree_enum (degree) | |
55 | VALUES ('Diplôme'), ('Ingénieur'), ('Corps'), ('MS'), ('PhD'), | |
56 | ('DEA'), ('ME'), ('MBA'), ('MiF'), ('MPA'), ('Licence'); | |
57 | ||
58 | INSERT INTO profile_education_degree (eduid, degreeid) | |
59 | SELECT a.id, d.id | |
60 | FROM applis_def AS a | |
61 | INNER JOIN profile_education_degree_enum AS d ON (FIND_IN_SET(d.degree, a.type)); | |
62 | ||
63 | INSERT INTO profile_education_enum (id, name, url) | |
64 | SELECT id, text, url | |
65 | FROM applis_def; | |
66 | ||
67 | INSERT INTO profile_education (id, uid, eduid, degreeid) | |
68 | SELECT a.ordre, a.uid, a.aid, d.id | |
69 | FROM applis_ins AS a | |
70 | INNER JOIN profile_education_degree_enum AS d ON (a.type = d.degree); | |
71 | ||
3a703848 SJ |
72 | UPDATE watch_profile AS w1 |
73 | INNER JOIN watch_profile AS w2 ON (w1.uid = w2.uid AND w1.field = 'appli1' AND w2.field = 'appli2') | |
74 | SET w1.ts = IF(w1.ts > w2.ts, w1.ts, w2.ts), w2.ts = IF(w1.ts > w2.ts, w1.ts, w2.ts); | |
75 | ||
76 | INSERT IGNORE INTO watch_profile (uid, ts, field) | |
77 | SELECT uid, ts, 'appli1' | |
78 | FROM watch_profile | |
79 | WHERE field = 'appli2'; | |
80 | ||
81 | ALTER TABLE watch_profile MODIFY field enum('nom', 'freetext', 'mobile', 'nationalite', 'nationalite2', | |
82 | 'nationalite3', 'nick', 'web', 'networking', 'appli1', 'appli2', | |
83 | 'edus', 'addresses', 'section', 'binets', 'medals', 'cv', 'jobs', | |
84 | 'photo'); | |
85 | ||
86 | UPDATE watch_profile SET field = 'edus' WHERE field = 'appli1'; | |
87 | ||
88 | DELETE FROM watch_profile WHERE field = 'appli2'; | |
89 | ||
90 | ALTER TABLE watch_profile MODIFY field enum('nom', 'freetext', 'mobile', 'nationalite', 'nationalite2', | |
91 | 'nationalite3', 'nick', 'web', 'networking', 'edus', 'addresses', | |
92 | 'section', 'binets', 'medals', 'cv', 'jobs', 'photo'); | |
043bbacf SJ |
93 | |
94 | # vim:set syntax=mysql: | |
95 |