diff --git a/src/application/migrations/006_add_calendar_view_setting.php b/src/application/migrations/006_add_calendar_view_setting.php index 5dd85847..437b2c43 100644 --- a/src/application/migrations/006_add_calendar_view_setting.php +++ b/src/application/migrations/006_add_calendar_view_setting.php @@ -16,17 +16,21 @@ class Migration_Add_calendar_view_setting extends CI_Migration { { $this->load->dbforge(); - $fields = [ - 'calendar_view' => [ - 'type' => 'VARCHAR', - 'constraint' => '32', - 'default' => 'default' - ] - ]; + $fields = $this->db->list_fields('ea_user_settings'); - $this->dbforge->add_column('ea_user_settings', $fields); - - $this->db->update('ea_user_settings', ['calendar_view' => 'default']); + if (!in_array('calendar_view', $fields, true)) { + $fields = [ + 'calendar_view' => [ + 'type' => 'VARCHAR', + 'constraint' => '32', + 'default' => 'default' + ] + ]; + + $this->dbforge->add_column('ea_user_settings', $fields); + + $this->db->update('ea_user_settings', ['calendar_view' => 'default']); + } } public function down() diff --git a/src/application/migrations/007_add_service_availabilities_type.php b/src/application/migrations/007_add_service_availabilities_type.php index 58c8fcbf..c9cf2659 100644 --- a/src/application/migrations/007_add_service_availabilities_type.php +++ b/src/application/migrations/007_add_service_availabilities_type.php @@ -14,25 +14,26 @@ class Migration_Add_service_availabilities_type extends CI_Migration { public function up() { - $this->load->dbforge(); - - $fields = [ - 'availabilities_type' => [ - 'type' => 'VARCHAR', - 'constraint' => '32', - 'default' => 'flexible', - 'after' => 'description' - ] - ]; - - $this->dbforge->add_column('ea_services', $fields); - - $this->db->update('ea_services', ['availabilities_type' => 'flexible']); + if (!$this->db->field_exists('availabilities_type', 'ea_services')) { + $fields = [ + 'availabilities_type' => [ + 'type' => 'VARCHAR', + 'constraint' => '32', + 'default' => 'flexible', + 'after' => 'description' + ] + ]; + + $this->dbforge->add_column('ea_services', $fields); + + $this->db->update('ea_services', ['availabilities_type' => 'flexible']); + } } public function down() { - $this->load->dbforge(); - $this->dbforge->drop_column('ea_services', 'availabilities_type'); + if ($this->db->field_exists('availabilities_type', 'ea_services')) { + $this->dbforge->drop_column('ea_services', 'availabilities_type'); + } } } diff --git a/src/application/migrations/008_add_service_attendants_number.php b/src/application/migrations/008_add_service_attendants_number.php index 1699c724..555a74b9 100644 --- a/src/application/migrations/008_add_service_attendants_number.php +++ b/src/application/migrations/008_add_service_attendants_number.php @@ -14,25 +14,26 @@ class Migration_Add_service_attendants_number extends CI_Migration { public function up() { - $this->load->dbforge(); - - $fields = [ - 'attendants_number' => [ - 'type' => 'INT', - 'constraint' => '11', - 'default' => '1', - 'after' => 'availabilities_type' - ] - ]; - - $this->dbforge->add_column('ea_services', $fields); - - $this->db->update('ea_services', ['attendants_number' => '1']); + if (!$this->db->field_exists('attendants_number', 'ea_services')) { + $fields = [ + 'attendants_number' => [ + 'type' => 'INT', + 'constraint' => '11', + 'default' => '1', + 'after' => 'availabilities_type' + ] + ]; + + $this->dbforge->add_column('ea_services', $fields); + + $this->db->update('ea_services', ['attendants_number' => '1']); + } } public function down() { - $this->load->dbforge(); - $this->dbforge->drop_column('ea_services', 'attendants_number'); + if (!$this->db->field_exists('attendants_number', 'ea_services')) { + $this->dbforge->drop_column('ea_services', 'attendants_number'); + } } } diff --git a/src/application/migrations/009_change_column_types.php b/src/application/migrations/009_change_column_types.php index 7748247a..87c707ae 100644 --- a/src/application/migrations/009_change_column_types.php +++ b/src/application/migrations/009_change_column_types.php @@ -14,8 +14,6 @@ class Migration_Change_column_types extends CI_Migration { public function up() { - $this->load->dbforge(); - // Appointments $fields = [ 'id' => [ @@ -189,8 +187,6 @@ class Migration_Change_column_types extends CI_Migration { public function down() { - $this->load->dbforge(); - // Appointments $fields = [ 'id' => [