From df1d4fdeea6c8687387f2e20307990b0f01f96f3 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 18 Jan 2022 18:21:23 +0100 Subject: [PATCH] Add color columns on service and appointment tables (#422). --- ...026_add_color_column_to_services_table.php | 49 +++++++++++++++++++ ...add_color_column_to_appointments_table.php | 49 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 application/migrations/026_add_color_column_to_services_table.php create mode 100644 application/migrations/027_add_color_column_to_appointments_table.php diff --git a/application/migrations/026_add_color_column_to_services_table.php b/application/migrations/026_add_color_column_to_services_table.php new file mode 100644 index 00000000..62a9a77c --- /dev/null +++ b/application/migrations/026_add_color_column_to_services_table.php @@ -0,0 +1,49 @@ + + * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.4.0 + * ---------------------------------------------------------------------------- */ + +/** + * @property CI_DB_query_builder db + * @property CI_DB_forge $dbforge + */ +class Migration_Add_color_column_to_services_table extends CI_Migration { + /** + * Upgrade method. + */ + public function up() + { + if ( ! $this->db->field_exists('color', 'services')) + { + $fields = [ + 'color' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'default' => '#4c95d2', + 'after' => 'description' + ] + ]; + + $this->dbforge->add_column('services', $fields); + } + } + + /** + * Downgrade method. + */ + public function down() + { + if ( ! $this->db->field_exists('color', 'services')) + { + $this->dbforge->drop_column('services', 'color'); + } + } +} diff --git a/application/migrations/027_add_color_column_to_appointments_table.php b/application/migrations/027_add_color_column_to_appointments_table.php new file mode 100644 index 00000000..faccd88b --- /dev/null +++ b/application/migrations/027_add_color_column_to_appointments_table.php @@ -0,0 +1,49 @@ + + * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.4.0 + * ---------------------------------------------------------------------------- */ + +/** + * @property CI_DB_query_builder db + * @property CI_DB_forge $dbforge + */ +class Migration_Add_color_column_to_appointments_table extends CI_Migration { + /** + * Upgrade method. + */ + public function up() + { + if ( ! $this->db->field_exists('color', 'appointments')) + { + $fields = [ + 'color' => [ + 'type' => 'VARCHAR', + 'constraint' => '256', + 'default' => '#4c95d2', + 'after' => 'hash' + ] + ]; + + $this->dbforge->add_column('appointments', $fields); + } + } + + /** + * Downgrade method. + */ + public function down() + { + if ( ! $this->db->field_exists('color', 'appointments')) + { + $this->dbforge->drop_column('appointments', 'color'); + } + } +}