Renamed the id_service_categories field of services to id_categories

This commit is contained in:
Alex Tselegidis 2021-12-15 07:45:41 +01:00
parent 777dcb0d9e
commit 16863bcf5b
1 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,66 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */
class Migration_Rename_id_service_categories_column_of_services_table extends EA_Migration {
/**
* Upgrade method.
*/
public function up()
{
if ($this->db->field_exists('id_service_categories', 'services'))
{
$this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` DROP FOREIGN KEY `services_service_categories`');
$fields = [
'id_service_categories' => [
'name' => 'id_categories',
'type' => 'INT',
'constraint' => '11'
]
];
$this->dbforge->modify_column('services', $fields);
$this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '`
ADD CONSTRAINT `services_categories` FOREIGN KEY (`id_categories`) REFERENCES `' . $this->db->dbprefix('categories') . '` (`id`)
ON DELETE SET NULL
ON UPDATE CASCADE');
}
}
/**
* Downgrade method.
*/
public function down()
{
if ($this->db->field_exists('id_categories', 'services'))
{
$this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '` DROP FOREIGN KEY `services_categories`');
$fields = [
'id_categories' => [
'name' => 'id_service_categories',
'type' => 'INT',
'constraint' => '11'
]
];
$this->dbforge->modify_column('services', $fields);
$this->db->query('ALTER TABLE `' . $this->db->dbprefix('services') . '`
ADD CONSTRAINT `services_service_categories` FOREIGN KEY (`id_categories`) REFERENCES `' . $this->db->dbprefix('categories') . '` (`id`)
ON DELETE SET NULL
ON UPDATE CASCADE');
}
}
}