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