Subversion Repositories eFlore/Applications.cel

Rev

Rev 2415 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2415 jpm 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Mise à jour de la base de données afin de l'optimiser :
5
 * - remplacement du champ "eflore_publiable" de la table "cel_images" par un champ "transmission" (correspondant au champ tansmission des obs)
6
 * - ajout du champ "date_liaison" dans la table "cel_images"
2418 jpm 7
 * - ajout du champ "ce_observation" dans la table "cel_images"
8
 * - migration des données de la table cel_obs_images dans cel_images
9
 * - création d'un index sur cel_images.ce_observation
10
 * - suppression de la table cel_obs_images
2415 jpm 11
 *
12
 * Utilisation :
13
 * - mise à jour de la bdd : <code>/opt/lamp/bin/php cli.php migration_optimisation -a migrer</code>
14
 *
15
 * @category   CEL
16
 * @package    Scripts
17
 * @subpackage Migration : Optimisation
18
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
19
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
20
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
21
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
22
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
23
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
24
 */
25
class MigrationOptimisation extends Script {
26
 
27
	public function executer() {
28
		$cmd = $this->getParametre('a');
29
		$this->mode_verbeux = $this->getParametre('v');
30
 
31
		switch($cmd) {
2418 jpm 32
			case 'maj':
33
				$this->migrerBdd();
34
				break;
2415 jpm 35
			default:
2418 jpm 36
				echo "Action «$cmd» inconnue.\n";
2415 jpm 37
		}
38
	}
39
 
2418 jpm 40
	private function migrerBdd() {
41
		$contenuSql = FichierUtil::recupererContenu(__DIR__.'/maj_optimisation.sql');
42
		$this->executerScripSql($contenuSql);
2415 jpm 43
	}
44
 
2418 jpm 45
	private function executerScripSql($sql) {
46
		$requetes = SqlUtil::extraireRequetes($sql);
47
		foreach ($requetes as $requete) {
48
			echo "Exécution de la requete : $requete\n";
49
			$this->executer($requete);
2415 jpm 50
		}
51
	}
52
}