2020-04-23 21:35:21 +03:00
|
|
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
2022-01-18 15:05:42 +03:00
|
|
|
* Easy!Appointments - Online Appointment Scheduler
|
2020-04-23 21:35:21 +03:00
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2021-12-18 19:43:45 +03:00
|
|
|
* @copyright Copyright (c) Alex Tselegidis
|
|
|
|
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link https://easyappointments.org
|
2020-04-23 21:35:21 +03:00
|
|
|
* @since v1.4.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
2021-10-29 11:19:10 +03:00
|
|
|
/*
|
2020-05-02 14:18:05 +03:00
|
|
|
* Notice: This first migration got altered to include the creation of the initial database structure so that external
|
|
|
|
* SQL are not required.
|
2020-04-23 21:35:21 +03:00
|
|
|
*/
|
2021-10-29 11:19:10 +03:00
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
class Migration_Specific_calendar_sync extends EA_Migration
|
|
|
|
{
|
2020-04-23 21:35:21 +03:00
|
|
|
/**
|
|
|
|
* Upgrade method.
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
$this->dbforge->add_field([
|
|
|
|
'id' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'auto_increment' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'book_datetime' => [
|
|
|
|
'type' => 'DATETIME',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'start_datetime' => [
|
|
|
|
'type' => 'DATETIME',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'end_datetime' => [
|
|
|
|
'type' => 'DATETIME',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'notes' => [
|
|
|
|
'type' => 'TEXT',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'hash' => [
|
|
|
|
'type' => 'TEXT',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
2022-01-18 14:54:41 +03:00
|
|
|
'is_unavailability' => [
|
2020-04-23 21:35:21 +03:00
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'default' => '0',
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'id_users_provider' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'id_users_customer' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'id_services' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'id_google_calendar' => [
|
|
|
|
'type' => 'TEXT',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
|
|
|
],
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->add_key('id', true);
|
2020-04-23 21:35:21 +03:00
|
|
|
$this->dbforge->add_key('id_users_provider');
|
|
|
|
$this->dbforge->add_key('id_users_customer');
|
|
|
|
$this->dbforge->add_key('id_services');
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->create_table('appointments', true, ['engine' => 'InnoDB']);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
|
|
|
$this->dbforge->add_field([
|
|
|
|
'id' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'auto_increment' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'name' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '256',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'slug' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '256',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'is_admin' => [
|
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'appointments' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'customers' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'services' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'users' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'system_settings' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'user_settings' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
|
|
|
],
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->add_key('id', true);
|
|
|
|
$this->dbforge->create_table('roles', true, ['engine' => 'InnoDB']);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
|
|
|
$this->dbforge->add_field([
|
|
|
|
'id_users_secretary' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-12-22 13:35:41 +03:00
|
|
|
'unsigned' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'id_users_provider' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-12-22 13:35:41 +03:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->add_key('id_users_secretary', true);
|
|
|
|
$this->dbforge->add_key('id_users_provider', true);
|
|
|
|
$this->dbforge->create_table('secretaries_providers', true, ['engine' => 'InnoDB']);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
|
|
|
$this->dbforge->add_field([
|
|
|
|
'id' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'auto_increment' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'name' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '256',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'duration' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'constraint' => '11',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'price' => [
|
|
|
|
'type' => 'DECIMAL',
|
|
|
|
'constraint' => '10,2',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'currency' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '32',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'description' => [
|
|
|
|
'type' => 'TEXT',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'id_service_categories' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
|
|
|
],
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->add_key('id', true);
|
2020-04-23 21:35:21 +03:00
|
|
|
$this->dbforge->add_key('id_service_categories');
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->create_table('services', true, ['engine' => 'InnoDB']);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
|
|
|
$this->dbforge->add_field([
|
|
|
|
'id_users' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-12-22 13:35:41 +03:00
|
|
|
'unsigned' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'id_services' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-12-22 13:35:41 +03:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->add_key('id_users', true);
|
|
|
|
$this->dbforge->add_key('id_services', true);
|
|
|
|
$this->dbforge->create_table('services_providers', true, ['engine' => 'InnoDB']);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
|
|
|
$this->dbforge->add_field([
|
|
|
|
'id' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'auto_increment' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'name' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '256',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'description' => [
|
|
|
|
'type' => 'TEXT',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
|
|
|
],
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->add_key('id', true);
|
2020-04-23 21:35:21 +03:00
|
|
|
$this->dbforge->add_key('id_service_categories');
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->create_table('service_categories', true, ['engine' => 'InnoDB']);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
|
|
|
$this->dbforge->add_field([
|
|
|
|
'id' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'auto_increment' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'name' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '512',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'value' => [
|
|
|
|
'type' => 'LONGTEXT',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
|
|
|
],
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->add_key('id', true);
|
|
|
|
$this->dbforge->create_table('settings', true, ['engine' => 'InnoDB']);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
|
|
|
$this->dbforge->add_field([
|
|
|
|
'id' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-11-29 12:24:09 +03:00
|
|
|
'unsigned' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'auto_increment' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'first_name' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '256',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'last_name' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '512',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'email' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '512',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'mobile_number' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '128',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'phone_number' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '128',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'address' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '256',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'city' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '256',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'state' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '128',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'zip_code' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '64',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'notes' => [
|
|
|
|
'type' => 'TEXT',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'id_roles' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-12-22 13:35:41 +03:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->add_key('id', true);
|
2020-04-23 21:35:21 +03:00
|
|
|
$this->dbforge->add_key('id_roles');
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->create_table('users', true, ['engine' => 'InnoDB']);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
|
|
|
$this->dbforge->add_field([
|
|
|
|
'id_users' => [
|
|
|
|
'type' => 'BIGINT',
|
|
|
|
'constraint' => '20',
|
2023-12-22 13:35:41 +03:00
|
|
|
'unsigned' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'username' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '256',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'password' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '512',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'salt' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '512',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'working_plan' => [
|
|
|
|
'type' => 'TEXT',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'notifications' => [
|
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'google_sync' => [
|
|
|
|
'type' => 'TINYINT',
|
|
|
|
'constraint' => '4',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'google_token' => [
|
|
|
|
'type' => 'TEXT',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'google_calendar' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => '128',
|
2023-12-22 13:35:41 +03:00
|
|
|
'null' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'sync_past_days' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'constraint' => '11',
|
2023-11-29 12:24:09 +03:00
|
|
|
'null' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'default' => '5',
|
2020-04-23 21:35:21 +03:00
|
|
|
],
|
|
|
|
'sync_future_days' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'constraint' => '11',
|
2023-11-29 12:24:09 +03:00
|
|
|
'null' => true,
|
2023-12-22 13:35:41 +03:00
|
|
|
'default' => '5',
|
|
|
|
],
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->dbforge->add_key('id_users', true);
|
|
|
|
$this->dbforge->create_table('user_settings', true, ['engine' => 'InnoDB']);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->db->query(
|
|
|
|
'
|
|
|
|
ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
|
|
|
'`
|
|
|
|
ADD CONSTRAINT `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
|
|
|
'_ibfk_2` FOREIGN KEY (`id_users_customer`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('users') .
|
|
|
|
'` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
ADD CONSTRAINT `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
|
|
|
'_ibfk_3` FOREIGN KEY (`id_services`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('services') .
|
|
|
|
'` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
ADD CONSTRAINT `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
|
|
|
'_ibfk_4` FOREIGN KEY (`id_users_provider`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('users') .
|
|
|
|
'` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
2023-12-22 13:35:41 +03:00
|
|
|
',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->db->query(
|
|
|
|
'
|
|
|
|
ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('secretaries_providers') .
|
|
|
|
'`
|
|
|
|
ADD CONSTRAINT `fk_' .
|
|
|
|
$this->db->dbprefix('secretaries_providers') .
|
|
|
|
'_1` FOREIGN KEY (`id_users_secretary`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('users') .
|
|
|
|
'` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
ADD CONSTRAINT `fk_' .
|
|
|
|
$this->db->dbprefix('secretaries_providers') .
|
|
|
|
'_2` FOREIGN KEY (`id_users_provider`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('users') .
|
|
|
|
'` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
2023-12-22 13:35:41 +03:00
|
|
|
',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->db->query(
|
|
|
|
'
|
|
|
|
ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('services') .
|
|
|
|
'`
|
|
|
|
ADD CONSTRAINT `' .
|
|
|
|
$this->db->dbprefix('services') .
|
|
|
|
'_ibfk_1` FOREIGN KEY (`id_service_categories`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('service_categories') .
|
|
|
|
'` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
2023-12-22 13:35:41 +03:00
|
|
|
',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->db->query(
|
|
|
|
'
|
|
|
|
ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('services_providers') .
|
|
|
|
'`
|
|
|
|
ADD CONSTRAINT `' .
|
|
|
|
$this->db->dbprefix('services_providers') .
|
|
|
|
'_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('users') .
|
|
|
|
'` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
ADD CONSTRAINT `' .
|
|
|
|
$this->db->dbprefix('services_providers') .
|
|
|
|
'_ibfk_2` FOREIGN KEY (`id_services`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('services') .
|
|
|
|
'` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
2023-12-22 13:35:41 +03:00
|
|
|
',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->db->query(
|
|
|
|
'
|
|
|
|
ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('users') .
|
|
|
|
'`
|
|
|
|
ADD CONSTRAINT `' .
|
|
|
|
$this->db->dbprefix('users') .
|
|
|
|
'_ibfk_1` FOREIGN KEY (`id_roles`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('roles') .
|
|
|
|
'` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
2023-12-22 13:35:41 +03:00
|
|
|
',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->db->query(
|
|
|
|
'
|
|
|
|
ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('user_settings') .
|
|
|
|
'`
|
|
|
|
ADD CONSTRAINT `' .
|
|
|
|
$this->db->dbprefix('user_settings') .
|
|
|
|
'_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `' .
|
|
|
|
$this->db->dbprefix('users') .
|
|
|
|
'` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
2020-04-23 21:35:21 +03:00
|
|
|
|
2023-12-22 13:35:41 +03:00
|
|
|
',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
2020-04-23 21:48:20 +03:00
|
|
|
$this->db->insert('roles', [
|
2020-04-23 21:35:21 +03:00
|
|
|
'name' => 'Administrator',
|
|
|
|
'slug' => 'admin',
|
2023-11-29 12:24:09 +03:00
|
|
|
'is_admin' => true,
|
2020-04-23 21:35:21 +03:00
|
|
|
'appointments' => 15,
|
|
|
|
'customers' => 15,
|
|
|
|
'services' => 15,
|
|
|
|
'users' => 15,
|
|
|
|
'system_settings' => 15,
|
2023-12-22 13:35:41 +03:00
|
|
|
'user_settings' => 15,
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
|
|
|
|
2020-04-23 21:48:20 +03:00
|
|
|
$this->db->insert('roles', [
|
2020-04-23 21:35:21 +03:00
|
|
|
'name' => 'Provider',
|
|
|
|
'slug' => 'provider',
|
2023-11-29 12:24:09 +03:00
|
|
|
'is_admin' => false,
|
2020-04-23 21:35:21 +03:00
|
|
|
'appointments' => 15,
|
|
|
|
'customers' => 15,
|
|
|
|
'services' => 0,
|
|
|
|
'users' => 0,
|
|
|
|
'system_settings' => 0,
|
2023-12-22 13:35:41 +03:00
|
|
|
'user_settings' => 15,
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
|
|
|
|
2020-04-23 21:48:20 +03:00
|
|
|
$this->db->insert('roles', [
|
2020-04-23 21:35:21 +03:00
|
|
|
'name' => 'Customer',
|
|
|
|
'slug' => 'customer',
|
2023-11-29 12:24:09 +03:00
|
|
|
'is_admin' => false,
|
2020-04-23 21:35:21 +03:00
|
|
|
'appointments' => 0,
|
|
|
|
'customers' => 0,
|
|
|
|
'services' => 0,
|
|
|
|
'users' => 0,
|
|
|
|
'system_settings' => 0,
|
2023-12-22 13:35:41 +03:00
|
|
|
'user_settings' => 0,
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
|
|
|
|
2020-04-23 21:48:20 +03:00
|
|
|
$this->db->insert('roles', [
|
2020-04-23 21:35:21 +03:00
|
|
|
'name' => 'Secretary',
|
|
|
|
'slug' => 'secretary',
|
2023-11-29 12:24:09 +03:00
|
|
|
'is_admin' => false,
|
2020-04-23 21:35:21 +03:00
|
|
|
'appointments' => 15,
|
|
|
|
'customers' => 15,
|
|
|
|
'services' => 0,
|
|
|
|
'users' => 0,
|
|
|
|
'system_settings' => 0,
|
2023-12-22 13:35:41 +03:00
|
|
|
'user_settings' => 15,
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
|
|
|
|
2020-04-23 21:48:20 +03:00
|
|
|
$this->db->insert('settings', [
|
2020-04-23 21:35:21 +03:00
|
|
|
'name' => 'company_working_plan',
|
2023-11-29 12:24:09 +03:00
|
|
|
'value' =>
|
2023-12-22 13:35:41 +03:00
|
|
|
'{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"saturday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]},"sunday":{"start":"09:00","end":"18:00","breaks":[{"start":"14:30","end":"15:00"}]}}',
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
|
|
|
|
2020-04-23 21:48:20 +03:00
|
|
|
$this->db->insert('settings', [
|
2020-04-23 21:35:21 +03:00
|
|
|
'name' => 'book_advance_timeout',
|
2023-12-22 13:35:41 +03:00
|
|
|
'value' => '30',
|
2020-04-23 21:35:21 +03:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Downgrade method.
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
2023-11-29 12:24:09 +03:00
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
|
|
|
'` DROP FOREIGN KEY `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_ibfk_2`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
|
|
|
'` DROP FOREIGN KEY `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_ibfk_3`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
|
|
|
'` DROP FOREIGN KEY `' .
|
|
|
|
$this->db->dbprefix('appointments') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_ibfk_4`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('secretaries_providers') .
|
|
|
|
'` DROP FOREIGN KEY `fk_' .
|
|
|
|
$this->db->dbprefix('secretaries_providers') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_1`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('secretaries_providers') .
|
|
|
|
'` DROP FOREIGN KEY `fk_' .
|
|
|
|
$this->db->dbprefix('secretaries_providers') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_2`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('services_providers') .
|
|
|
|
'` DROP FOREIGN KEY `' .
|
|
|
|
$this->db->dbprefix('services_providers') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_ibfk_1`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('services_providers') .
|
|
|
|
'` DROP FOREIGN KEY `' .
|
|
|
|
$this->db->dbprefix('services_providers') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_ibfk_2`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('services') .
|
|
|
|
'` DROP FOREIGN KEY `' .
|
|
|
|
$this->db->dbprefix('services') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_ibfk_1`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('users') .
|
|
|
|
'` DROP FOREIGN KEY `' .
|
|
|
|
$this->db->dbprefix('users') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_ibfk_1`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
|
|
|
$this->db->query(
|
|
|
|
'ALTER TABLE `' .
|
|
|
|
$this->db->dbprefix('user_settings') .
|
|
|
|
'` DROP FOREIGN KEY `' .
|
|
|
|
$this->db->dbprefix('user_settings') .
|
2023-12-22 13:35:41 +03:00
|
|
|
'_ibfk_1`',
|
2023-11-29 12:24:09 +03:00
|
|
|
);
|
2020-04-23 21:35:21 +03:00
|
|
|
|
2020-04-23 21:48:20 +03:00
|
|
|
$this->dbforge->drop_table('appointments');
|
|
|
|
$this->dbforge->drop_table('roles');
|
|
|
|
$this->dbforge->drop_table('secretaries_providers');
|
|
|
|
$this->dbforge->drop_table('services');
|
2021-12-15 09:41:05 +03:00
|
|
|
$this->dbforge->drop_table('service_categories');
|
2020-04-23 21:48:20 +03:00
|
|
|
$this->dbforge->drop_table('services_providers');
|
|
|
|
$this->dbforge->drop_table('settings');
|
|
|
|
$this->dbforge->drop_table('user_settings');
|
|
|
|
$this->dbforge->drop_table('users');
|
2020-04-23 21:35:21 +03:00
|
|
|
}
|
|
|
|
}
|