Commit c07880fc4478eefccd1e59c3f05242208c235da6
1 parent
36dfd311
Exists in
master
and in
3 other branches
Modification BDD LATMOS
Showing
2 changed files
with
240 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +#!/bin/bash | ||
2 | + | ||
3 | +# Pour Mac OS recent (10.10, Yosemite), la syntaxe du SED est differente | ||
4 | +# Il faut donc faire une copie de ce fichier et transformer les instructions sed a l'interieur | ||
5 | +# Pour cela, il suffit d'executer ces 2 lignes : | ||
6 | +# cp ce_script.sh ce_script_macosx.sh | ||
7 | +# sed -e "s/ -i / -i '' /" -i '' ce_script_macosx.sh | ||
8 | + | ||
9 | +if [ ! -f ../../config/app.php ] ; then | ||
10 | +echo "Vous devez executer ce script depuis le dossier database/update/" | ||
11 | +exit 1 | ||
12 | +fi | ||
13 | + | ||
14 | + | ||
15 | +# Get login, pass, dbname, and hostname | ||
16 | +username=$(grep "/\*d\*/'username'" ../../config/app.php | cut -d"'" -f4) | ||
17 | +password=$(grep "/\*d\*/'password'" ../../config/app.php | cut -d"'" -f4) | ||
18 | +database=$(grep "/\*d\*/'database'" ../../config/app.php | cut -d"'" -f4) | ||
19 | +host=$(grep "/\*d\*/'host'" ../../config/app.php | cut -d"'" -f4) | ||
20 | + | ||
21 | + | ||
22 | +cp -p ./script_sql/db-update-2017-05-23.sql ./script_sql/db-update-2017-05-23-build.sql | ||
23 | + | ||
24 | +# Execute sql update script | ||
25 | +sed -e "s/database/$database/" -i ./script_sql/db-update-2017-05-23-build.sql | ||
26 | +mysql --user=$username --password=$password -h $host < ./script_sql/db-update-2017-05-23-build.sql | ||
27 | + | ||
28 | +# Delete cakephp cache | ||
29 | +sudo rm ../../tmp/cache/models/* | ||
30 | +sudo rm ../../tmp/cache/persistent/* | ||
31 | + | ||
32 | +sudo chmod -R 777 ../../tmp | ||
33 | +sudo chmod -R 777 ../../vendor | ||
34 | +sudo chmod -R 777 ../../webroot |
@@ -0,0 +1,206 @@ | @@ -0,0 +1,206 @@ | ||
1 | +USE database; | ||
2 | + | ||
3 | +-- ------------------------------------------------------------------------------------------------------------- | ||
4 | +-- 23/05/2017 | ||
5 | +-- MODIF TABLE CONFIGURATIONS | ||
6 | +-- Structure de la table `configurations` | ||
7 | +-- | ||
8 | + | ||
9 | +ALTER TABLE `configurations` ADD COLUMN `metrologie` TINYINT(1) NULL DEFAULT '0' AFTER `taille_max_doc`; | ||
10 | + | ||
11 | +-- ------------------------------------------------------------------------------------------------------------- | ||
12 | +-- 23/05/2017 | ||
13 | +-- MODIF TABLE MATERIELS | ||
14 | +-- Structure de la table `materiels` | ||
15 | +-- | ||
16 | + | ||
17 | +ALTER TABLE `materiels` | ||
18 | +CHANGE COLUMN `fournisseur` `fournisseur_id` INT NULL DEFAULT NULL , | ||
19 | +ADD COLUMN `metrologie` TINYINT(1) NULL DEFAULT '0' AFTER `photo_id`; | ||
20 | + | ||
21 | +-- ------------------------------------------------------------------------------------------------------------- | ||
22 | +-- 23/05/2017 | ||
23 | +-- AJOUT TABLE FOURNISSEURS | ||
24 | +-- Structure de la table `fournisseurs` | ||
25 | +-- | ||
26 | + | ||
27 | +CREATE TABLE `fournisseurs` ( | ||
28 | + `id` INT NOT NULL AUTO_INCREMENT, | ||
29 | + `nom` VARCHAR(45) NULL, | ||
30 | + PRIMARY KEY (`id`)); | ||
31 | + | ||
32 | +-- ------------------------------------------------------------------------------------------------------------- | ||
33 | +-- 23/05/2017 | ||
34 | +-- AJOUT TABLE UNITES | ||
35 | +-- Structure de la table `unites` | ||
36 | +-- | ||
37 | + | ||
38 | +CREATE TABLE `unites` ( | ||
39 | + `id` INT NOT NULL AUTO_INCREMENT, | ||
40 | + `nom` VARCHAR(45) NULL, | ||
41 | + `symbole` VARCHAR(45) NULL, | ||
42 | + PRIMARY KEY (`id`)); | ||
43 | + | ||
44 | + | ||
45 | +-- ------------------------------------------------------------------------------------------------------------- | ||
46 | +-- 23/05/2017 | ||
47 | +-- AJOUT TABLE MESURES | ||
48 | +-- Structure de la table `mesures` | ||
49 | +-- | ||
50 | + | ||
51 | + | ||
52 | +CREATE TABLE `mesures` ( | ||
53 | + `id` INT NOT NULL AUTO_INCREMENT, | ||
54 | + `fichemetrologique_id` INT NOT NULL, | ||
55 | + `valeur` DOUBLE NULL, | ||
56 | + `erreur` DOUBLE NULL, | ||
57 | + PRIMARY KEY (`id`)); | ||
58 | + | ||
59 | + | ||
60 | +-- ------------------------------------------------------------------------------------------------------------- | ||
61 | +-- 23/05/2017 | ||
62 | +-- MODIF TABLE USERS | ||
63 | +-- Structure de la table `users` | ||
64 | +-- | ||
65 | + | ||
66 | +ALTER TABLE `users` | ||
67 | +ADD COLUMN `sur_categorie_id` INT(11) NULL AFTER `groupe_thematique_id`; | ||
68 | + | ||
69 | +-- ------------------------------------------------------------------------------------------------------------- | ||
70 | +-- 23/05/2017 | ||
71 | +-- AJOUT TABLE FICHEMETROLOGIQUES | ||
72 | +-- Structure de la table `fichemetrologiques` | ||
73 | +-- | ||
74 | + | ||
75 | +CREATE TABLE `fichemetrologiques` ( | ||
76 | + `id` int(11) NOT NULL AUTO_INCREMENT, | ||
77 | + `suivi_id` int(11) NOT NULL, | ||
78 | + `mesurande` double DEFAULT NULL, | ||
79 | + `moyenne` double DEFAULT NULL, | ||
80 | + `ecarttype` double DEFAULT NULL, | ||
81 | + `correction` double DEFAULT NULL, | ||
82 | + `ua` double DEFAULT NULL, | ||
83 | + `ub` double DEFAULT NULL, | ||
84 | + `uc` double DEFAULT NULL, | ||
85 | + `uf` double DEFAULT NULL, | ||
86 | + `u` double DEFAULT NULL, | ||
87 | + `incertitude` double DEFAULT NULL, | ||
88 | + `conditionEnv` double DEFAULT NULL, | ||
89 | + `resolution` varchar(45) DEFAULT NULL, | ||
90 | + `etatmateriel` varchar(45) DEFAULT NULL, | ||
91 | + `etatmetrologique` varchar(45) DEFAULT NULL, | ||
92 | + `emtpersonnel` double DEFAULT NULL, | ||
93 | + `nbMesure` int(11) DEFAULT NULL, | ||
94 | + `conformeEMTstandart` varchar(100) DEFAULT NULL, | ||
95 | + `conformeEMTperso` varchar(100) DEFAULT NULL, | ||
96 | + `resultatfinal` varchar(100) DEFAULT NULL, | ||
97 | + `observation` varchar(200) DEFAULT NULL, | ||
98 | + `datefiche` date DEFAULT NULL, | ||
99 | + `retard` varchar(45) DEFAULT 'RAS', | ||
100 | + `justesse` DOUBLE DEFAULT NULL, | ||
101 | + PRIMARY KEY (`id`) | ||
102 | +) ENGINE=InnoDB AUTO_INCREMENT=142 DEFAULT CHARSET=latin1 | ||
103 | + | ||
104 | + | ||
105 | +-- ------------------------------------------------------------------------------------------------------------- | ||
106 | +-- 23/05/2017 | ||
107 | +-- MODIF TABLE SUIVIS | ||
108 | +-- Structure de la table `suivis` | ||
109 | +-- | ||
110 | + | ||
111 | +ALTER TABLE `suivis` | ||
112 | +ADD COLUMN `unite_id` INT(11) NULL DEFAULT NULL AFTER `modified`, | ||
113 | +ADD COLUMN `plage_debut` DOUBLE NULL DEFAULT NULL AFTER `unite_id`, | ||
114 | +ADD COLUMN `plage_fin` DOUBLE NULL DEFAULT NULL AFTER `plage_debut`, | ||
115 | +ADD COLUMN `resolution` DOUBLE NULL DEFAULT NULL AFTER `plage_fin`, | ||
116 | +ADD COLUMN `tolerance` DOUBLE NULL DEFAULT NULL AFTER `resolution`, | ||
117 | +ADD COLUMN `sensibilite` DOUBLE NULL DEFAULT NULL AFTER `tolerance`, | ||
118 | +ADD COLUMN `justesse` DOUBLE NULL DEFAULT NULL AFTER `sensibilite`, | ||
119 | +ADD COLUMN `fidelite` DOUBLE NULL DEFAULT NULL AFTER `justesse`, | ||
120 | +ADD COLUMN `typemesure` VARCHAR(45) NULL DEFAULT 'Direct' AFTER `fidelite`, | ||
121 | +ADD COLUMN `emtstandart` DOUBLE NULL DEFAULT NULL AFTER `typemesure`, | ||
122 | +ADD COLUMN `symbole` VARCHAR(45) NULL DEFAULT NULL AFTER `emtstandart`, | ||
123 | +ADD COLUMN `formule_id` INT(11) NULL DEFAULT NULL AFTER `symbole`, | ||
124 | +ADD COLUMN `nommesure` VARCHAR(45) NULL DEFAULT NULL AFTER `formule_id`, | ||
125 | +ADD COLUMN `valeurRef` DOUBLE NULL DEFAULT NULL AFTER `nommesure`, | ||
126 | +ADD COLUMN `intitule` VARCHAR(100) NULL DEFAULT NULL AFTER `valeurRef`, | ||
127 | +ADD COLUMN `conforme` VARCHAR(100) NULL DEFAULT NULL AFTER `intitule`; | ||
128 | + | ||
129 | +-- ------------------------------------------------------------------------------------------------------------- | ||
130 | +-- 23/05/2017 | ||
131 | +-- AJOUT LIAISON SUIVIS-UNITES | ||
132 | +-- | ||
133 | +-- | ||
134 | + | ||
135 | +ALTER TABLE `suivis` | ||
136 | +ADD INDEX `fk_suivis_unite_id_idx` (`unite_id` ASC); | ||
137 | +ALTER TABLE `suivis` | ||
138 | +ADD CONSTRAINT `fk_suivis_unite_id` | ||
139 | + FOREIGN KEY (`unite_id`) | ||
140 | + REFERENCES `unites` (`id`) | ||
141 | + ON DELETE NO ACTION | ||
142 | + ON UPDATE NO ACTION; | ||
143 | + | ||
144 | +-- ------------------------------------------------------------------------------------------------------------- | ||
145 | +-- 23/05/2017 | ||
146 | +-- AJOUT LIAISON FOURNISSEURS-MATERIELS | ||
147 | +-- | ||
148 | +-- | ||
149 | + | ||
150 | +ALTER TABLE `materiels` | ||
151 | +ADD INDEX `fk_materiels_fournisseurs_id_idx` (`fournisseur_id` ASC); | ||
152 | +ALTER TABLE `materiels` | ||
153 | +ADD CONSTRAINT `fk_materiels_fournisseurs_id` | ||
154 | + FOREIGN KEY (`fournisseur_id`) | ||
155 | + REFERENCES `fournisseurs` (`id`) | ||
156 | + ON DELETE NO ACTION | ||
157 | + ON UPDATE NO ACTION; | ||
158 | + | ||
159 | + | ||
160 | +-- ------------------------------------------------------------------------------------------------------------- | ||
161 | +-- 23/05/2017 | ||
162 | +-- AJOUT LIAISON MESURES-FICHEMETROLOGIQUES | ||
163 | +-- | ||
164 | +-- | ||
165 | + | ||
166 | +ALTER TABLE `mesures` | ||
167 | +ADD INDEX `fk_mesures_fichemetrologique_id_idx` (`fichemetrologique_id` ASC); | ||
168 | +ALTER TABLE `mesures` | ||
169 | +ADD CONSTRAINT `fk_mesures_fichemetrologique_id` | ||
170 | + FOREIGN KEY (`fichemetrologique_id`) | ||
171 | + REFERENCES `fichemetrologiques` (`id`) | ||
172 | + ON DELETE NO ACTION | ||
173 | + ON UPDATE NO ACTION; | ||
174 | + | ||
175 | + | ||
176 | +-- ------------------------------------------------------------------------------------------------------------- | ||
177 | +-- 23/05/2017 | ||
178 | +-- AJOUT LIAISON SUR_CATEGORIES-USERS | ||
179 | +-- | ||
180 | +-- | ||
181 | + | ||
182 | +ALTER TABLE `users` | ||
183 | +ADD INDEX `fk_users_sur_categories_id_idx` (`sur_categorie_id` ASC); | ||
184 | +ALTER TABLE `users` | ||
185 | +ADD CONSTRAINT `fk_users_sur_categories_id` | ||
186 | + FOREIGN KEY (`sur_categorie_id`) | ||
187 | + REFERENCES `sur_categories` (`id`) | ||
188 | + ON DELETE NO ACTION | ||
189 | + ON UPDATE NO ACTION; | ||
190 | + | ||
191 | + | ||
192 | +-- ------------------------------------------------------------------------------------------------------------- | ||
193 | +-- 23/05/2017 | ||
194 | +-- AJOUT LIAISON FICHEMETROLOGIQUES-SUIVIS | ||
195 | +-- | ||
196 | +-- | ||
197 | + | ||
198 | +ALTER TABLE `fichemetrologiques` | ||
199 | +ADD INDEX `fk_fichemetrologique_suivi_id_idx` (`suivi_id` ASC); | ||
200 | +ALTER TABLE `fichemetrologiques` | ||
201 | +ADD CONSTRAINT `fk_fichemetrologique_suivi_id` | ||
202 | + FOREIGN KEY (`suivi_id`) | ||
203 | + REFERENCES `suivis` (`id`) | ||
204 | + ON DELETE NO ACTION | ||
205 | + ON UPDATE NO ACTION; | ||
206 | + |