From 3d0d1f20055868f642504292f3d8d4342d9c504a Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 29 Mar 2020 12:47:57 +0200 Subject: [PATCH] Added timezone fields to the database (#313). --- application/config/migration.php | 2 +- .../migrations/018_add_timezone_columns.php | 40 +++++++++++++++++++ assets/sql/data.sql | 2 +- assets/sql/structure.sql | 6 ++- 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 application/migrations/018_add_timezone_columns.php diff --git a/application/config/migration.php b/application/config/migration.php index 67f170a7..78e384e4 100755 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -37,7 +37,7 @@ $config['migration_table'] = 'ea_migrations'; | be upgraded / downgraded to. | */ -$config['migration_version'] = 17; // current +$config['migration_version'] = 18; // current /* diff --git a/application/migrations/018_add_timezone_columns.php b/application/migrations/018_add_timezone_columns.php new file mode 100644 index 00000000..d02d1a39 --- /dev/null +++ b/application/migrations/018_add_timezone_columns.php @@ -0,0 +1,40 @@ + + * @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_add_timezone_columns extends CI_Migration { + public function up() + { + $this->db->query(' + ALTER TABLE `ea_appointments` + ADD `timezone` VARCHAR(256) NULL AFTER `end_datetime`; + '); + + $this->db->query(' + ALTER TABLE `ea_users` + ADD `timezone` VARCHAR(256) NULL AFTER `notes`; + '); + } + + public function down() + { + $this->db->query(' + ALTER TABLE `ea_appointments` + DROP COLUMN `timezone`; + '); + + $this->db->query(' + ALTER TABLE `ea_users` + DROP COLUMN `timezone`; + '); + } +} diff --git a/assets/sql/data.sql b/assets/sql/data.sql index 02d109cc..1fcb2f11 100644 --- a/assets/sql/data.sql +++ b/assets/sql/data.sql @@ -27,4 +27,4 @@ VALUES ('require_phone_number', '1'), ('api_token', ''); -INSERT INTO `ea_migrations` VALUES ('16'); +INSERT INTO `ea_migrations` VALUES ('18'); diff --git a/assets/sql/structure.sql b/assets/sql/structure.sql index 567f4a1f..c65b30df 100755 --- a/assets/sql/structure.sql +++ b/assets/sql/structure.sql @@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS `ea_appointments` ( `book_datetime` DATETIME, `start_datetime` DATETIME, `end_datetime` DATETIME, + `timezone` VARCHAR(256), `location` TEXT, `notes` TEXT, `hash` TEXT, @@ -24,9 +25,9 @@ CREATE TABLE IF NOT EXISTS `ea_appointments` ( 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, + `modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ON UPDATE CURRENT_TIMESTAMP, `first_name` VARCHAR(256), `last_name` VARCHAR(256), `email` VARCHAR(512), @@ -131,6 +132,7 @@ CREATE TABLE IF NOT EXISTS `ea_users` ( `state` VARCHAR(128), `zip_code` VARCHAR(64), `notes` TEXT, + `timezone` VARCHAR(256), `id_roles` INT(11) NOT NULL, PRIMARY KEY (`id`), KEY `id_roles` (`id_roles`)