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

@ -1,41 +1,41 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Enable/Disable Migrations
|--------------------------------------------------------------------------
|
| Migrations are disabled by default but should be enabled
| whenever you intend to do a schema migration.
|
*/
$config['migration_enabled'] = TRUE;
/*
|--------------------------------------------------------------------------
| Migrations version
|--------------------------------------------------------------------------
|
| This is used to set migration version that the file system should be on.
| If you run $this->migration->latest() this is the version that schema will
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 1; // current
/*
|--------------------------------------------------------------------------
| Migrations Path
|--------------------------------------------------------------------------
|
| Path to your migrations folder.
| Typically, it will be within your application path.
| Also, writing permission is required within the migrations path.
|
*/
$config['migration_path'] = APPPATH . 'migrations/';
/* End of file migration.php */
/* Location: ./application/config/migration.php */
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Enable/Disable Migrations
|--------------------------------------------------------------------------
|
| Migrations are disabled by default but should be enabled
| whenever you intend to do a schema migration.
|
*/
$config['migration_enabled'] = TRUE;
/*
|--------------------------------------------------------------------------
| Migrations version
|--------------------------------------------------------------------------
|
| This is used to set migration version that the file system should be on.
| If you run $this->migration->latest() this is the version that schema will
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 2; // current
/*
|--------------------------------------------------------------------------
| Migrations Path
|--------------------------------------------------------------------------
|
| Path to your migrations folder.
| Typically, it will be within your application path.
| Also, writing permission is required within the migrations path.
|
*/
$config['migration_path'] = APPPATH . 'migrations/';
/* End of file migration.php */
/* Location: ./application/config/migration.php */

View file

@ -2,11 +2,11 @@
/* ----------------------------------------------------------------------------
* 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
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.0.0
* ---------------------------------------------------------------------------- */
@ -14,17 +14,21 @@
class Migration_Specific_calendar_sync extends CI_Migration {
public function up() {
$fields = array(
'google_calendar' => array(
'type' => 'VARCHAR',
'constraint' => '128',
'null' => TRUE)
);
$this->dbforge->add_column('ea_user_settings', $fields);
if (!$this->db->field_exists('google_calendar', 'ea_user_settings')) {
$fields = array(
'google_calendar' => array(
'type' => 'VARCHAR',
'constraint' => '128',
'null' => TRUE
)
);
$this->dbforge->add_column('ea_user_settings', $fields);
}
}
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');
}
}