From e0c3c0eba510f70e339318cffdbd33b3c7ff56e0 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Wed, 7 Oct 2015 21:36:59 +0200 Subject: [PATCH] Added migration that add the "google_analytics_code" setting in the database. --- src/application/config/migration.php | 82 +++++++++---------- .../migrations/001_specific_calendar_sync.php | 28 ++++--- .../002_add_google_analytics_setting.php | 24 ++++++ 3 files changed, 81 insertions(+), 53 deletions(-) create mode 100644 src/application/migrations/002_add_google_analytics_setting.php diff --git a/src/application/config/migration.php b/src/application/config/migration.php index b0704207..f6ce1480 100644 --- a/src/application/config/migration.php +++ b/src/application/config/migration.php @@ -1,41 +1,41 @@ -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 */ \ No newline at end of file +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 */ diff --git a/src/application/migrations/001_specific_calendar_sync.php b/src/application/migrations/001_specific_calendar_sync.php index 972e1d8e..6c318e07 100644 --- a/src/application/migrations/001_specific_calendar_sync.php +++ b/src/application/migrations/001_specific_calendar_sync.php @@ -2,11 +2,11 @@ /* ---------------------------------------------------------------------------- * Easy!Appointments - Open Source Web Scheduler - * + * * @package EasyAppointments * @author A.Tselegidis * @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'); + } } -} \ No newline at end of file +} diff --git a/src/application/migrations/002_add_google_analytics_setting.php b/src/application/migrations/002_add_google_analytics_setting.php new file mode 100644 index 00000000..eea920ff --- /dev/null +++ b/src/application/migrations/002_add_google_analytics_setting.php @@ -0,0 +1,24 @@ + + * @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'); + } +}