2428 |
jpm |
1 |
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
|
|
2 |
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
|
|
3 |
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
|
|
|
4 |
|
2467 |
jpm |
5 |
SET GLOBAL SQL_MODE = 'NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES';
|
|
|
6 |
|
2427 |
jpm |
7 |
-- Supprime le champ «publiable_eflore»
|
|
|
8 |
ALTER TABLE `cel_images` DROP `publiable_eflore` ;
|
2418 |
jpm |
9 |
|
2427 |
jpm |
10 |
-- Ajoute le champ «transmission» dans «cel_images»
|
2494 |
jpm |
11 |
ALTER TABLE `cel_images` ADD `transmission` TINYINT(1) NOT NULL DEFAULT '0' AFTER `meta_autres`;
|
2427 |
jpm |
12 |
|
|
|
13 |
-- Ajoute le champ «date_liaison» dans «cel_images»
|
2485 |
jpm |
14 |
ALTER TABLE `cel_images` ADD `date_liaison` DATETIME NULL AFTER `date_creation`;
|
2418 |
jpm |
15 |
|
2427 |
jpm |
16 |
-- Ajoute le champ «date_transmission» dans «cel_images»
|
2466 |
aurelien |
17 |
ALTER TABLE `cel_images` ADD `date_transmission` DATETIME NULL AFTER `date_liaison`;
|
2427 |
jpm |
18 |
|
|
|
19 |
-- Ajoute le champ «ce_observation» dans «cel_images»
|
2418 |
jpm |
20 |
ALTER TABLE `cel_images` ADD `ce_observation` BIGINT NULL AFTER `id_image`;
|
|
|
21 |
|
2427 |
jpm |
22 |
-- Met à jour la table cel_image avec les données de cel_obs_images
|
2435 |
jpm |
23 |
START TRANSACTION;
|
2476 |
jpm |
24 |
UPDATE cel_images AS ci, cel_obs_images AS coi
|
|
|
25 |
SET ci.ce_observation = coi.id_observation,
|
|
|
26 |
ci.date_liaison = coi.date_liaison
|
|
|
27 |
WHERE ci.id_image = coi.id_image
|
|
|
28 |
AND coi.id_image != '0';
|
2435 |
jpm |
29 |
COMMIT;
|
2418 |
jpm |
30 |
|
2427 |
jpm |
31 |
-- Ajout index sur ce_observation
|
2418 |
jpm |
32 |
CREATE INDEX ce_observation ON cel_images (ce_observation);
|
2503 |
mathias |
33 |
-- Ajout index sur transmission
|
|
|
34 |
CREATE INDEX transmission ON cel_images(transmission);
|
2418 |
jpm |
35 |
|
2428 |
jpm |
36 |
-- Mise à jour du champ «transmission» de la table «cel_images» à partir des données de «cel_obs»
|
2435 |
jpm |
37 |
START TRANSACTION;
|
2476 |
jpm |
38 |
UPDATE cel_images AS ci, cel_obs AS co
|
|
|
39 |
SET ci.transmission = co.transmission,
|
|
|
40 |
ci.date_transmission = co.date_transmission
|
|
|
41 |
WHERE ci.ce_observation = co.id_observation
|
|
|
42 |
AND (ci.ce_observation IS NOT NULL OR ci.ce_observation != 0);
|
2435 |
jpm |
43 |
COMMIT;
|
2418 |
jpm |
44 |
|
2427 |
jpm |
45 |
-- Suppression de la table cel_obs_image inutile
|
2435 |
jpm |
46 |
RENAME TABLE cel_obs_images TO cel_obs_images_obsolete;
|
2428 |
jpm |
47 |
|
|
|
48 |
-- -----------------------------------------------------
|
2476 |
jpm |
49 |
|
|
|
50 |
-- Champs ce_utilisateur de cel_obs peut être NULL
|
|
|
51 |
ALTER TABLE cel_obs CHANGE ce_utilisateur ce_utilisateur VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL;
|
|
|
52 |
|
|
|
53 |
-- Suppression index id_obs
|
|
|
54 |
ALTER TABLE cel_obs DROP INDEX id_obs;
|
|
|
55 |
|
|
|
56 |
-- Correction du champ ce_utilisateur pour la table cel_images
|
2494 |
jpm |
57 |
START TRANSACTION;
|
2485 |
jpm |
58 |
UPDATE cel_obs SET ce_utilisateur = NULL
|
|
|
59 |
WHERE ce_utilisateur LIKE '%@%' OR ce_utilisateur = '';
|
2494 |
jpm |
60 |
COMMIT;
|
2476 |
jpm |
61 |
|
|
|
62 |
-- Correction index id_obs
|
|
|
63 |
CREATE UNIQUE INDEX id_obs ON cel_obs (ordre, ce_utilisateur, courriel_utilisateur);
|
|
|
64 |
|
|
|
65 |
-- Correction index date_creation
|
|
|
66 |
ALTER TABLE cel_obs DROP INDEX date_creation;
|
|
|
67 |
CREATE INDEX utilisateur_date_creation ON cel_obs (ce_utilisateur, date_creation, id_observation);
|
|
|
68 |
|
|
|
69 |
-- -----------------------------------------------------
|
2485 |
jpm |
70 |
-- CORRECTIONS des CHAMPS ce_utilisateur & INDEX
|
2476 |
jpm |
71 |
|
|
|
72 |
-- Correction données en erreurs (bloque la génération des index)
|
|
|
73 |
START TRANSACTION;
|
|
|
74 |
SET @ordre = 1;
|
|
|
75 |
UPDATE cel_images SET ordre = @ordre := @ordre+1
|
|
|
76 |
WHERE ce_utilisateur = 20207 AND courriel_utilisateur = 'jardin-de-claire@orange.fr';
|
|
|
77 |
COMMIT;
|
|
|
78 |
|
|
|
79 |
START TRANSACTION;
|
|
|
80 |
SET @ordre = 1;
|
|
|
81 |
UPDATE cel_images SET ordre = @ordre := @ordre+1
|
|
|
82 |
WHERE ce_utilisateur = 16501 AND courriel_utilisateur = 'alexis.joly@inria.fr';
|
|
|
83 |
COMMIT;
|
|
|
84 |
|
|
|
85 |
START TRANSACTION;
|
|
|
86 |
SET @ordre = 1;
|
|
|
87 |
UPDATE cel_images SET ordre = @ordre := @ordre+1
|
|
|
88 |
WHERE ce_utilisateur = 10261 AND courriel_utilisateur = 'kti-moreau@orange.fr';
|
|
|
89 |
COMMIT;
|
|
|
90 |
|
|
|
91 |
START TRANSACTION;
|
|
|
92 |
SET @ordre = 1;
|
|
|
93 |
UPDATE cel_images SET ordre = @ordre := @ordre+1
|
|
|
94 |
WHERE ce_utilisateur = 18989 AND courriel_utilisateur = 'laetitia.goeau@free.fr';
|
|
|
95 |
COMMIT;
|
|
|
96 |
|
|
|
97 |
START TRANSACTION;
|
|
|
98 |
SET @ordre = 1;
|
|
|
99 |
UPDATE cel_images SET ordre = @ordre := @ordre+1
|
|
|
100 |
WHERE ce_utilisateur = 20667 AND courriel_utilisateur = 'catalina20@hotmail.fr';
|
|
|
101 |
COMMIT;
|
|
|
102 |
|
|
|
103 |
START TRANSACTION;
|
|
|
104 |
SET @ordre = 1;
|
|
|
105 |
UPDATE cel_images SET ordre = @ordre := @ordre+1
|
|
|
106 |
WHERE ce_utilisateur = 11785 AND courriel_utilisateur = 'pierre.bonnet@cirad.fr';
|
|
|
107 |
COMMIT;
|
|
|
108 |
|
|
|
109 |
-- Champ ce_utilisateur de cel_images peut être NULL
|
|
|
110 |
ALTER TABLE cel_images CHANGE ce_utilisateur ce_utilisateur VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL;
|
|
|
111 |
|
|
|
112 |
-- Correction index id_image
|
|
|
113 |
ALTER TABLE cel_images DROP INDEX id_image;
|
|
|
114 |
|
|
|
115 |
-- Correction du champ ce_utilisateur pour la table cel_images
|
|
|
116 |
START TRANSACTION;
|
|
|
117 |
UPDATE cel_images SET ce_utilisateur = NULL
|
|
|
118 |
WHERE ce_utilisateur LIKE '%@%' OR ce_utilisateur = '';
|
|
|
119 |
COMMIT;
|
|
|
120 |
|
|
|
121 |
-- Correction index id_image
|
|
|
122 |
CREATE UNIQUE INDEX id_img ON cel_images (ordre, ce_utilisateur, courriel_utilisateur);
|
|
|
123 |
|
|
|
124 |
-- Correction index ce_utilisateur_2
|
|
|
125 |
ALTER TABLE cel_images DROP INDEX ce_utilisateur_2;
|
|
|
126 |
CREATE INDEX utilisateur_date_creation ON cel_images (ce_utilisateur, date_creation, id_image);
|
|
|
127 |
|
|
|
128 |
-- Correction du champ date_modification dans la table cel_images
|
|
|
129 |
START TRANSACTION;
|
2494 |
jpm |
130 |
UPDATE cel_images
|
|
|
131 |
SET date_modification = GREATEST(
|
2476 |
jpm |
132 |
IFNULL(date_creation, '0000-00-00 00:00:00'),
|
|
|
133 |
IFNULL(date_transmission, '0000-00-00 00:00:00'),
|
|
|
134 |
IFNULL(date_modification, '0000-00-00 00:00:00'),
|
|
|
135 |
IFNULL(date_liaison, '0000-00-00 00:00:00')
|
|
|
136 |
);
|
|
|
137 |
COMMIT;
|
|
|
138 |
|
|
|
139 |
-- Correction du champ date_modification dans la table cel_obs
|
|
|
140 |
START TRANSACTION;
|
|
|
141 |
UPDATE cel_obs AS co, cel_images AS ci
|
|
|
142 |
SET co.date_modification = GREATEST(
|
|
|
143 |
IFNULL(co.date_creation, '0000-00-00 00:00:00'),
|
|
|
144 |
IFNULL(co.date_transmission, '0000-00-00 00:00:00'),
|
|
|
145 |
IFNULL(co.date_modification, '0000-00-00 00:00:00'),
|
|
|
146 |
IFNULL(ci.date_liaison, '0000-00-00 00:00:00')
|
2485 |
jpm |
147 |
)
|
2476 |
jpm |
148 |
WHERE co.id_observation = ci.ce_observation ;
|
|
|
149 |
COMMIT;
|
2485 |
jpm |
150 |
|
2476 |
jpm |
151 |
-- -----------------------------------------------------
|
2485 |
jpm |
152 |
-- CORRECTIONS des DATES
|
|
|
153 |
|
|
|
154 |
ALTER TABLE cel_obs CHANGE date_creation date_creation DATETIME NOT NULL;
|
|
|
155 |
|
|
|
156 |
ALTER TABLE cel_obs CHANGE date_modification date_modification DATETIME NOT NULL;
|
|
|
157 |
|
|
|
158 |
START TRANSACTION;
|
|
|
159 |
UPDATE cel_obs AS co, cel_images AS ci
|
|
|
160 |
SET co.date_creation = LEAST(
|
|
|
161 |
IFNULL(co.date_modification, '0000-00-00 00:00:00'),
|
|
|
162 |
IFNULL(co.date_transmission, '0000-00-00 00:00:00'),
|
|
|
163 |
IFNULL(ci.date_creation, '0000-00-00 00:00:00'),
|
|
|
164 |
IFNULL(ci.date_modification, '0000-00-00 00:00:00'),
|
|
|
165 |
IFNULL(ci.date_transmission, '0000-00-00 00:00:00'),
|
|
|
166 |
IFNULL(ci.date_liaison, '0000-00-00 00:00:00')
|
|
|
167 |
)
|
|
|
168 |
WHERE co.id_observation = ci.ce_observation
|
|
|
169 |
AND co.date_creation = '0000-00-00 00:00:00' OR co.date_creation = NULL;
|
|
|
170 |
COMMIT;
|
|
|
171 |
|
|
|
172 |
START TRANSACTION;
|
|
|
173 |
UPDATE cel_images
|
|
|
174 |
SET date_creation = LEAST(
|
|
|
175 |
IFNULL(date_modification, '0000-00-00 00:00:00'),
|
|
|
176 |
IFNULL(date_transmission, '0000-00-00 00:00:00'),
|
|
|
177 |
IFNULL(date_liaison, '0000-00-00 00:00:00')
|
|
|
178 |
)
|
|
|
179 |
WHERE date_creation = '0000-00-00 00:00:00' OR date_creation = NULL;
|
|
|
180 |
COMMIT;
|
|
|
181 |
|
|
|
182 |
START TRANSACTION;
|
|
|
183 |
UPDATE cel_images AS ci, cel_obs AS co
|
|
|
184 |
SET ci.date_creation = LEAST(
|
|
|
185 |
IFNULL(ci.date_modification, '0000-00-00 00:00:00'),
|
|
|
186 |
IFNULL(ci.date_transmission, '0000-00-00 00:00:00'),
|
|
|
187 |
IFNULL(ci.date_liaison, '0000-00-00 00:00:00'),
|
|
|
188 |
IFNULL(co.date_creation, '0000-00-00 00:00:00'),
|
|
|
189 |
IFNULL(co.date_modification, '0000-00-00 00:00:00'),
|
|
|
190 |
IFNULL(co.date_transmission, '0000-00-00 00:00:00')
|
|
|
191 |
)
|
|
|
192 |
WHERE ci.ce_observation = co.id_observation
|
|
|
193 |
AND ci.date_creation = '0000-00-00 00:00:00' OR ci.date_creation = NULL;
|
|
|
194 |
COMMIT;
|
|
|
195 |
|
|
|
196 |
-- -----------------------------------------------------
|
2428 |
jpm |
197 |
SET SQL_MODE=@OLD_SQL_MODE;
|
|
|
198 |
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
2466 |
aurelien |
199 |
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|