. * * Script de migration de la base */ if (!defined('BASEPATH')) exit ('No direct script access allowed'); /** * Passe les compteurs de tickets en décimal * * @author frederic * */ class Migration_Tarifs_Date_De_Fin extends CI_Migration { protected $number; /** * * Constructor * * Affiche header et menu */ function __construct() { parent :: __construct(); $this->number = 15; } /* * Execute an array of sql requests */ private function run_queries($sqls = array()) { $errors = 0; foreach ($sqls as $sql) { // echo $sql . br(); if (!$this->db->query($sql)) {$errors += 1;} } return $errors; } /** * Apply the migration */ public function up() { $errors = 0; $sqls = array( "ALTER TABLE `tarifs` ADD `date_fin` DATE NULL DEFAULT '2099-12-31' COMMENT 'Date de fin' AFTER `date` ;", "ALTER TABLE `tarifs` ADD `public` TINYINT NULL DEFAULT '1' COMMENT 'Permet le filtrage sur l''impression';" ); $errors += $this->run_queries($sqls); gvv_info("Migration database up to " . $this->number . ", errors=$errors"); return !$errors; } /** * Reverse the migration */ public function down() { $errors = 0; $sqls = array( "ALTER TABLE `tarifs` DROP `date_fin`;", "ALTER TABLE `tarifs` DROP `public`;" ); $errors += $this->run_queries($sqls); gvv_info("Migration database down to " . $this->number - 1 . ", errors=$errors"); return !$errors; } }