public function __construct($config = array()) { parent::__construct(); // Loading the configuration fo migration $this->config->load('migration'); foreach ($this->config->config as $key => $val) { $this->{'_' . $key} = $val; } log_message('debug', 'Migrations class initialized'); // Are they trying to use migrations while it is disabled? if ($this->_migration_enabled !== TRUE) { show_error('Migrations has been loaded but is disabled or set up incorrectly.'); } // If not set, set it $this->_migration_path == '' and $this->_migration_path = APPPATH . 'migrations/'; // Add trailing slash if not set $this->_migration_path = rtrim($this->_migration_path, '/') . '/'; // Load migration language $this->lang->load('migration'); // They'll probably be using dbforge $this->load->dbforge(); // If the migrations table is missing, make it if (!$this->db->table_exists('migrations')) { $this->dbforge->add_field(array('version' => array('type' => 'INT', 'constraint' => 3))); $this->dbforge->create_table('migrations', TRUE); $this->db->insert('migrations', array('version' => 0)); } }
public function __construct($config = array()) { parent::__construct($config); // If the migrations type column is missing, add it if (!$this->db->field_exists('type', $this->_migration_table)) { $this->dbforge->add_column($this->_migration_table, array('type' => array('type' => 'VARCHAR', 'constraint' => 40, 'first' => TRUE))); $this->db->update($this->_migration_table, array('type' => 'core')); } }
/** * Class constructor method * * @param array $config Array of parameters to initialize class */ public function __construct($config = []) { parent::__construct($config); $this->_set_table(); $this->_check_table(); $this->_set_directory_migrations(); $this->_set_database_migrations(); log_message('info', __CLASS__ . ' Class Initialized'); }
/** * Class Constructor * * @param array $config Migration library config arguments. */ public function __construct($config = array()) { parent::__construct($config); if (!$this->db->field_exists('module', $this->_migration_table)) { $fields = array('module' => array('type' => 'VARCHAR', 'first' => TRUE, 'constraint' => '100', 'null' => FALSE)); $this->dbforge->add_column($this->_migration_table, $fields); $this->db->query("ALTER TABLE {$this->_migration_table} ADD PRIMARY KEY(module);"); $this->db->query("UPDATE {$this->_migration_table} SET module = '{$this->_module_name}' LIMIT 1;"); } $this->_set_migration_path(); log_message('info', 'Craftsman Migration Class Init'); }
public function __construct() { parent::__construct(); }
public function __construct() { parent::__construct(); $this->db->data_cache = array(); }
public function __construct() { parent::__construct(); $this->load->dbforge(); }
public function __construct($config = array()) { parent::__construct($config); $this->load->model('settings_model'); }
/** * Retrieves current schema version * * @return int Current Migration */ function get_version() { return parent::_get_version(); }
public function __construct($config = array()) { parent::__construct($config); $this->db->data_cache = array(); // reset data cache to get fresh info }
/** * Extends migration mechanism to create backup before running migrations and remove it on success, but keep on failure * (non-PHPdoc) * @see CI_Migration::version() */ public function version($target_version) { // Make DB backup $backupFile = $this->_make_backup(); if ($backupFile === FALSE) { log_message('DEBUG', 'Making backup before migrating failed.'); } // Run migrationgs $migrationsResult = parent::version($target_version); // If everything went well - remove backup if ($migrationsResult !== FALSE && $migrationsResult == $target_version) { if ($backupFile !== FALSE && !$this->_delete_backup($backupFile)) { log_message('debug', 'There was an error when removing backup file.'); } } else { if ($backupFile !== FALSE) { log_message('error', 'Migrating to version ' . $target_version . ' failed. Backup from before migration stored in ' . $backupFile); } else { log_message('error', 'Migrating to version ' . $target_version . ' failed, but no valid backup saved.'); } } return $migrationsResult; }
public function __construct($config = array()) { parent::__construct($config); $this->load->model('ranking_model'); $this->load->model('country_model'); }