. * * 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_Formation extends CI_Migration { protected $number; /** * * Constructor * * Affiche header et menu */ function __construct() { parent :: __construct(); $this->number = 18; $this->load->library('database'); } /* * 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; $filename = getcwd() . '/application/migrations/formation.sql'; $res = $this->database->sqlfile($filename); gvv_info("Migration database up to " . $this->number . ", errors=$errors"); return !$errors; } /** * Reverse the migration */ public function down() { $errors = 0; $sql = 'SET FOREIGN_KEY_CHECKS=0;'; if (!$this->db->query($sql)) {$errors += 1;} $this->dbforge->drop_table('formation_chapitres', true); $this->dbforge->drop_table('formation_item', true); $this->dbforge->drop_table('formation_progres', true); $sql = 'SET FOREIGN_KEY_CHECKS=1;'; if (!$this->db->query($sql)) {$errors += 1;} gvv_info("Migration database down to " . $this->number - 1 . ", errors=$errors"); return !$errors; } }