From f571fc9de8509c7db3fd19bc8d79461604c8e297 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Thu, 23 Apr 2020 20:35:21 +0200 Subject: [PATCH] Refactor the migrations so that the complete DB change history is reproduced (fixes are also included). --- .../001_initial_database_structure.php | 504 ++++++++++++++++++ .../002_add_google_analytics_setting.php | 28 +- ...003_add_customer_notifications_setting.php | 27 +- .../004_add_date_format_setting.php | 29 +- .../005_add_require_captcha_setting.php | 28 +- .../006_add_calendar_view_setting.php | 4 +- ...availabilities_type_to_services_table.php} | 6 +- ...d_attendants_number_to_services_table.php} | 8 +- .../migrations/009_change_column_types.php | 44 +- .../010_add_time_format_setting.php | 28 +- ...> 011_remove_prefix_from_foreign_keys.php} | 46 +- .../migrations/012_create_consents_table.php | 133 +++++ application/migrations/012_legal_contents.php | 68 --- .../013_add_weekday_start_setting.php | 28 +- ...14_create_appointment_location_column.php} | 6 +- ...d_extra_working_plan_to_user_settings.php} | 7 +- .../016_add_require_phone_number_setting.php | 28 +- .../migrations/017_add_api_token_setting.php | 28 +- .../migrations/018_add_timezone_columns.php | 44 -- ...sync.php => 018_add_timezone_to_users.php} | 23 +- .../019_add_display_any_provider_setting.php | 2 - 21 files changed, 740 insertions(+), 379 deletions(-) create mode 100644 application/migrations/001_initial_database_structure.php rename application/migrations/{007_add_service_availabilities_type.php => 007_add_availabilities_type_to_services_table.php} (88%) rename application/migrations/{008_add_service_attendants_number.php => 008_add_attendants_number_to_services_table.php} (84%) rename application/migrations/{011_remove_prefix_from_fkey_constraints.php => 011_remove_prefix_from_foreign_keys.php} (69%) create mode 100644 application/migrations/012_create_consents_table.php delete mode 100644 application/migrations/012_legal_contents.php rename application/migrations/{014_add_appointment_location_column.php => 014_create_appointment_location_column.php} (87%) rename application/migrations/{015_add_user_extra_working_plan.php => 015_add_extra_working_plan_to_user_settings.php} (86%) delete mode 100644 application/migrations/018_add_timezone_columns.php rename application/migrations/{001_specific_calendar_sync.php => 018_add_timezone_to_users.php} (61%) diff --git a/application/migrations/001_initial_database_structure.php b/application/migrations/001_initial_database_structure.php new file mode 100644 index 00000000..0ef96582 --- /dev/null +++ b/application/migrations/001_initial_database_structure.php @@ -0,0 +1,504 @@ + + * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.4.0 + * ---------------------------------------------------------------------------- */ + +/** + * Class Migration_Initial_database_structure + * + * @property CI_DB_query_builder db + * @property CI_DB_forge dbforge + */ +class Migration_Initial_database_structure extends CI_Migration { + /** + * Upgrade method. + */ + public function up() + { + $this->dbforge->add_field([ + 'id' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ], + 'book_datetime' => [ + 'type' => 'DATETIME', + 'null' => TRUE, + ], + 'start_datetime' => [ + 'type' => 'DATETIME', + 'null' => TRUE, + ], + 'end_datetime' => [ + 'type' => 'DATETIME', + 'null' => TRUE, + ], + 'notes' => [ + 'type' => 'TEXT', + 'null' => TRUE, + ], + 'hash' => [ + 'type' => 'TEXT', + 'null' => TRUE, + ], + 'is_unavailable' => [ + 'type' => 'TINYINT', + 'constraint' => '4', + 'default' => '0' + ], + 'id_users_provider' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'null' => TRUE + ], + 'id_users_customer' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'null' => TRUE + ], + 'id_services' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'null' => TRUE + ], + 'id_google_calendar' => [ + 'type' => 'TEXT', + 'null' => TRUE + ], + ]); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->add_key('id_users_provider'); + $this->dbforge->add_key('id_users_customer'); + $this->dbforge->add_key('id_services'); + $this->dbforge->create_table('ea_appointments', TRUE, ['engine' => 'InnoDB']); + + $this->dbforge->add_field([ + 'id' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE + ], + 'slug' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE + ], + 'is_admin' => [ + 'type' => 'TINYINT', + 'constraint' => '4', + 'null' => TRUE + ], + 'appointments' => [ + 'type' => 'INT', + 'constraint' => '4', + 'null' => TRUE + ], + 'customers' => [ + 'type' => 'INT', + 'constraint' => '4', + 'null' => TRUE + ], + 'services' => [ + 'type' => 'INT', + 'constraint' => '4', + 'null' => TRUE + ], + 'users' => [ + 'type' => 'INT', + 'constraint' => '4', + 'null' => TRUE + ], + 'system_settings' => [ + 'type' => 'INT', + 'constraint' => '4', + 'null' => TRUE + ], + 'user_settings' => [ + 'type' => 'INT', + 'constraint' => '4', + 'null' => TRUE + ], + ]); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->create_table('ea_roles', TRUE, ['engine' => 'InnoDB']); + + $this->dbforge->add_field([ + 'id_users_secretary' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + ], + 'id_users_provider' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + ] + ]); + $this->dbforge->add_key('id_users_secretary', TRUE); + $this->dbforge->add_key('id_users_provider', TRUE); + $this->dbforge->create_table('ea_secretaries_providers', TRUE, ['engine' => 'InnoDB']); + + $this->dbforge->add_field([ + 'id' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE + ], + 'duration' => [ + 'type' => 'INT', + 'constraint' => '11', + 'null' => TRUE + ], + 'price' => [ + 'type' => 'DECIMAL', + 'constraint' => '10,2', + 'null' => TRUE + ], + 'currency' => [ + 'type' => 'VARCHAR', + 'constraint' => '32', + 'null' => TRUE + ], + 'description' => [ + 'type' => 'TEXT', + 'null' => TRUE + ], + 'id_service_categories' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'null' => TRUE + ], + ]); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->add_key('id_service_categories'); + $this->dbforge->create_table('ea_services', TRUE, ['engine' => 'InnoDB']); + + $this->dbforge->add_field([ + 'id_users' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + ], + 'id_services' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + ] + ]); + $this->dbforge->add_key('id_users', TRUE); + $this->dbforge->add_key('id_services', TRUE); + $this->dbforge->create_table('ea_services_providers', TRUE, ['engine' => 'InnoDB']); + + $this->dbforge->add_field([ + 'id' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE + ], + 'description' => [ + 'type' => 'TEXT', + 'null' => TRUE + ], + ]); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->add_key('id_service_categories'); + $this->dbforge->create_table('ea_service_categories', TRUE, ['engine' => 'InnoDB']); + + $this->dbforge->add_field([ + 'id' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => '512', + 'null' => TRUE + ], + 'value' => [ + 'type' => 'LONGTEXT', + 'null' => TRUE + ], + ]); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->create_table('ea_settings', TRUE, ['engine' => 'InnoDB']); + + $this->dbforge->add_field([ + 'id' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ], + 'first_name' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE + ], + 'last_name' => [ + 'type' => 'VARCHAR', + 'constraint' => '512', + 'null' => TRUE + ], + 'email' => [ + 'type' => 'VARCHAR', + 'constraint' => '512', + 'null' => TRUE + ], + 'mobile_number' => [ + 'type' => 'VARCHAR', + 'constraint' => '128', + 'null' => TRUE + ], + 'phone_number' => [ + 'type' => 'VARCHAR', + 'constraint' => '128', + 'null' => TRUE + ], + 'address' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE + ], + 'city' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE + ], + 'state' => [ + 'type' => 'VARCHAR', + 'constraint' => '128', + 'null' => TRUE + ], + 'zip_code' => [ + 'type' => 'VARCHAR', + 'constraint' => '64', + 'null' => TRUE + ], + 'notes' => [ + 'type' => 'TEXT', + 'null' => TRUE + ], + 'id_roles' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE + ], + ]); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->add_key('id_roles'); + $this->dbforge->create_table('ea_users', TRUE, ['engine' => 'InnoDB']); + + $this->dbforge->add_field([ + 'id_users' => [ + 'type' => 'BIGINT', + 'constraint' => '20', + 'unsigned' => TRUE, + ], + 'username' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE + ], + 'password' => [ + 'type' => 'VARCHAR', + 'constraint' => '512', + 'null' => TRUE + ], + 'salt' => [ + 'type' => 'VARCHAR', + 'constraint' => '512', + 'null' => TRUE + ], + 'working_plan' => [ + 'type' => 'TEXT', + 'null' => TRUE + ], + 'notifications' => [ + 'type' => 'TINYINT', + 'constraint' => '4', + 'null' => TRUE + ], + 'google_sync' => [ + 'type' => 'TINYINT', + 'constraint' => '4', + 'null' => TRUE + ], + 'google_token' => [ + 'type' => 'TEXT', + 'null' => TRUE + ], + 'google_calendar' => [ + 'type' => 'VARCHAR', + 'constraint' => '128', + 'null' => TRUE + ], + 'sync_past_days' => [ + 'type' => 'INT', + 'constraint' => '11', + 'null' => TRUE, + 'default' => '5' + ], + 'sync_future_days' => [ + 'type' => 'INT', + 'constraint' => '11', + 'null' => TRUE, + 'default' => '5' + ], + ]); + $this->dbforge->add_key('id_users', TRUE); + $this->dbforge->create_table('ea_user_settings', TRUE, ['engine' => 'InnoDB']); + + $this->db->query(' + ALTER TABLE `ea_appointments` + ADD CONSTRAINT `ea_appointments_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `ea_appointments_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `ea_appointments_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + '); + + $this->db->query(' + ALTER TABLE `ea_secretaries_providers` + ADD CONSTRAINT `fk_ea_secretaries_providers_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `fk_ea_secretaries_providers_2` FOREIGN KEY (`id_users_provider`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + '); + + $this->db->query(' + ALTER TABLE `ea_services` + ADD CONSTRAINT `ea_services_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `ea_service_categories` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; + '); + + $this->db->query(' + ALTER TABLE `ea_services_providers` + ADD CONSTRAINT `ea_services_providers_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `ea_services_providers_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `ea_services` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + '); + + $this->db->query(' + ALTER TABLE `ea_users` + ADD CONSTRAINT `ea_users_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `ea_roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + '); + + $this->db->query(' + ALTER TABLE `ea_user_settings` + ADD CONSTRAINT `ea_user_settings_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + '); + + $this->db->insert('ea_roles', [ + 'name' => 'Administrator', + 'slug' => 'admin', + 'is_admin' => TRUE, + 'appointments' => 15, + 'customers' => 15, + 'services' => 15, + 'users' => 15, + 'system_settings' => 15, + 'user_settings' => 15, + ]); + + $this->db->insert('ea_roles', [ + 'name' => 'Provider', + 'slug' => 'provider', + 'is_admin' => FALSE, + 'appointments' => 15, + 'customers' => 15, + 'services' => 0, + 'users' => 0, + 'system_settings' => 0, + 'user_settings' => 15, + ]); + + $this->db->insert('ea_roles', [ + 'name' => 'Customer', + 'slug' => 'customer', + 'is_admin' => FALSE, + 'appointments' => 0, + 'customers' => 0, + 'services' => 0, + 'users' => 0, + 'system_settings' => 0, + 'user_settings' => 0, + ]); + + $this->db->insert('ea_roles', [ + 'name' => 'Secretary', + 'slug' => 'secretary', + 'is_admin' => FALSE, + 'appointments' => 15, + 'customers' => 15, + 'services' => 0, + 'users' => 0, + 'system_settings' => 0, + 'user_settings' => 15, + ]); + + $this->db->insert('ea_settings', [ + 'name' => 'company_working_plan', + 'value' => '{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"saturday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"sunday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]}}' + ]); + + $this->db->insert('ea_settings', [ + 'name' => 'book_advance_timeout', + 'value' => '30' + ]); + } + + /** + * Downgrade method. + */ + public function down() + { + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_2`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_3`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_4`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_1`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_2`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_2`'); + $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `ea_services_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `ea_users_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `ea_user_settings_ibfk_1`'); + + $this->dbforge->drop_table('ea_appointments'); + $this->dbforge->drop_table('ea_roles'); + $this->dbforge->drop_table('ea_secretaries_providers'); + $this->dbforge->drop_table('ea_services'); + $this->dbforge->drop_table('ea_service_categories'); + $this->dbforge->drop_table('ea_services_providers'); + $this->dbforge->drop_table('ea_settings'); + $this->dbforge->drop_table('ea_user_settings'); + $this->dbforge->drop_table('ea_users'); + } +} diff --git a/application/migrations/002_add_google_analytics_setting.php b/application/migrations/002_add_google_analytics_setting.php index 191c2be4..522a76c4 100644 --- a/application/migrations/002_add_google_analytics_setting.php +++ b/application/migrations/002_add_google_analytics_setting.php @@ -14,24 +14,10 @@ /** * Class Migration_Add_google_analytics_setting * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_google_analytics_setting extends CI_Migration { - /** - * Migration_Add_google_analytics_setting constructor. - * - * @param array $config - */ - public function __construct($config = []) - { - parent::__construct($config); - - $this->load->model('settings_model'); - } - /** * Upgrade method. * @@ -39,14 +25,10 @@ class Migration_Add_google_analytics_setting extends CI_Migration { */ public function up() { - try - { - $this->settings_model->get_setting('google_analytics_code'); - } - catch (Exception $exception) - { - $this->settings_model->set_setting('google_analytics_code', ''); - } + $this->db->insert('ea_settings', [ + 'name' => 'google_analytics_code', + 'value' => '' + ]); } /** @@ -56,6 +38,6 @@ class Migration_Add_google_analytics_setting extends CI_Migration { */ public function down() { - $this->settings_model->remove_setting('google_analytics_code'); + $this->db->delete('ea_settings', ['name' => 'google_analytics_code']); } } diff --git a/application/migrations/003_add_customer_notifications_setting.php b/application/migrations/003_add_customer_notifications_setting.php index 0056d566..b2deba1c 100644 --- a/application/migrations/003_add_customer_notifications_setting.php +++ b/application/migrations/003_add_customer_notifications_setting.php @@ -16,21 +16,8 @@ * * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_customer_notifications_setting extends CI_Migration { - /** - * Migration_Add_customer_notifications_setting constructor. - * - * @param array $config - */ - public function __construct($config = []) - { - parent::__construct($config); - - $this->load->model('settings_model'); - } - /** * Upgrade method. * @@ -38,14 +25,10 @@ class Migration_Add_customer_notifications_setting extends CI_Migration { */ public function up() { - try - { - $this->settings_model->get_setting('customer_notifications'); - } - catch (Exception $exception) - { - $this->settings_model->set_setting('customer_notifications', '1'); - } + $this->db->insert('ea_settings', [ + 'name' => 'customer_notifications', + 'value' => '1' + ]); } /** @@ -55,6 +38,6 @@ class Migration_Add_customer_notifications_setting extends CI_Migration { */ public function down() { - $this->settings_model->remove_setting('customer_notifications'); + $this->db->delete('ea_settings', ['name' => 'customer_notifications']); } } diff --git a/application/migrations/004_add_date_format_setting.php b/application/migrations/004_add_date_format_setting.php index 5e382047..3eee551b 100644 --- a/application/migrations/004_add_date_format_setting.php +++ b/application/migrations/004_add_date_format_setting.php @@ -14,25 +14,10 @@ /** * Class Migration_Add_date_format_setting * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_date_format_setting extends CI_Migration { - /** - * Migration_Add_date_format_setting constructor. - * - * @param array $config - */ - public function __construct($config = []) - { - parent::__construct($config); - - $this->load->model('settings_model'); - } - - /** * Upgrade method. * @@ -40,14 +25,10 @@ class Migration_Add_date_format_setting extends CI_Migration { */ public function up() { - try - { - $this->settings_model->get_setting('date_format'); - } - catch (Exception $exception) - { - $this->settings_model->set_setting('date_format', DATE_FORMAT_DMY); - } + $this->db->insert('ea_settings', [ + 'name' => 'date_format', + 'value' => 'DMY' + ]); } /** @@ -57,6 +38,6 @@ class Migration_Add_date_format_setting extends CI_Migration { */ public function down() { - $this->settings_model->remove_setting('date_format'); + $this->db->delete('ea_settings', ['name' => 'date_format']); } } diff --git a/application/migrations/005_add_require_captcha_setting.php b/application/migrations/005_add_require_captcha_setting.php index e544d2d6..c7977975 100644 --- a/application/migrations/005_add_require_captcha_setting.php +++ b/application/migrations/005_add_require_captcha_setting.php @@ -14,24 +14,10 @@ /** * Class Migration_Add_require_captcha_setting * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_require_captcha_setting extends CI_Migration { - /** - * Migration_Add_require_captcha_setting constructor. - * - * @param array $config - */ - public function __construct($config = []) - { - parent::__construct($config); - - $this->load->model('settings_model'); - } - /** * Upgrade method. * @@ -39,14 +25,10 @@ class Migration_Add_require_captcha_setting extends CI_Migration { */ public function up() { - try - { - $this->settings_model->get_setting('require_captcha'); - } - catch (Exception $exception) - { - $this->settings_model->set_setting('require_captcha', '1'); - } + $this->db->insert('ea_settings', [ + 'name' => 'require_captcha', + 'value' => '0' + ]); } /** @@ -56,6 +38,6 @@ class Migration_Add_require_captcha_setting extends CI_Migration { */ public function down() { - $this->settings_model->remove_setting('require_captcha'); + $this->db->delete('ea_settings', ['name' => 'require_captcha']); } } diff --git a/application/migrations/006_add_calendar_view_setting.php b/application/migrations/006_add_calendar_view_setting.php index 32fd181a..c8fa783e 100644 --- a/application/migrations/006_add_calendar_view_setting.php +++ b/application/migrations/006_add_calendar_view_setting.php @@ -14,10 +14,8 @@ /** * Class Migration_Add_calendar_view_setting * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_calendar_view_setting extends CI_Migration { /** @@ -48,7 +46,7 @@ class Migration_Add_calendar_view_setting extends CI_Migration { { if ($this->db->field_exists('calendar_view', 'ea_user_settings')) { - $this->dbforge->drop_column('ea_user_settings', 'calendar_view_calendar'); + $this->dbforge->drop_column('ea_user_settings', 'calendar_view'); } } } diff --git a/application/migrations/007_add_service_availabilities_type.php b/application/migrations/007_add_availabilities_type_to_services_table.php similarity index 88% rename from application/migrations/007_add_service_availabilities_type.php rename to application/migrations/007_add_availabilities_type_to_services_table.php index 13acd9ba..982c7517 100644 --- a/application/migrations/007_add_service_availabilities_type.php +++ b/application/migrations/007_add_availabilities_type_to_services_table.php @@ -12,14 +12,12 @@ * ---------------------------------------------------------------------------- */ /** - * Class Migration_Add_service_availabilities_type + * Class Migration_Add_availabilities_type_to_services_table * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ -class Migration_Add_service_availabilities_type extends CI_Migration { +class Migration_Add_availabilities_type_to_services_table extends CI_Migration { /** * Upgrade method. */ diff --git a/application/migrations/008_add_service_attendants_number.php b/application/migrations/008_add_attendants_number_to_services_table.php similarity index 84% rename from application/migrations/008_add_service_attendants_number.php rename to application/migrations/008_add_attendants_number_to_services_table.php index bd8460df..b455f97b 100644 --- a/application/migrations/008_add_service_attendants_number.php +++ b/application/migrations/008_add_attendants_number_to_services_table.php @@ -12,14 +12,12 @@ * ---------------------------------------------------------------------------- */ /** - * Class Migration_Add_service_attendants_number + * Class Migration_Add_attendants_number_to_services_table * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ -class Migration_Add_service_attendants_number extends CI_Migration { +class Migration_Add_attendants_number_to_services_table extends CI_Migration { /** * Upgrade method. */ @@ -37,8 +35,6 @@ class Migration_Add_service_attendants_number extends CI_Migration { ]; $this->dbforge->add_column('ea_services', $fields); - - $this->db->update('ea_services', ['attendants_number' => '1']); } } diff --git a/application/migrations/009_change_column_types.php b/application/migrations/009_change_column_types.php index 12140534..e31c1202 100644 --- a/application/migrations/009_change_column_types.php +++ b/application/migrations/009_change_column_types.php @@ -14,10 +14,8 @@ /** * Class Migration_Change_column_types * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Change_column_types extends CI_Migration { /** @@ -26,16 +24,16 @@ class Migration_Change_column_types extends CI_Migration { public function up() { // Drop table constraints. - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY ea_appointments_ibfk_2'); - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY ea_appointments_ibfk_3'); - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY ea_appointments_ibfk_4'); - $this->db->query('ALTER TABLE ea_secretaries_providers DROP FOREIGN KEY fk_ea_secretaries_providers_1'); - $this->db->query('ALTER TABLE ea_secretaries_providers DROP FOREIGN KEY fk_ea_secretaries_providers_2'); - $this->db->query('ALTER TABLE ea_services_providers DROP FOREIGN KEY ea_services_providers_ibfk_1'); - $this->db->query('ALTER TABLE ea_services_providers DROP FOREIGN KEY ea_services_providers_ibfk_2'); - $this->db->query('ALTER TABLE ea_services DROP FOREIGN KEY ea_services_ibfk_1'); - $this->db->query('ALTER TABLE ea_users DROP FOREIGN KEY ea_users_ibfk_1'); - $this->db->query('ALTER TABLE ea_user_settings DROP FOREIGN KEY ea_user_settings_ibfk_1'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_2`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_3`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_4`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_1`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_2`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_2`'); + $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `ea_services_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `ea_users_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `ea_user_settings_ibfk_1`'); // Appointments $fields = [ @@ -240,16 +238,16 @@ class Migration_Change_column_types extends CI_Migration { public function down() { // Drop table constraints. - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY ea_appointments_ibfk_2'); - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY ea_appointments_ibfk_3'); - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY ea_appointments_ibfk_4'); - $this->db->query('ALTER TABLE ea_secretaries_providers DROP FOREIGN KEY fk_ea_secretaries_providers_1'); - $this->db->query('ALTER TABLE ea_secretaries_providers DROP FOREIGN KEY fk_ea_secretaries_providers_2'); - $this->db->query('ALTER TABLE ea_services_providers DROP FOREIGN KEY ea_services_providers_ibfk_1'); - $this->db->query('ALTER TABLE ea_services_providers DROP FOREIGN KEY ea_services_providers_ibfk_2'); - $this->db->query('ALTER TABLE ea_services DROP FOREIGN KEY ea_services_ibfk_1'); - $this->db->query('ALTER TABLE ea_users DROP FOREIGN KEY ea_users_ibfk_1'); - $this->db->query('ALTER TABLE ea_user_settings DROP FOREIGN KEY ea_user_settings_ibfk_1'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_2`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_3`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_4`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_1`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_2`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_2`'); + $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `ea_services_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `ea_users_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `ea_user_settings_ibfk_1`'); // Appointments $fields = [ @@ -402,7 +400,7 @@ class Migration_Change_column_types extends CI_Migration { 'auto_increment' => TRUE ], 'id_roles' => [ - 'name' => 'id', + 'name' => 'id_roles', 'type' => 'bigint', 'constraint' => '20' ] diff --git a/application/migrations/010_add_time_format_setting.php b/application/migrations/010_add_time_format_setting.php index 89dbc057..d15b4e39 100644 --- a/application/migrations/010_add_time_format_setting.php +++ b/application/migrations/010_add_time_format_setting.php @@ -14,37 +14,19 @@ /** * Class Migration_Add_time_format_setting * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_time_format_setting extends CI_Migration { - /** - * Migration_Add_time_format_setting constructor. - * - * @param array $config - */ - public function __construct($config = []) - { - parent::__construct($config); - - $this->load->model('settings_model'); - } - /** * Upgrade method. */ public function up() { - try - { - $this->settings_model->get_setting('time_format'); - } - catch (Exception $exception) - { - $this->settings_model->set_setting('time_format', 'regular'); - } + $this->db->insert('ea_settings', [ + 'name' => 'time_format', + 'value' => 'regular' + ]); } /** @@ -52,6 +34,6 @@ class Migration_Add_time_format_setting extends CI_Migration { */ public function down() { - $this->settings_model->remove_setting('time_format'); + $this->db->delete('ea_settings', ['name' => 'time_format']); } } diff --git a/application/migrations/011_remove_prefix_from_fkey_constraints.php b/application/migrations/011_remove_prefix_from_foreign_keys.php similarity index 69% rename from application/migrations/011_remove_prefix_from_fkey_constraints.php rename to application/migrations/011_remove_prefix_from_foreign_keys.php index 98f533a1..1503e7ff 100644 --- a/application/migrations/011_remove_prefix_from_fkey_constraints.php +++ b/application/migrations/011_remove_prefix_from_foreign_keys.php @@ -12,30 +12,28 @@ * ---------------------------------------------------------------------------- */ /** - * Class Migration_Remove_prefix_from_fkey_constraints + * Class Migration_Remove_prefix_from_foreign_keys * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ -class Migration_Remove_prefix_from_fkey_constraints extends CI_Migration { +class Migration_Remove_prefix_from_foreign_keys extends CI_Migration { /** * Upgrade method. */ public function up() { // Drop table constraints. - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY ea_appointments_ibfk_2'); - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY ea_appointments_ibfk_3'); - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY ea_appointments_ibfk_4'); - $this->db->query('ALTER TABLE ea_secretaries_providers DROP FOREIGN KEY fk_ea_secretaries_providers_1'); - $this->db->query('ALTER TABLE ea_secretaries_providers DROP FOREIGN KEY fk_ea_secretaries_providers_2'); - $this->db->query('ALTER TABLE ea_services_providers DROP FOREIGN KEY ea_services_providers_ibfk_1'); - $this->db->query('ALTER TABLE ea_services_providers DROP FOREIGN KEY ea_services_providers_ibfk_2'); - $this->db->query('ALTER TABLE ea_services DROP FOREIGN KEY ea_services_ibfk_1'); - $this->db->query('ALTER TABLE ea_users DROP FOREIGN KEY ea_users_ibfk_1'); - $this->db->query('ALTER TABLE ea_user_settings DROP FOREIGN KEY ea_user_settings_ibfk_1'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_2`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_3`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `ea_appointments_ibfk_4`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_1`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `fk_ea_secretaries_providers_2`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `ea_services_providers_ibfk_2`'); + $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `ea_services_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `ea_users_ibfk_1`'); + $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `ea_user_settings_ibfk_1`'); // Add table constraints again without the "ea" prefix. $this->db->query('ALTER TABLE `ea_appointments` @@ -87,16 +85,16 @@ class Migration_Remove_prefix_from_fkey_constraints extends CI_Migration { public function down() { // Drop table constraints. - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY appointments_services'); - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY appointments_users_customer'); - $this->db->query('ALTER TABLE ea_appointments DROP FOREIGN KEY appointments_users_provider'); - $this->db->query('ALTER TABLE ea_secretaries_providers DROP FOREIGN KEY secretaries_users_secretary'); - $this->db->query('ALTER TABLE ea_secretaries_providers DROP FOREIGN KEY secretaries_users_provider'); - $this->db->query('ALTER TABLE ea_services_providers DROP FOREIGN KEY services_providers_users_provider'); - $this->db->query('ALTER TABLE ea_services_providers DROP FOREIGN KEY services_providers_services'); - $this->db->query('ALTER TABLE ea_services DROP FOREIGN KEY services_service_categories'); - $this->db->query('ALTER TABLE ea_users DROP FOREIGN KEY users_roles'); - $this->db->query('ALTER TABLE ea_user_settings DROP FOREIGN KEY user_settings_users'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `appointments_services`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `appointments_users_customer`'); + $this->db->query('ALTER TABLE `ea_appointments` DROP FOREIGN KEY `appointments_users_provider`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `secretaries_users_secretary`'); + $this->db->query('ALTER TABLE `ea_secretaries_providers` DROP FOREIGN KEY `secretaries_users_provider`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `services_providers_users_provider`'); + $this->db->query('ALTER TABLE `ea_services_providers` DROP FOREIGN KEY `services_providers_services`'); + $this->db->query('ALTER TABLE `ea_services` DROP FOREIGN KEY `services_service_categories`'); + $this->db->query('ALTER TABLE `ea_users` DROP FOREIGN KEY `users_roles`'); + $this->db->query('ALTER TABLE `ea_user_settings` DROP FOREIGN KEY `user_settings_users`'); // Add table constraints again. $this->db->query('ALTER TABLE `ea_appointments` diff --git a/application/migrations/012_create_consents_table.php b/application/migrations/012_create_consents_table.php new file mode 100644 index 00000000..85956c6d --- /dev/null +++ b/application/migrations/012_create_consents_table.php @@ -0,0 +1,133 @@ + + * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.3.2 + * ---------------------------------------------------------------------------- */ + +/** + * Class Migration_Create_consents_table + * + * @property CI_DB_query_builder db + * @property CI_DB_forge dbforge + */ +class Migration_Create_consents_table extends CI_Migration { + /** + * Upgrade method. + */ + public function up() + { + $this->db->insert('ea_settings', [ + 'name' => 'display_cookie_notice', + 'value' => '0' + ]); + + $this->db->insert('ea_settings', [ + 'name' => 'cookie_notice_content', + 'value' => 'Cookie notice content.' + ]); + + $this->db->insert('ea_settings', [ + 'name' => 'display_terms_and_conditions', + 'value' => '0' + ]); + + $this->db->insert('ea_settings', [ + 'name' => 'terms_and_conditions_content', + 'value' => 'Terms and conditions content.' + ]); + + $this->db->insert('ea_settings', [ + 'name' => 'display_privacy_policy', + 'value' => '0' + ]); + + $this->db->insert('ea_settings', [ + 'name' => 'privacy_policy_content', + 'value' => 'Privacy policy content.' + ]); + + $this->dbforge->add_field([ + 'id' => [ + 'type' => 'INT', + 'constraint' => 11, + 'auto_increment' => TRUE + ], + 'created' => [ + 'type' => 'TIMESTAMP', + 'null' => TRUE + ], + 'modified' => [ + 'type' => 'TIMESTAMP', + 'null' => TRUE + ], + 'first_name' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE, + ], + 'last_name' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE, + ], + 'email' => [ + 'type' => 'VARCHAR', + 'constraint' => '512', + 'null' => TRUE, + ], + 'ip' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE, + ], + 'type' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'null' => TRUE, + ], + ]); + + $this->dbforge->add_key('id', TRUE); + + $this->dbforge->create_table('ea_consents', TRUE, ['engine' => 'InnoDB']); + } + + /** + * Downgrade method. + */ + public function down() + { + $this->db->delete('ea_settings', [ + 'name' => 'display_cookie_notice' + ]); + + $this->db->delete('ea_settings', [ + 'name' => 'cookie_notice_content' + ]); + + $this->db->delete('ea_settings', [ + 'name' => 'display_terms_and_conditions' + ]); + + $this->db->delete('ea_settings', [ + 'name' => 'terms_and_conditions_content' + ]); + + $this->db->delete('ea_settings', [ + 'name' => 'display_privacy_policy' + ]); + + $this->db->delete('ea_settings', [ + 'name' => 'privacy_policy_content' + ]); + + $this->dbforge->drop_table('ea_consents'); + } +} diff --git a/application/migrations/012_legal_contents.php b/application/migrations/012_legal_contents.php deleted file mode 100644 index 72f7c4ba..00000000 --- a/application/migrations/012_legal_contents.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.3.2 - * ---------------------------------------------------------------------------- */ - -/** - * Class Migration_Legal_contents - * - * @property CI_Loader load - * @property CI_DB_query_builder db - * @property CI_DB_forge dbforge - * @property Settings_Model settings_model - */ -class Migration_Legal_contents extends CI_Migration { - /** - * Upgrade method. - */ - public function up() - { - $this->db->insert('ea_settings', ['name' => 'display_cookie_notice', 'value' => '0']); - $this->db->insert('ea_settings', ['name' => 'cookie_notice_content', 'value' => 'Cookie notice content.']); - $this->db->insert('ea_settings', ['name' => 'display_terms_and_conditions', 'value' => '0']); - $this->db->insert('ea_settings', - ['name' => 'terms_and_conditions_content', 'value' => 'Terms and conditions content.']); - $this->db->insert('ea_settings', ['name' => 'display_privacy_policy', 'value' => '0']); - $this->db->insert('ea_settings', ['name' => 'privacy_policy_content', 'value' => 'Privacy policy content.']); - - $this->db->query(' - CREATE TABLE IF NOT EXISTS `ea_consents` ( - `id` INT(11) NOT NULL AUTO_INCREMENT, - `modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP - ON UPDATE CURRENT_TIMESTAMP, - `created` TIMESTAMP, - `first_name` VARCHAR(256), - `last_name` VARCHAR(256), - `email` VARCHAR(512), - `ip` VARCHAR(256), - `type` VARCHAR(256), - PRIMARY KEY (`id`) - ) - ENGINE = InnoDB - DEFAULT CHARSET = utf8; - '); - } - - /** - * Downgrade method. - */ - public function down() - { - $this->db->delete('ea_settings', ['name' => 'display_cookie_notice']); - $this->db->delete('ea_settings', ['name' => 'cookie_notice_content']); - $this->db->delete('ea_settings', ['name' => 'display_terms_and_conditions']); - $this->db->delete('ea_settings', ['name' => 'terms_and_conditions_content']); - $this->db->delete('ea_settings', ['name' => 'display_privacy_policy']); - $this->db->delete('ea_settings', ['name' => 'privacy_policy_content']); - - $this->db->query('DROP TABLE `ea_consents`;'); - } -} diff --git a/application/migrations/013_add_weekday_start_setting.php b/application/migrations/013_add_weekday_start_setting.php index 0e3889cd..a086d894 100644 --- a/application/migrations/013_add_weekday_start_setting.php +++ b/application/migrations/013_add_weekday_start_setting.php @@ -14,37 +14,19 @@ /** * Class Migration_Add_weekday_start_setting * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_weekday_start_setting extends CI_Migration { - /** - * Migration_Add_weekday_start_setting constructor. - * - * @param array $config - */ - public function __construct($config = []) - { - parent::__construct($config); - - $this->load->model('settings_model'); - } - /** * Upgrade method. */ public function up() { - try - { - $this->settings_model->get_setting('first_weekday'); - } - catch (Exception $exception) - { - $this->settings_model->set_setting('first_weekday', 'sunday'); - } + $this->db->insert('ea_settings', [ + 'name' => 'first_weekday', + 'value' => 'sunday' + ]); } /** @@ -52,6 +34,6 @@ class Migration_Add_weekday_start_setting extends CI_Migration { */ public function down() { - $this->settings_model->remove_setting('first_weekday'); + $this->db->delete('ea_settings', ['name' => 'first_weekday']); } } diff --git a/application/migrations/014_add_appointment_location_column.php b/application/migrations/014_create_appointment_location_column.php similarity index 87% rename from application/migrations/014_add_appointment_location_column.php rename to application/migrations/014_create_appointment_location_column.php index 12a8f206..7425102a 100644 --- a/application/migrations/014_add_appointment_location_column.php +++ b/application/migrations/014_create_appointment_location_column.php @@ -12,14 +12,12 @@ * ---------------------------------------------------------------------------- */ /** - * Class Migration_add_appointment_location_column + * Class Migration_Create_appointment_location_column * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ -class Migration_add_appointment_location_column extends CI_Migration { +class Migration_Create_appointment_location_column extends CI_Migration { /** * Upgrade method. */ diff --git a/application/migrations/015_add_user_extra_working_plan.php b/application/migrations/015_add_extra_working_plan_to_user_settings.php similarity index 86% rename from application/migrations/015_add_user_extra_working_plan.php rename to application/migrations/015_add_extra_working_plan_to_user_settings.php index e83ec271..f200c5aa 100644 --- a/application/migrations/015_add_user_extra_working_plan.php +++ b/application/migrations/015_add_extra_working_plan_to_user_settings.php @@ -12,14 +12,12 @@ * ---------------------------------------------------------------------------- */ /** - * Class Migration_Add_user_extra_working_plan + * Class Migration_Add_extra_working_plan_to_user_settings * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ -class Migration_Add_user_extra_working_plan extends CI_Migration { +class Migration_Add_extra_working_plan_to_user_settings extends CI_Migration { /** * Upgrade method. */ @@ -31,7 +29,6 @@ class Migration_Add_user_extra_working_plan extends CI_Migration { 'extra_working_plan' => [ 'type' => 'TEXT', 'null' => TRUE, - 'default' => '', 'after' => 'working_plan' ] ]; diff --git a/application/migrations/016_add_require_phone_number_setting.php b/application/migrations/016_add_require_phone_number_setting.php index 43a85eab..4c5fd6c7 100644 --- a/application/migrations/016_add_require_phone_number_setting.php +++ b/application/migrations/016_add_require_phone_number_setting.php @@ -14,37 +14,19 @@ /** * Class Migration_Add_require_phone_number_setting * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_require_phone_number_setting extends CI_Migration { - /** - * Migration_Add_require_phone_number_setting constructor. - * - * @param array $config - */ - public function __construct($config = []) - { - parent::__construct($config); - - $this->load->model('settings_model'); - } - /** * Upgrade method. */ public function up() { - try - { - $this->settings_model->get_setting('require_phone_number'); - } - catch (Exception $exception) - { - $this->settings_model->set_setting('require_phone_number', '1'); - } + $this->db->insert('ea_settings', [ + 'name' => 'require_phone_number', + 'value' => '1' + ]); } /** @@ -52,6 +34,6 @@ class Migration_Add_require_phone_number_setting extends CI_Migration { */ public function down() { - $this->settings_model->remove_setting('require_phone_number'); + $this->db->delete('ea_settings', ['name' => 'require_phone_number']); } } diff --git a/application/migrations/017_add_api_token_setting.php b/application/migrations/017_add_api_token_setting.php index a31b65da..0e858b24 100644 --- a/application/migrations/017_add_api_token_setting.php +++ b/application/migrations/017_add_api_token_setting.php @@ -14,24 +14,10 @@ /** * Class Migration_Add_api_token_setting * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_api_token_setting extends CI_Migration { - /** - * Migration_Add_api_token_setting constructor. - * - * @param array $config - */ - public function __construct($config = []) - { - parent::__construct($config); - - $this->load->model('settings_model'); - } - /** * Upgrade method. * @@ -39,14 +25,10 @@ class Migration_Add_api_token_setting extends CI_Migration { */ public function up() { - try - { - $this->settings_model->get_setting('api_token'); - } - catch (Exception $exception) - { - $this->settings_model->set_setting('api_token', ''); - } + $this->db->insert('ea_settings', [ + 'name' => 'api_token', + 'value' => '' + ]); } /** @@ -56,6 +38,6 @@ class Migration_Add_api_token_setting extends CI_Migration { */ public function down() { - $this->settings_model->remove_setting('api_token'); + $this->db->delete('ea_settings', ['name' => 'api_token']); } } diff --git a/application/migrations/018_add_timezone_columns.php b/application/migrations/018_add_timezone_columns.php deleted file mode 100644 index 5a78e6ec..00000000 --- a/application/migrations/018_add_timezone_columns.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.4.0 - * ---------------------------------------------------------------------------- */ - -/** - * Class Migration_Add_timezone_columns - * - * @property CI_Loader load - * @property CI_DB_query_builder db - * @property CI_DB_forge dbforge - * @property Settings_Model settings_model - */ -class Migration_Add_timezone_columns extends CI_Migration { - /** - * Upgrade method. - */ - public function up() - { - $this->db->query(' - ALTER TABLE `ea_users` - ADD `timezone` VARCHAR(256) DEFAULT "UTC" AFTER `notes`; - '); - } - - /** - * Downgrade method. - */ - public function down() - { - $this->db->query(' - ALTER TABLE `ea_users` - DROP COLUMN `timezone`; - '); - } -} diff --git a/application/migrations/001_specific_calendar_sync.php b/application/migrations/018_add_timezone_to_users.php similarity index 61% rename from application/migrations/001_specific_calendar_sync.php rename to application/migrations/018_add_timezone_to_users.php index 9a264dc9..42342ab4 100644 --- a/application/migrations/001_specific_calendar_sync.php +++ b/application/migrations/018_add_timezone_to_users.php @@ -8,31 +8,33 @@ * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 * @link http://easyappointments.org - * @since v1.0.0 + * @since v1.4.0 * ---------------------------------------------------------------------------- */ /** - * Class Migration_Specific_calendar_sync + * Class Migration_Add_timezone_to_users * * @property CI_DB_query_builder db * @property CI_DB_forge dbforge */ -class Migration_Specific_calendar_sync extends CI_Migration { +class Migration_Add_timezone_to_users extends CI_Migration { /** * Upgrade method. */ public function up() { - if ( ! $this->db->field_exists('google_calendar', 'ea_user_settings')) + if ( ! $this->db->field_exists('timezone', 'ea_users')) { $fields = [ - 'google_calendar' => [ + 'timezone' => [ 'type' => 'VARCHAR', - 'constraint' => '128', - 'null' => TRUE + 'constraint' => '256', + 'default' => 'UTC', + 'after' => 'notes' ] ]; - $this->dbforge->add_column('ea_user_settings', $fields); + + $this->dbforge->add_column('ea_users', $fields); } } @@ -41,9 +43,6 @@ class Migration_Specific_calendar_sync extends CI_Migration { */ public function down() { - if ($this->db->field_exists('google_calendar', 'ea_user_settings')) - { - $this->dbforge->drop_column('ea_user_settings', 'google_calendar'); - } + $this->dbforge->drop_column('ea_users', 'timezone'); } } diff --git a/application/migrations/019_add_display_any_provider_setting.php b/application/migrations/019_add_display_any_provider_setting.php index dc2743a6..4f9e2650 100644 --- a/application/migrations/019_add_display_any_provider_setting.php +++ b/application/migrations/019_add_display_any_provider_setting.php @@ -14,10 +14,8 @@ /** * Class Migration_Add_display_any_provider_setting * - * @property CI_Loader load * @property CI_DB_query_builder db * @property CI_DB_forge dbforge - * @property Settings_Model settings_model */ class Migration_Add_display_any_provider_setting extends CI_Migration { /**