diff --git a/database/update/db-update-2017-05-23.sh b/database/update/db-update-2017-05-23.sh new file mode 100644 index 0000000..863423b --- /dev/null +++ b/database/update/db-update-2017-05-23.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Pour Mac OS recent (10.10, Yosemite), la syntaxe du SED est differente +# Il faut donc faire une copie de ce fichier et transformer les instructions sed a l'interieur +# Pour cela, il suffit d'executer ces 2 lignes : +# cp ce_script.sh ce_script_macosx.sh +# sed -e "s/ -i / -i '' /" -i '' ce_script_macosx.sh + +if [ ! -f ../../config/app.php ] ; then +echo "Vous devez executer ce script depuis le dossier database/update/" +exit 1 +fi + + +# Get login, pass, dbname, and hostname +username=$(grep "/\*d\*/'username'" ../../config/app.php | cut -d"'" -f4) +password=$(grep "/\*d\*/'password'" ../../config/app.php | cut -d"'" -f4) +database=$(grep "/\*d\*/'database'" ../../config/app.php | cut -d"'" -f4) +host=$(grep "/\*d\*/'host'" ../../config/app.php | cut -d"'" -f4) + + +cp -p ./script_sql/db-update-2017-05-23.sql ./script_sql/db-update-2017-05-23-build.sql + +# Execute sql update script +sed -e "s/database/$database/" -i ./script_sql/db-update-2017-05-23-build.sql +mysql --user=$username --password=$password -h $host < ./script_sql/db-update-2017-05-23-build.sql + +# Delete cakephp cache +sudo rm ../../tmp/cache/models/* +sudo rm ../../tmp/cache/persistent/* + +sudo chmod -R 777 ../../tmp +sudo chmod -R 777 ../../vendor +sudo chmod -R 777 ../../webroot diff --git a/database/update/script_sql/db-update-2017-05-23.sql b/database/update/script_sql/db-update-2017-05-23.sql new file mode 100644 index 0000000..6a7945b --- /dev/null +++ b/database/update/script_sql/db-update-2017-05-23.sql @@ -0,0 +1,206 @@ +USE database; + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- MODIF TABLE CONFIGURATIONS +-- Structure de la table `configurations` +-- + +ALTER TABLE `configurations` ADD COLUMN `metrologie` TINYINT(1) NULL DEFAULT '0' AFTER `taille_max_doc`; + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- MODIF TABLE MATERIELS +-- Structure de la table `materiels` +-- + +ALTER TABLE `materiels` +CHANGE COLUMN `fournisseur` `fournisseur_id` INT NULL DEFAULT NULL , +ADD COLUMN `metrologie` TINYINT(1) NULL DEFAULT '0' AFTER `photo_id`; + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- AJOUT TABLE FOURNISSEURS +-- Structure de la table `fournisseurs` +-- + +CREATE TABLE `fournisseurs` ( + `id` INT NOT NULL AUTO_INCREMENT, + `nom` VARCHAR(45) NULL, + PRIMARY KEY (`id`)); + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- AJOUT TABLE UNITES +-- Structure de la table `unites` +-- + +CREATE TABLE `unites` ( + `id` INT NOT NULL AUTO_INCREMENT, + `nom` VARCHAR(45) NULL, + `symbole` VARCHAR(45) NULL, + PRIMARY KEY (`id`)); + + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- AJOUT TABLE MESURES +-- Structure de la table `mesures` +-- + + +CREATE TABLE `mesures` ( + `id` INT NOT NULL AUTO_INCREMENT, + `fichemetrologique_id` INT NOT NULL, + `valeur` DOUBLE NULL, + `erreur` DOUBLE NULL, + PRIMARY KEY (`id`)); + + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- MODIF TABLE USERS +-- Structure de la table `users` +-- + +ALTER TABLE `users` +ADD COLUMN `sur_categorie_id` INT(11) NULL AFTER `groupe_thematique_id`; + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- AJOUT TABLE FICHEMETROLOGIQUES +-- Structure de la table `fichemetrologiques` +-- + +CREATE TABLE `fichemetrologiques` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `suivi_id` int(11) NOT NULL, + `mesurande` double DEFAULT NULL, + `moyenne` double DEFAULT NULL, + `ecarttype` double DEFAULT NULL, + `correction` double DEFAULT NULL, + `ua` double DEFAULT NULL, + `ub` double DEFAULT NULL, + `uc` double DEFAULT NULL, + `uf` double DEFAULT NULL, + `u` double DEFAULT NULL, + `incertitude` double DEFAULT NULL, + `conditionEnv` double DEFAULT NULL, + `resolution` varchar(45) DEFAULT NULL, + `etatmateriel` varchar(45) DEFAULT NULL, + `etatmetrologique` varchar(45) DEFAULT NULL, + `emtpersonnel` double DEFAULT NULL, + `nbMesure` int(11) DEFAULT NULL, + `conformeEMTstandart` varchar(100) DEFAULT NULL, + `conformeEMTperso` varchar(100) DEFAULT NULL, + `resultatfinal` varchar(100) DEFAULT NULL, + `observation` varchar(200) DEFAULT NULL, + `datefiche` date DEFAULT NULL, + `retard` varchar(45) DEFAULT 'RAS', + `justesse` DOUBLE DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=142 DEFAULT CHARSET=latin1 + + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- MODIF TABLE SUIVIS +-- Structure de la table `suivis` +-- + +ALTER TABLE `suivis` +ADD COLUMN `unite_id` INT(11) NULL DEFAULT NULL AFTER `modified`, +ADD COLUMN `plage_debut` DOUBLE NULL DEFAULT NULL AFTER `unite_id`, +ADD COLUMN `plage_fin` DOUBLE NULL DEFAULT NULL AFTER `plage_debut`, +ADD COLUMN `resolution` DOUBLE NULL DEFAULT NULL AFTER `plage_fin`, +ADD COLUMN `tolerance` DOUBLE NULL DEFAULT NULL AFTER `resolution`, +ADD COLUMN `sensibilite` DOUBLE NULL DEFAULT NULL AFTER `tolerance`, +ADD COLUMN `justesse` DOUBLE NULL DEFAULT NULL AFTER `sensibilite`, +ADD COLUMN `fidelite` DOUBLE NULL DEFAULT NULL AFTER `justesse`, +ADD COLUMN `typemesure` VARCHAR(45) NULL DEFAULT 'Direct' AFTER `fidelite`, +ADD COLUMN `emtstandart` DOUBLE NULL DEFAULT NULL AFTER `typemesure`, +ADD COLUMN `symbole` VARCHAR(45) NULL DEFAULT NULL AFTER `emtstandart`, +ADD COLUMN `formule_id` INT(11) NULL DEFAULT NULL AFTER `symbole`, +ADD COLUMN `nommesure` VARCHAR(45) NULL DEFAULT NULL AFTER `formule_id`, +ADD COLUMN `valeurRef` DOUBLE NULL DEFAULT NULL AFTER `nommesure`, +ADD COLUMN `intitule` VARCHAR(100) NULL DEFAULT NULL AFTER `valeurRef`, +ADD COLUMN `conforme` VARCHAR(100) NULL DEFAULT NULL AFTER `intitule`; + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- AJOUT LIAISON SUIVIS-UNITES +-- +-- + +ALTER TABLE `suivis` +ADD INDEX `fk_suivis_unite_id_idx` (`unite_id` ASC); +ALTER TABLE `suivis` +ADD CONSTRAINT `fk_suivis_unite_id` + FOREIGN KEY (`unite_id`) + REFERENCES `unites` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION; + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- AJOUT LIAISON FOURNISSEURS-MATERIELS +-- +-- + +ALTER TABLE `materiels` +ADD INDEX `fk_materiels_fournisseurs_id_idx` (`fournisseur_id` ASC); +ALTER TABLE `materiels` +ADD CONSTRAINT `fk_materiels_fournisseurs_id` + FOREIGN KEY (`fournisseur_id`) + REFERENCES `fournisseurs` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION; + + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- AJOUT LIAISON MESURES-FICHEMETROLOGIQUES +-- +-- + +ALTER TABLE `mesures` +ADD INDEX `fk_mesures_fichemetrologique_id_idx` (`fichemetrologique_id` ASC); +ALTER TABLE `mesures` +ADD CONSTRAINT `fk_mesures_fichemetrologique_id` + FOREIGN KEY (`fichemetrologique_id`) + REFERENCES `fichemetrologiques` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION; + + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- AJOUT LIAISON SUR_CATEGORIES-USERS +-- +-- + +ALTER TABLE `users` +ADD INDEX `fk_users_sur_categories_id_idx` (`sur_categorie_id` ASC); +ALTER TABLE `users` +ADD CONSTRAINT `fk_users_sur_categories_id` + FOREIGN KEY (`sur_categorie_id`) + REFERENCES `sur_categories` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION; + + +-- ------------------------------------------------------------------------------------------------------------- +-- 23/05/2017 +-- AJOUT LIAISON FICHEMETROLOGIQUES-SUIVIS +-- +-- + +ALTER TABLE `fichemetrologiques` +ADD INDEX `fk_fichemetrologique_suivi_id_idx` (`suivi_id` ASC); +ALTER TABLE `fichemetrologiques` +ADD CONSTRAINT `fk_fichemetrologique_suivi_id` + FOREIGN KEY (`suivi_id`) + REFERENCES `suivis` (`id`) + ON DELETE NO ACTION + ON UPDATE NO ACTION; + -- libgit2 0.21.2