Added migration that add the "google_analytics_code" setting in the database.

This commit is contained in:
Alex Tselegidis 2015-10-07 21:36:59 +02:00
parent 722daac2cd
commit e0c3c0eba5
3 changed files with 81 additions and 53 deletions

View file

@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to. | be upgraded / downgraded to.
| |
*/ */
$config['migration_version'] = 1; // current $config['migration_version'] = 2; // current
/* /*

View file

@ -14,17 +14,21 @@
class Migration_Specific_calendar_sync extends CI_Migration { class Migration_Specific_calendar_sync extends CI_Migration {
public function up() { public function up() {
$fields = array( if (!$this->db->field_exists('google_calendar', 'ea_user_settings')) {
'google_calendar' => array( $fields = array(
'type' => 'VARCHAR', 'google_calendar' => array(
'constraint' => '128', 'type' => 'VARCHAR',
'null' => TRUE) 'constraint' => '128',
); 'null' => TRUE
)
$this->dbforge->add_column('ea_user_settings', $fields); );
$this->dbforge->add_column('ea_user_settings', $fields);
}
} }
public function down() { public function down() {
$this->dbforge->drop_column('ea_user_settings', 'google_calendar'); if ($this->db->field_exists('google_calendar', 'ea_user_settings')) {
$this->dbforge->drop_column('ea_user_settings', 'google_calendar');
}
} }
} }

View file

@ -0,0 +1,24 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2015, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.0.0
* ---------------------------------------------------------------------------- */
class Migration_Add_google_analytics_setting extends CI_Migration {
public function up() {
$this->load->model('settings_model');
$this->settings_model->set_setting('google_analytics_code', '');
}
public function down() {
$this->load->model('settings_model');
$this->settings_model->remove_setting('google_analytics_code');
}
}