mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-28 10:53:40 +03:00
Renamed the id_service_categories field of services to id_categories
This commit is contained in:
parent
777dcb0d9e
commit
16863bcf5b
1 changed files with 66 additions and 0 deletions
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue