Commit 64904ba28ddb5038f6b26e5e34a36638d0a35e68
1 parent
7511858e
Exists in
master
and in
3 other branches
script de mise à jour de la BD de l'IRAP pour la v2.6
Showing
2 changed files
with
332 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,37 @@ |
1 | +#!/bin/bash | |
2 | + | |
3 | +myname=`basename $0 .sh` | |
4 | + | |
5 | +# Pour Mac OS recent (10.10, Yosemite), la syntaxe du SED est differente | |
6 | +# Il faut donc faire une copie de ce fichier et transformer les instructions sed a l'interieur | |
7 | +# Pour cela, il suffit d'executer ces 2 lignes : | |
8 | +# cp ce_script.sh ce_script_macosx.sh | |
9 | +# sed -e "s/ -i / -i '' /" -i '' ce_script_macosx.sh | |
10 | + | |
11 | +if [ ! -f ../../config/app.php ] ; then | |
12 | +echo "Vous devez executer ce script depuis le dossier database/update/" | |
13 | +exit 1 | |
14 | +fi | |
15 | + | |
16 | + | |
17 | +# Get login, pass, dbname, and hostname | |
18 | +username=$(grep "/\*d\*/'username'" ../../config/app.php | cut -d"'" -f4) | |
19 | +password=$(grep "/\*d\*/'password'" ../../config/app.php | cut -d"'" -f4) | |
20 | +database=$(grep "/\*d\*/'database'" ../../config/app.php | cut -d"'" -f4) | |
21 | +host=$(grep "/\*d\*/'host'" ../../config/app.php | cut -d"'" -f4) | |
22 | + | |
23 | + | |
24 | +#cp -p ./script_sql/db-update-2016-07-01-irap.sql ./script_sql/db-update-2016-07-01-irap-build.sql | |
25 | +cp -p ./script_sql/$myname.sql ./script_sql/$myname-build.sql | |
26 | + | |
27 | +# Execute sql update script | |
28 | +sed -e "s/database/$database/" -i ./script_sql/$myname-build.sql | |
29 | +mysql --user=$username --password=$password -h $host < ./script_sql/$myname-build.sql | |
30 | + | |
31 | +# Delete cakephp cache | |
32 | +sudo rm ../../tmp/cache/models/* | |
33 | +sudo rm ../../tmp/cache/persistent/* | |
34 | + | |
35 | +sudo chmod -R 777 ../../tmp | |
36 | +sudo chmod -R 777 ../../vendor | |
37 | +sudo chmod -R 777 ../../webroot | ... | ... |
database/update/script_sql/db-update-2017-06-13-irap-only.sql
0 → 100644
... | ... | @@ -0,0 +1,295 @@ |
1 | +use database; | |
2 | + | |
3 | +set foreign_key_checks=0; | |
4 | + | |
5 | +ALTER TABLE `configurations` ADD `aff_par_defaut` SMALLINT NOT NULL DEFAULT '20'; | |
6 | + | |
7 | +ALTER TABLE `materiels` ADD `nom_gestionnaire` VARCHAR( 45 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL AFTER `email_responsable` ; | |
8 | + | |
9 | +ALTER TABLE `configurations` CHANGE `envoi_mail_management_dev` `envoi_mail` TINYINT( 1 ) NOT NULL DEFAULT '0'; | |
10 | + | |
11 | + | |
12 | +-- ------------------------------------------------------------------------------------------------------------- | |
13 | +-- 05/06/2017 | |
14 | +-- MODIF FOURNISSEURS (id au lieu de nom, avec recup de l existant) | |
15 | +-- | |
16 | + | |
17 | +CREATE TABLE IF NOT EXISTS `fournisseurs` ( | |
18 | + `id` INT NOT NULL AUTO_INCREMENT, | |
19 | + `nom` VARCHAR(45) NULL, | |
20 | + unique(nom), | |
21 | + PRIMARY KEY (`id`)); | |
22 | + | |
23 | +insert into fournisseurs (nom) | |
24 | +select distinct fournisseur from materiels | |
25 | +where fournisseur != '' | |
26 | +ORDER BY `materiels`.`fournisseur` ASC; | |
27 | + | |
28 | +alter table materiels | |
29 | +add column fournisseur_id INT NULL DEFAULT NULL; | |
30 | + | |
31 | +update materiels | |
32 | +set fournisseur_id = (select id from fournisseurs where nom = materiels.fournisseur); | |
33 | + | |
34 | +alter table materiels | |
35 | +drop column fournisseur; | |
36 | + | |
37 | + | |
38 | +-- ------------------------------------------------------------------------------------------------------------- | |
39 | +-- 23/05/2017 | |
40 | +-- MODIF TABLE CONFIGURATIONS | |
41 | +-- Structure de la table `configurations` | |
42 | +-- | |
43 | + | |
44 | +ALTER TABLE `configurations` | |
45 | +ADD COLUMN `metrologie` TINYINT(1) NULL DEFAULT '0' AFTER `taille_max_doc`; | |
46 | + | |
47 | +-- ------------------------------------------------------------------------------------------------------------- | |
48 | +-- 23/05/2017 | |
49 | +-- MODIF TABLE MATERIELS | |
50 | +-- Structure de la table `materiels` | |
51 | +-- | |
52 | + | |
53 | +ALTER TABLE `materiels` | |
54 | +ADD COLUMN `metrologie` TINYINT(1) NULL DEFAULT '0' AFTER `photo_id`; | |
55 | + | |
56 | +-- ------------------------------------------------------------------------------------------------------------- | |
57 | +-- 23/05/2017 | |
58 | +-- AJOUT TABLE UNITES | |
59 | +-- Structure de la table `unites` | |
60 | +-- | |
61 | + | |
62 | +CREATE TABLE IF NOT EXISTS `unites` ( | |
63 | + `id` INT NOT NULL AUTO_INCREMENT, | |
64 | + `nom` VARCHAR(45) NULL, | |
65 | + `symbole` VARCHAR(45) NULL, | |
66 | + PRIMARY KEY (`id`)); | |
67 | + | |
68 | +-- ------------------------------------------------------------------------------------------------------------- | |
69 | +-- 23/05/2017 | |
70 | +-- AJOUT TABLE MESURES | |
71 | +-- Structure de la table `mesures` | |
72 | +-- | |
73 | + | |
74 | +CREATE TABLE IF NOT EXISTS `mesures` ( | |
75 | + `id` INT NOT NULL AUTO_INCREMENT, | |
76 | + `fichemetrologique_id` INT NOT NULL, | |
77 | + `valeur` DOUBLE NULL, | |
78 | + `erreur` DOUBLE NULL, | |
79 | + PRIMARY KEY (`id`)); | |
80 | + | |
81 | +-- ------------------------------------------------------------------------------------------------------------- | |
82 | +-- 23/05/2017 | |
83 | +-- AJOUT TABLE FORMULES | |
84 | +-- Structure de la table `formules` | |
85 | +-- | |
86 | + | |
87 | +CREATE TABLE IF NOT EXISTS `formules` ( | |
88 | + `id` INT NOT NULL AUTO_INCREMENT, | |
89 | + `nommesure` VARCHAR(100) NULL DEFAULT NULL, | |
90 | + `symbole` VARCHAR(45) NULL DEFAULT 'F', | |
91 | + `unite` VARCHAR(45) NULL DEFAULT NULL, | |
92 | + `nbVariable` INT(11) NULL DEFAULT NULL, | |
93 | + `formule` VARCHAR(200) NULL DEFAULT 'F', | |
94 | + PRIMARY KEY (`id`)); | |
95 | + | |
96 | +-- ------------------------------------------------------------------------------------------------------------- | |
97 | +-- 23/05/2017 | |
98 | +-- AJOUT TABLE VARIABLES | |
99 | +-- Structure de la table `variables` | |
100 | +-- | |
101 | + | |
102 | +CREATE TABLE IF NOT EXISTS `variables` ( | |
103 | + `id` INT(11) NOT NULL AUTO_INCREMENT, | |
104 | + `formule_id` INT(11) NULL DEFAULT NULL, | |
105 | + `symbolegrandeurphysique` VARCHAR(45) NULL DEFAULT NULL, | |
106 | + `symboleunitemesure` VARCHAR(45) NULL DEFAULT NULL, | |
107 | + `nomgrandeurphysique` VARCHAR(45) NULL DEFAULT NULL, | |
108 | + `domainedef` VARCHAR(45) NULL DEFAULT NULL, | |
109 | + `derivepartielle` VARCHAR(100) NULL DEFAULT 'F', | |
110 | + PRIMARY KEY (`id`)); | |
111 | + | |
112 | +-- ------------------------------------------------------------------------------------------------------------- | |
113 | +-- 23/05/2017 | |
114 | +-- MODIF TABLE USERS | |
115 | +-- Structure de la table `users` | |
116 | +-- | |
117 | + | |
118 | +ALTER TABLE `users` | |
119 | +ADD COLUMN `sur_categorie_id` INT(11) NULL AFTER `groupe_thematique_id`; | |
120 | + | |
121 | +-- ------------------------------------------------------------------------------------------------------------- | |
122 | +-- 23/05/2017 | |
123 | +-- AJOUT TABLE FICHEMETROLOGIQUES | |
124 | +-- Structure de la table `fichemetrologiques` | |
125 | +-- | |
126 | + | |
127 | +CREATE TABLE IF NOT EXISTS `fichemetrologiques` ( | |
128 | + `id` int(11) NOT NULL AUTO_INCREMENT, | |
129 | + `suivi_id` int(11) NOT NULL, | |
130 | + `mesurande` double DEFAULT NULL, | |
131 | + `moyenne` double DEFAULT NULL, | |
132 | + `ecarttype` double DEFAULT NULL, | |
133 | + `correction` double DEFAULT NULL, | |
134 | + `ua` double DEFAULT NULL, | |
135 | + `ub` double DEFAULT NULL, | |
136 | + `uc` double DEFAULT NULL, | |
137 | + `uf` double DEFAULT NULL, | |
138 | + `u` double DEFAULT NULL, | |
139 | + `incertitude` double DEFAULT NULL, | |
140 | + `conditionEnv` double DEFAULT NULL, | |
141 | + `resolution` varchar(45) DEFAULT NULL, | |
142 | + `etatmateriel` varchar(45) DEFAULT NULL, | |
143 | + `etatmetrologique` varchar(45) DEFAULT NULL, | |
144 | + `emtpersonnel` double DEFAULT NULL, | |
145 | + `nbMesure` int(11) DEFAULT NULL, | |
146 | + `conformeEMTstandart` varchar(100) DEFAULT NULL, | |
147 | + `conformeEMTperso` varchar(100) DEFAULT NULL, | |
148 | + `resultatfinal` varchar(100) DEFAULT NULL, | |
149 | + `observation` varchar(200) DEFAULT NULL, | |
150 | + `datefiche` date DEFAULT NULL, | |
151 | + `retard` varchar(45) DEFAULT 'RAS', | |
152 | + `justesse` double DEFAULT NULL, | |
153 | + PRIMARY KEY (`id`) | |
154 | +); | |
155 | + | |
156 | + | |
157 | +-- ------------------------------------------------------------------------------------------------------------- | |
158 | +-- 23/05/2017 | |
159 | +-- MODIF TABLE SUIVIS | |
160 | +-- Structure de la table `suivis` | |
161 | +-- | |
162 | + | |
163 | +ALTER TABLE `suivis` | |
164 | +ADD COLUMN `unite_id` INT(11) NULL DEFAULT NULL AFTER `modified`, | |
165 | +ADD COLUMN `plage_debut` DOUBLE NULL DEFAULT NULL AFTER `unite_id`, | |
166 | +ADD COLUMN `plage_fin` DOUBLE NULL DEFAULT NULL AFTER `plage_debut`, | |
167 | +ADD COLUMN `resolution` DOUBLE NULL DEFAULT NULL AFTER `plage_fin`, | |
168 | +ADD COLUMN `tolerance` DOUBLE NULL DEFAULT NULL AFTER `resolution`, | |
169 | +ADD COLUMN `sensibilite` DOUBLE NULL DEFAULT NULL AFTER `tolerance`, | |
170 | +ADD COLUMN `justesse` DOUBLE NULL DEFAULT NULL AFTER `sensibilite`, | |
171 | +ADD COLUMN `fidelite` DOUBLE NULL DEFAULT NULL AFTER `justesse`, | |
172 | +ADD COLUMN `typemesure` VARCHAR(45) NULL DEFAULT 'Direct' AFTER `fidelite`, | |
173 | +ADD COLUMN `emtstandart` DOUBLE NULL DEFAULT NULL AFTER `typemesure`, | |
174 | +ADD COLUMN `symbole` VARCHAR(45) NULL DEFAULT NULL AFTER `emtstandart`, | |
175 | +ADD COLUMN `nommesure` VARCHAR(45) NULL DEFAULT NULL AFTER `symbole`, | |
176 | +ADD COLUMN `valeurRef` DOUBLE NULL DEFAULT NULL AFTER `nommesure`, | |
177 | +ADD COLUMN `intitule` VARCHAR(100) NULL DEFAULT NULL AFTER `valeurRef`, | |
178 | +ADD COLUMN `conforme` VARCHAR(100) NULL DEFAULT NULL AFTER `intitule`, | |
179 | +ADD COLUMN `formule_id` INT(11) NULL DEFAULT NULL AFTER `conforme`; | |
180 | + | |
181 | +-- ------------------------------------------------------------------------------------------------------------- | |
182 | +-- 23/05/2017 | |
183 | +-- AJOUT LIAISON SUIVIS-UNITES | |
184 | +-- | |
185 | +-- | |
186 | + | |
187 | +ALTER TABLE `suivis` | |
188 | +ADD INDEX `fk_suivis_unite_id_idx` (`unite_id` ASC); | |
189 | +ALTER TABLE `suivis` | |
190 | +ADD CONSTRAINT `fk_suivis_unite_id` | |
191 | + FOREIGN KEY (`unite_id`) | |
192 | + REFERENCES `unites` (`id`) | |
193 | + ON DELETE NO ACTION | |
194 | + ON UPDATE NO ACTION; | |
195 | + | |
196 | +-- ------------------------------------------------------------------------------------------------------------- | |
197 | +-- 23/05/2017 | |
198 | +-- AJOUT LIAISON FOURNISSEURS-MATERIELS | |
199 | +-- | |
200 | +-- | |
201 | + ALTER TABLE `materiels` | |
202 | +ADD CONSTRAINT `fk_materiels_fournisseurs_id` | |
203 | + FOREIGN KEY (`fournisseur_id`) | |
204 | + REFERENCES `fournisseurs` (`id`) | |
205 | + ON DELETE NO ACTION | |
206 | + ON UPDATE NO ACTION, | |
207 | +ADD INDEX `fk_materiels_fournisseurs_id_idx` (`fournisseur_id` ASC); | |
208 | + | |
209 | + | |
210 | +-- ------------------------------------------------------------------------------------------------------------- | |
211 | +-- 23/05/2017 | |
212 | +-- AJOUT LIAISON VARIABLES-FORMULES | |
213 | +-- | |
214 | +-- | |
215 | + | |
216 | + ALTER TABLE `variables` | |
217 | +ADD INDEX `fk_variables_formule_id_idx` (`formule_id` ASC); | |
218 | +ALTER TABLE `variables` | |
219 | +ADD CONSTRAINT `fk_variables_formule_id` | |
220 | + FOREIGN KEY (`formule_id`) | |
221 | + REFERENCES `formules` (`id`) | |
222 | + ON DELETE NO ACTION | |
223 | + ON UPDATE NO ACTION; | |
224 | + | |
225 | + | |
226 | +-- ------------------------------------------------------------------------------------------------------------- | |
227 | +-- 23/05/2017 | |
228 | +-- AJOUT LIAISON MESURES-FICHEMETROLOGIQUES | |
229 | +-- | |
230 | +-- | |
231 | + | |
232 | +ALTER TABLE `mesures` | |
233 | +ADD INDEX `fk_mesures_fichemetrologique_id_idx` (`fichemetrologique_id` ASC); | |
234 | +ALTER TABLE `mesures` | |
235 | +ADD CONSTRAINT `fk_mesures_fichemetrologique_id` | |
236 | + FOREIGN KEY (`fichemetrologique_id`) | |
237 | + REFERENCES `fichemetrologiques` (`id`) | |
238 | + ON DELETE NO ACTION | |
239 | + ON UPDATE NO ACTION; | |
240 | + | |
241 | + | |
242 | +-- ------------------------------------------------------------------------------------------------------------- | |
243 | +-- 23/05/2017 | |
244 | +-- AJOUT LIAISON SUR_CATEGORIES-USERS | |
245 | +-- | |
246 | +-- | |
247 | + | |
248 | +ALTER TABLE `users` | |
249 | +ADD INDEX `fk_users_sur_categories_id_idx` (`sur_categorie_id` ASC); | |
250 | +ALTER TABLE `users` | |
251 | +ADD CONSTRAINT `fk_users_sur_categories_id` | |
252 | + FOREIGN KEY (`sur_categorie_id`) | |
253 | + REFERENCES `sur_categories` (`id`) | |
254 | + ON DELETE NO ACTION | |
255 | + ON UPDATE NO ACTION; | |
256 | + | |
257 | + | |
258 | +-- ------------------------------------------------------------------------------------------------------------- | |
259 | +-- 23/05/2017 | |
260 | +-- AJOUT LIAISON FICHEMETROLOGIQUES-SUIVIS | |
261 | +-- | |
262 | +-- | |
263 | + | |
264 | +ALTER TABLE `fichemetrologiques` | |
265 | +ADD INDEX `fk_fichemetrologique_suivi_id_idx` (`suivi_id` ASC); | |
266 | +ALTER TABLE `fichemetrologiques` | |
267 | +ADD CONSTRAINT `fk_fichemetrologique_suivi_id` | |
268 | + FOREIGN KEY (`suivi_id`) | |
269 | + REFERENCES `suivis` (`id`) | |
270 | + ON DELETE NO ACTION | |
271 | + ON UPDATE NO ACTION; | |
272 | + | |
273 | + | |
274 | +-- ------------------------------------------------------------------------------------------------------------- | |
275 | +-- 23/05/2017 | |
276 | +-- AJOUT LIAISON SUIVIS-FORMULES | |
277 | +-- | |
278 | +-- | |
279 | + | |
280 | +ALTER TABLE `suivis` | |
281 | +ADD INDEX `fk_suivis_formule_id_idx` (`formule_id` ASC); | |
282 | +ALTER TABLE `suivis` | |
283 | +ADD CONSTRAINT `fk_suivis_formule_id` | |
284 | + FOREIGN KEY (`formule_id`) | |
285 | + REFERENCES `formules` (`id`) | |
286 | + ON DELETE NO ACTION | |
287 | + ON UPDATE NO ACTION; | |
288 | + | |
289 | + | |
290 | + | |
291 | +ALTER TABLE `configurations` ADD `envoi_mail_guests` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `envoi_mail` ; | |
292 | + | |
293 | +ALTER TABLE `materiels` CHANGE `nom_gestionnaire` `gestionnaire_id` INT( 11 ) NULL ; | |
294 | + | |
295 | +ALTER TABLE `configurations` ADD `procedure_sur_accueil` TINYINT( 1 ) NOT NULL DEFAULT '1'; | |
0 | 296 | \ No newline at end of file | ... | ... |