first commit
Some checks failed
CI / build-test (push) Has been cancelled

This commit is contained in:
2025-05-31 18:56:37 +02:00
commit 8c4798a5fd
1240 changed files with 190468 additions and 0 deletions

View File

@@ -0,0 +1,629 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
/*
* Notice: This first migration got altered to include the creation of the initial database structure so that external
* SQL are not required.
*/
class Migration_Specific_calendar_sync extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
$this->dbforge->add_field([
'id' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'auto_increment' => true,
],
'book_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'start_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'end_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'notes' => [
'type' => 'TEXT',
'null' => true,
],
'hash' => [
'type' => 'TEXT',
'null' => true,
],
'is_unavailability' => [
'type' => 'TINYINT',
'constraint' => '4',
'default' => '0',
],
'id_users_provider' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'null' => true,
],
'id_users_customer' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'null' => true,
],
'id_services' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'null' => true,
],
'id_google_calendar' => [
'type' => 'TEXT',
'null' => true,
],
]);
$this->dbforge->add_key('id', true);
$this->dbforge->add_key('id_users_provider');
$this->dbforge->add_key('id_users_customer');
$this->dbforge->add_key('id_services');
$this->dbforge->create_table('appointments', true, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'slug' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'is_admin' => [
'type' => 'TINYINT',
'constraint' => '4',
'null' => true,
],
'appointments' => [
'type' => 'INT',
'constraint' => '4',
'null' => true,
],
'customers' => [
'type' => 'INT',
'constraint' => '4',
'null' => true,
],
'services' => [
'type' => 'INT',
'constraint' => '4',
'null' => true,
],
'users' => [
'type' => 'INT',
'constraint' => '4',
'null' => true,
],
'system_settings' => [
'type' => 'INT',
'constraint' => '4',
'null' => true,
],
'user_settings' => [
'type' => 'INT',
'constraint' => '4',
'null' => true,
],
]);
$this->dbforge->add_key('id', true);
$this->dbforge->create_table('roles', true, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id_users_secretary' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
],
'id_users_provider' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
],
]);
$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']);
$this->dbforge->add_field([
'id' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'duration' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
],
'price' => [
'type' => 'DECIMAL',
'constraint' => '10,2',
'null' => true,
],
'currency' => [
'type' => 'VARCHAR',
'constraint' => '32',
'null' => true,
],
'description' => [
'type' => 'TEXT',
'null' => true,
],
'id_service_categories' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'null' => true,
],
]);
$this->dbforge->add_key('id', true);
$this->dbforge->add_key('id_service_categories');
$this->dbforge->create_table('services', true, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id_users' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
],
'id_services' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
],
]);
$this->dbforge->add_key('id_users', true);
$this->dbforge->add_key('id_services', true);
$this->dbforge->create_table('services_providers', true, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'description' => [
'type' => 'TEXT',
'null' => true,
],
]);
$this->dbforge->add_key('id', true);
$this->dbforge->add_key('id_service_categories');
$this->dbforge->create_table('service_categories', true, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => '512',
'null' => true,
],
'value' => [
'type' => 'LONGTEXT',
'null' => true,
],
]);
$this->dbforge->add_key('id', true);
$this->dbforge->create_table('settings', true, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
'auto_increment' => true,
],
'first_name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'last_name' => [
'type' => 'VARCHAR',
'constraint' => '512',
'null' => true,
],
'email' => [
'type' => 'VARCHAR',
'constraint' => '512',
'null' => true,
],
'mobile_number' => [
'type' => 'VARCHAR',
'constraint' => '128',
'null' => true,
],
'phone_number' => [
'type' => 'VARCHAR',
'constraint' => '128',
'null' => true,
],
'address' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'city' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'state' => [
'type' => 'VARCHAR',
'constraint' => '128',
'null' => true,
],
'zip_code' => [
'type' => 'VARCHAR',
'constraint' => '64',
'null' => true,
],
'notes' => [
'type' => 'TEXT',
'null' => true,
],
'id_roles' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
],
]);
$this->dbforge->add_key('id', true);
$this->dbforge->add_key('id_roles');
$this->dbforge->create_table('users', true, ['engine' => 'InnoDB']);
$this->dbforge->add_field([
'id_users' => [
'type' => 'BIGINT',
'constraint' => '20',
'unsigned' => true,
],
'username' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'password' => [
'type' => 'VARCHAR',
'constraint' => '512',
'null' => true,
],
'salt' => [
'type' => 'VARCHAR',
'constraint' => '512',
'null' => true,
],
'working_plan' => [
'type' => 'TEXT',
'null' => true,
],
'notifications' => [
'type' => 'TINYINT',
'constraint' => '4',
'null' => true,
],
'google_sync' => [
'type' => 'TINYINT',
'constraint' => '4',
'null' => true,
],
'google_token' => [
'type' => 'TEXT',
'null' => true,
],
'google_calendar' => [
'type' => 'VARCHAR',
'constraint' => '128',
'null' => true,
],
'sync_past_days' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
'default' => '5',
],
'sync_future_days' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
'default' => '5',
],
]);
$this->dbforge->add_key('id_users', true);
$this->dbforge->create_table('user_settings', true, ['engine' => 'InnoDB']);
$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;
',
);
$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;
',
);
$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;
',
);
$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;
',
);
$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;
',
);
$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;
',
);
$this->db->insert('roles', [
'name' => 'Administrator',
'slug' => 'admin',
'is_admin' => true,
'appointments' => 15,
'customers' => 15,
'services' => 15,
'users' => 15,
'system_settings' => 15,
'user_settings' => 15,
]);
$this->db->insert('roles', [
'name' => 'Provider',
'slug' => 'provider',
'is_admin' => false,
'appointments' => 15,
'customers' => 15,
'services' => 0,
'users' => 0,
'system_settings' => 0,
'user_settings' => 15,
]);
$this->db->insert('roles', [
'name' => 'Customer',
'slug' => 'customer',
'is_admin' => false,
'appointments' => 0,
'customers' => 0,
'services' => 0,
'users' => 0,
'system_settings' => 0,
'user_settings' => 0,
]);
$this->db->insert('roles', [
'name' => 'Secretary',
'slug' => 'secretary',
'is_admin' => false,
'appointments' => 15,
'customers' => 15,
'services' => 0,
'users' => 0,
'system_settings' => 0,
'user_settings' => 15,
]);
$this->db->insert('settings', [
'name' => 'company_working_plan',
'value' =>
'{"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"}]}}',
]);
$this->db->insert('settings', [
'name' => 'book_advance_timeout',
'value' => '30',
]);
}
/**
* Downgrade method.
*/
public function down(): void
{
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_3`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_4`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `fk_' .
$this->db->dbprefix('secretaries_providers') .
'_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `fk_' .
$this->db->dbprefix('secretaries_providers') .
'_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services_providers') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services_providers') .
'_ibfk_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('users') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('users') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('user_settings') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('user_settings') .
'_ibfk_1`',
);
$this->dbforge->drop_table('appointments');
$this->dbforge->drop_table('roles');
$this->dbforge->drop_table('secretaries_providers');
$this->dbforge->drop_table('services');
$this->dbforge->drop_table('service_categories');
$this->dbforge->drop_table('services_providers');
$this->dbforge->drop_table('settings');
$this->dbforge->drop_table('user_settings');
$this->dbforge->drop_table('users');
}
}

View File

@@ -0,0 +1,42 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.1.0
* ---------------------------------------------------------------------------- */
class Migration_Add_google_analytics_setting extends EA_Migration
{
/**
* Upgrade method.
*
* @throws Exception
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'google_analytics_code'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'google_analytics_code',
'value' => '',
]);
}
}
/**
* Downgrade method.
*
* @throws Exception
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'google_analytics_code'])->num_rows()) {
$this->db->delete('settings', ['name' => 'google_analytics_code']);
}
}
}

View File

@@ -0,0 +1,42 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.1.0
* ---------------------------------------------------------------------------- */
class Migration_Add_customer_notifications_setting extends EA_Migration
{
/**
* Upgrade method.
*
* @throws Exception
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'customer_notifications'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'customer_notifications',
'value' => '1',
]);
}
}
/**
* Downgrade method.
*
* @throws Exception
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'customer_notifications'])->num_rows()) {
$this->db->delete('settings', ['name' => 'customer_notifications']);
}
}
}

View File

@@ -0,0 +1,42 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.1.0
* ---------------------------------------------------------------------------- */
class Migration_Add_date_format_setting extends EA_Migration
{
/**
* Upgrade method.
*
* @throws Exception
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'date_format'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'date_format',
'value' => 'DMY',
]);
}
}
/**
* Downgrade method.
*
* @throws Exception
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'date_format'])->num_rows()) {
$this->db->delete('settings', ['name' => 'date_format']);
}
}
}

View File

@@ -0,0 +1,42 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.1.0
* ---------------------------------------------------------------------------- */
class Migration_Add_require_captcha_setting extends EA_Migration
{
/**
* Upgrade method.
*
* @throws Exception
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'require_captcha'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'require_captcha',
'value' => '0',
]);
}
}
/**
* Downgrade method.
*
* @throws Exception
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'require_captcha'])->num_rows()) {
$this->db->delete('settings', ['name' => 'require_captcha']);
}
}
}

View File

@@ -0,0 +1,45 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.2.0
* ---------------------------------------------------------------------------- */
class Migration_Add_calendar_view_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('calendar_view', 'user_settings')) {
$fields = [
'calendar_view' => [
'type' => 'VARCHAR',
'constraint' => '32',
'default' => 'default',
],
];
$this->dbforge->add_column('user_settings', $fields);
$this->db->update('user_settings', ['calendar_view' => 'default']);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('calendar_view', 'user_settings')) {
$this->dbforge->drop_column('user_settings', 'calendar_view');
}
}
}

View File

@@ -0,0 +1,46 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.2.0
* ---------------------------------------------------------------------------- */
class Migration_Add_service_availabilities_type extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('availabilities_type', 'services')) {
$fields = [
'availabilities_type' => [
'type' => 'VARCHAR',
'constraint' => '32',
'default' => 'flexible',
'after' => 'description',
],
];
$this->dbforge->add_column('services', $fields);
$this->db->update('services', ['availabilities_type' => 'flexible']);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('availabilities_type', 'services')) {
$this->dbforge->drop_column('services', 'availabilities_type');
}
}
}

View File

@@ -0,0 +1,44 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.2.0
* ---------------------------------------------------------------------------- */
class Migration_Add_service_attendants_number extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('attendants_number', 'services')) {
$fields = [
'attendants_number' => [
'type' => 'INT',
'constraint' => '11',
'default' => '1',
'after' => 'availabilities_type',
],
];
$this->dbforge->add_column('services', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('attendants_number', 'services')) {
$this->dbforge->drop_column('services', 'attendants_number');
}
}
}

View File

@@ -0,0 +1,690 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.3.0
* ---------------------------------------------------------------------------- */
class Migration_Change_column_types extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
// Drop table constraints.
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_3`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_4`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `fk_' .
$this->db->dbprefix('secretaries_providers') .
'_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `fk_' .
$this->db->dbprefix('secretaries_providers') .
'_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services_providers') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services_providers') .
'_ibfk_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('users') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('users') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('user_settings') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('user_settings') .
'_ibfk_1`',
);
// Appointments
$fields = [
'id' => [
'name' => 'id',
'type' => 'int',
'constraint' => '11',
'auto_increment' => true,
],
'id_users_provider' => [
'name' => 'id_users_provider',
'type' => 'int',
'constraint' => '11',
],
'id_users_customer' => [
'name' => 'id_users_customer',
'type' => 'int',
'constraint' => '11',
],
'id_services' => [
'name' => 'id_services',
'type' => 'int',
'constraint' => '11',
],
];
$this->dbforge->modify_column('appointments', $fields);
// Roles
$fields = [
'id' => [
'name' => 'id',
'type' => 'int',
'constraint' => '11',
'auto_increment' => true,
],
'appointments' => [
'name' => 'appointments',
'type' => 'int',
'constraint' => '11',
],
'customers' => [
'name' => 'customers',
'type' => 'int',
'constraint' => '11',
],
'services' => [
'name' => 'services',
'type' => 'int',
'constraint' => '11',
],
'users' => [
'name' => 'users',
'type' => 'int',
'constraint' => '11',
],
'system_settings' => [
'name' => 'system_settings',
'type' => 'int',
'constraint' => '11',
],
'user_settings' => [
'name' => 'user_settings',
'type' => 'int',
'constraint' => '11',
],
];
$this->dbforge->modify_column('roles', $fields);
// Secretary Provider
$fields = [
'id_users_secretary' => [
'name' => 'id_users_secretary',
'type' => 'int',
'constraint' => '11',
],
'id_users_provider' => [
'name' => 'id_users_provider',
'type' => 'int',
'constraint' => '11',
],
];
$this->dbforge->modify_column('secretaries_providers', $fields);
// Services
$fields = [
'id' => [
'name' => 'id',
'type' => 'int',
'constraint' => '11',
'auto_increment' => true,
],
'id_service_categories' => [
'name' => 'id_service_categories',
'type' => 'int',
'constraint' => '11',
],
];
$this->dbforge->modify_column('services', $fields);
// Service Providers
$fields = [
'id_users' => [
'name' => 'id_users',
'type' => 'int',
'constraint' => '11',
],
'id_services' => [
'name' => 'id_services',
'type' => 'int',
'constraint' => '11',
],
];
$this->dbforge->modify_column('services_providers', $fields);
// Service Categories
$fields = [
'id' => [
'name' => 'id',
'type' => 'int',
'constraint' => '11',
'auto_increment' => true,
],
];
$this->dbforge->modify_column('service_categories', $fields);
// Settings
$fields = [
'id' => [
'name' => 'id',
'type' => 'int',
'constraint' => '11',
'auto_increment' => true,
],
];
$this->dbforge->modify_column('settings', $fields);
// Users
$fields = [
'id' => [
'name' => 'id',
'type' => 'int',
'constraint' => '11',
'auto_increment' => true,
],
'id_roles' => [
'name' => 'id_roles',
'type' => 'int',
'constraint' => '11',
],
];
$this->dbforge->modify_column('users', $fields);
// Users Settings
$fields = [
'id_users' => [
'name' => 'id_users',
'type' => 'int',
'constraint' => '11',
],
];
$this->dbforge->modify_column('user_settings', $fields);
// Add table constraints again.
$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',
);
$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',
);
$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',
);
$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',
);
$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',
);
$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',
);
// Change charset of ' . $this->db->dbprefix('secretaries_providers') . ' table for databases created with EA! 1.2.1 version
$this->db->query(
'ALTER TABLE ' . $this->db->dbprefix('secretaries_providers') . ' CONVERT TO CHARACTER SET utf8',
);
}
/**
* Downgrade method.
*/
public function down(): void
{
// Drop table constraints.
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_3`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_4`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `fk_' .
$this->db->dbprefix('secretaries_providers') .
'_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `fk_' .
$this->db->dbprefix('secretaries_providers') .
'_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services_providers') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services_providers') .
'_ibfk_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('users') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('users') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('user_settings') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('user_settings') .
'_ibfk_1`',
);
// Appointments
$fields = [
'id' => [
'name' => 'id',
'type' => 'bigint',
'constraint' => '20',
'auto_increment' => true,
],
'id_users_provider' => [
'name' => 'id_users_provider',
'type' => 'bigint',
'constraint' => '20',
],
'id_users_customer' => [
'name' => 'id_users_customer',
'type' => 'bigint',
'constraint' => '20',
],
'id_services' => [
'name' => 'id_services',
'type' => 'bigint',
'constraint' => '20',
],
];
$this->dbforge->modify_column('appointments', $fields);
// Roles
$fields = [
'id' => [
'name' => 'id',
'type' => 'bigint',
'constraint' => '20',
'auto_increment' => true,
],
'appointments' => [
'name' => 'appointments',
'type' => 'bigint',
'constraint' => '20',
],
'customers' => [
'name' => 'customers',
'type' => 'bigint',
'constraint' => '20',
],
'services' => [
'name' => 'services',
'type' => 'bigint',
'constraint' => '20',
],
'users' => [
'name' => 'users',
'type' => 'bigint',
'constraint' => '20',
],
'system_settings' => [
'name' => 'system_settings',
'type' => 'bigint',
'constraint' => '20',
],
'user_settings' => [
'name' => 'user_settings',
'type' => 'bigint',
'constraint' => '20',
],
];
$this->dbforge->modify_column('roles', $fields);
// Secretary Provider
$fields = [
'id_users_secretary' => [
'name' => 'id_users_secretary',
'type' => 'bigint',
'constraint' => '20',
],
'id_users_provider' => [
'name' => 'id_users_provider',
'type' => 'bigint',
'constraint' => '20',
],
];
$this->dbforge->modify_column('secretaries_providers', $fields);
// Services
$fields = [
'id' => [
'name' => 'id',
'type' => 'bigint',
'constraint' => '20',
'auto_increment' => true,
],
'id_service_categories' => [
'name' => 'id_service_categories',
'type' => 'bigint',
'constraint' => '20',
],
];
$this->dbforge->modify_column('services', $fields);
// Service Providers
$fields = [
'id_users' => [
'name' => 'id_users',
'type' => 'bigint',
'constraint' => '20',
],
'id_services' => [
'name' => 'id_services',
'type' => 'bigint',
'constraint' => '20',
],
];
$this->dbforge->modify_column('services_providers', $fields);
// Service Categories
$fields = [
'id' => [
'name' => 'id',
'type' => 'bigint',
'constraint' => '20',
'auto_increment' => true,
],
];
$this->dbforge->modify_column('service_categories', $fields);
// Settings
$fields = [
'id' => [
'name' => 'id',
'type' => 'bigint',
'constraint' => '20',
'auto_increment' => true,
],
];
$this->dbforge->modify_column('settings', $fields);
// Users
$fields = [
'id' => [
'name' => 'id',
'type' => 'bigint',
'constraint' => '20',
'auto_increment' => true,
],
'id_roles' => [
'name' => 'id_roles',
'type' => 'bigint',
'constraint' => '20',
],
];
$this->dbforge->modify_column('users', $fields);
// Users Settings
$fields = [
'id_users' => [
'name' => 'id_users',
'type' => 'bigint',
'constraint' => '20',
],
];
$this->dbforge->modify_column('user_settings', $fields);
// Add database constraints.
$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',
);
$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',
);
$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',
);
$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',
);
$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',
);
$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',
);
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.3.0
* ---------------------------------------------------------------------------- */
class Migration_Add_time_format_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'time_format'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'time_format',
'value' => 'regular',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'time_format'])->num_rows()) {
$this->db->delete('settings', ['name' => 'time_format']);
}
}
}

View File

@@ -0,0 +1,311 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.3.0
* ---------------------------------------------------------------------------- */
class Migration_Remove_prefix_from_fkey_constraints extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
// Drop table constraints.
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_3`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('appointments') .
'_ibfk_4`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `fk_' .
$this->db->dbprefix('secretaries_providers') .
'_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `fk_' .
$this->db->dbprefix('secretaries_providers') .
'_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services_providers') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services_providers') .
'_ibfk_2`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('services') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('users') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('users') .
'_ibfk_1`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('user_settings') .
'` DROP FOREIGN KEY `' .
$this->db->dbprefix('user_settings') .
'_ibfk_1`',
);
// Add table constraints again without the "ea" prefix.
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('appointments') .
'`
ADD CONSTRAINT `appointments_users_customer` FOREIGN KEY (`id_users_customer`) REFERENCES `' .
$this->db->dbprefix('users') .
'` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `appointments_services` FOREIGN KEY (`id_services`) REFERENCES `' .
$this->db->dbprefix('services') .
'` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `appointments_users_provider` FOREIGN KEY (`id_users_provider`) REFERENCES `' .
$this->db->dbprefix('users') .
'` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'`
ADD CONSTRAINT `secretaries_users_secretary` FOREIGN KEY (`id_users_secretary`) REFERENCES `' .
$this->db->dbprefix('users') .
'` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `secretaries_users_provider` FOREIGN KEY (`id_users_provider`) REFERENCES `' .
$this->db->dbprefix('users') .
'` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services') .
'`
ADD CONSTRAINT `services_service_categories` FOREIGN KEY (`id_service_categories`) REFERENCES `' .
$this->db->dbprefix('service_categories') .
'` (`id`)
ON DELETE SET NULL
ON UPDATE CASCADE',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'`
ADD CONSTRAINT `services_providers_users_provider` FOREIGN KEY (`id_users`) REFERENCES `' .
$this->db->dbprefix('users') .
'` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `services_providers_services` FOREIGN KEY (`id_services`) REFERENCES `' .
$this->db->dbprefix('services') .
'` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('users') .
'`
ADD CONSTRAINT `users_roles` FOREIGN KEY (`id_roles`) REFERENCES `' .
$this->db->dbprefix('roles') .
'` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('user_settings') .
'`
ADD CONSTRAINT `user_settings_users` FOREIGN KEY (`id_users`) REFERENCES `' .
$this->db->dbprefix('users') .
'` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE',
);
}
/**
* Downgrade method.
*/
public function down(): void
{
// Drop table constraints.
$this->db->query(
'ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `appointments_services`',
);
$this->db->query(
'ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `appointments_users_customer`',
);
$this->db->query(
'ALTER TABLE `' . $this->db->dbprefix('appointments') . '` DROP FOREIGN KEY `appointments_users_provider`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `secretaries_users_secretary`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('secretaries_providers') .
'` DROP FOREIGN KEY `secretaries_users_provider`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `services_providers_users_provider`',
);
$this->db->query(
'ALTER TABLE `' .
$this->db->dbprefix('services_providers') .
'` DROP FOREIGN KEY `services_providers_services`',
);
$this->db->query(
'ALTER TABLE `' . $this->db->dbprefix('services') . '` DROP FOREIGN KEY `services_service_categories`',
);
$this->db->query('ALTER TABLE `' . $this->db->dbprefix('users') . '` DROP FOREIGN KEY `users_roles`');
$this->db->query(
'ALTER TABLE `' . $this->db->dbprefix('user_settings') . '` DROP FOREIGN KEY `user_settings_users`',
);
// Add table constraints again.
$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',
);
$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',
);
$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',
);
$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',
);
$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',
);
$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',
);
}
}

View File

@@ -0,0 +1,156 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.3.2
* ---------------------------------------------------------------------------- */
class Migration_Legal_contents extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'display_cookie_notice'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'display_cookie_notice',
'value' => '0',
]);
}
if (!$this->db->get_where('settings', ['name' => 'cookie_notice_content'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'cookie_notice_content',
'value' => 'Cookie notice content.',
]);
}
if (!$this->db->get_where('settings', ['name' => 'display_terms_and_conditions'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'display_terms_and_conditions',
'value' => '0',
]);
}
if (!$this->db->get_where('settings', ['name' => 'terms_and_conditions_content'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'terms_and_conditions_content',
'value' => 'Terms and conditions content.',
]);
}
if (!$this->db->get_where('settings', ['name' => 'display_privacy_policy'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'display_privacy_policy',
'value' => '0',
]);
}
if (!$this->db->get_where('settings', ['name' => 'privacy_policy_content'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'privacy_policy_content',
'value' => 'Privacy policy content.',
]);
}
if (!$this->db->table_exists('consents')) {
$this->dbforge->add_field([
'id' => [
'type' => 'INT',
'constraint' => 11,
'auto_increment' => true,
],
'created' => [
'type' => 'TIMESTAMP',
'null' => true,
],
'modified' => [
'type' => 'TIMESTAMP',
'null' => true,
],
'first_name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'last_name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'email' => [
'type' => 'VARCHAR',
'constraint' => '512',
'null' => true,
],
'ip' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'type' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
]);
$this->dbforge->add_key('id', true);
$this->dbforge->create_table('consents', true, ['engine' => 'InnoDB']);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'display_cookie_notice'])->num_rows()) {
$this->db->delete('settings', [
'name' => 'display_cookie_notice',
]);
}
if ($this->db->get_where('settings', ['name' => 'cookie_notice_content'])->num_rows()) {
$this->db->delete('settings', [
'name' => 'cookie_notice_content',
]);
}
if ($this->db->get_where('settings', ['name' => 'display_terms_and_conditions'])->num_rows()) {
$this->db->delete('settings', [
'name' => 'display_terms_and_conditions',
]);
}
if ($this->db->get_where('settings', ['name' => 'terms_and_conditions_content'])->num_rows()) {
$this->db->delete('settings', [
'name' => 'terms_and_conditions_content',
]);
}
if ($this->db->get_where('settings', ['name' => 'display_privacy_policy'])->num_rows()) {
$this->db->delete('settings', [
'name' => 'display_privacy_policy',
]);
}
if ($this->db->get_where('settings', ['name' => 'privacy_policy_content'])->num_rows()) {
$this->db->delete('settings', [
'name' => 'privacy_policy_content',
]);
}
if ($this->db->table_exists('consents')) {
$this->dbforge->drop_table('consents');
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.3.2
* ---------------------------------------------------------------------------- */
class Migration_Add_weekday_start_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'first_weekday'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'first_weekday',
'value' => 'sunday',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'first_weekday'])->num_rows()) {
$this->db->delete('settings', ['name' => 'first_weekday']);
}
}
}

View File

@@ -0,0 +1,59 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Create_appointment_location_column extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('location', 'appointments')) {
$fields = [
'location' => [
'type' => 'TEXT',
'null' => true,
'after' => 'end_datetime',
],
];
$this->dbforge->add_column('appointments', $fields);
}
if (!$this->db->field_exists('location', 'services')) {
$fields = [
'location' => [
'type' => 'TEXT',
'null' => true,
'after' => 'description',
],
];
$this->dbforge->add_column('services', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('location', 'appointments')) {
$this->dbforge->drop_column('appointments', 'location');
}
if ($this->db->field_exists('location', 'services')) {
$this->dbforge->drop_column('services', 'location');
}
}
}

View File

@@ -0,0 +1,43 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.2.0
* ---------------------------------------------------------------------------- */
class Migration_Add_working_plan_exceptions_to_user_settings extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('working_plan_exceptions', 'user_settings')) {
$fields = [
'working_plan_exceptions' => [
'type' => 'TEXT',
'null' => true,
'after' => 'working_plan',
],
];
$this->dbforge->add_column('user_settings', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('working_plan_exceptions', 'user_settings')) {
$this->dbforge->drop_column('user_settings', 'working_plan_exceptions');
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_require_phone_number_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'require_phone_number'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'require_phone_number',
'value' => '1',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'require_phone_number'])->num_rows()) {
$this->db->delete('settings', ['name' => 'require_phone_number']);
}
}
}

View File

@@ -0,0 +1,42 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_api_token_setting extends EA_Migration
{
/**
* Upgrade method.
*
* @throws Exception
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'api_token'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'api_token',
'value' => '',
]);
}
}
/**
* Downgrade method.
*
* @throws Exception
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'api_token'])->num_rows()) {
$this->db->delete('settings', ['name' => 'api_token']);
}
}
}

View File

@@ -0,0 +1,42 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_timezone_to_users extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('timezone', 'users')) {
$fields = [
'timezone' => [
'type' => 'VARCHAR',
'constraint' => '256',
'default' => 'UTC',
'after' => 'notes',
],
];
$this->dbforge->add_column('users', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
$this->dbforge->drop_column('users', 'timezone');
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_display_any_provider_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'display_any_provider'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'display_any_provider',
'value' => '1',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'display_any_provider'])->num_rows()) {
$this->db->delete('settings', ['name' => 'display_any_provider']);
}
}
}

View File

@@ -0,0 +1,42 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_language_to_users extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('language', 'users')) {
$fields = [
'language' => [
'type' => 'VARCHAR',
'constraint' => '256',
'default' => 'english',
'after' => 'timezone',
],
];
$this->dbforge->add_column('users', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
$this->dbforge->drop_column('users', 'language');
}
}

View File

@@ -0,0 +1,101 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Modify_sync_period_columns extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
$fields = [
'sync_past_days' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
'default' => '30',
],
'sync_future_days' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
'default' => '90',
],
];
$this->dbforge->modify_column('user_settings', $fields);
$this->db->update(
'user_settings',
[
'sync_past_days' => '30',
],
[
'sync_past_days' => '5',
],
);
$this->db->update(
'user_settings',
[
'sync_future_days' => '90',
],
[
'sync_future_days' => '5',
],
);
}
/**
* Downgrade method.
*/
public function down(): void
{
$fields = [
'sync_past_days' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
'default' => '5',
],
'sync_future_days' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
'default' => '5',
],
];
$this->dbforge->modify_column('user_settings', $fields);
$this->db->update(
'user_settings',
[
'sync_past_days' => '5',
],
[
'sync_past_days' => '30',
],
);
$this->db->update(
'user_settings',
[
'sync_future_days' => '5',
],
[
'sync_future_days' => '90',
],
);
}
}

View File

@@ -0,0 +1,96 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */
class Migration_Add_booking_field_settings extends EA_Migration
{
/**
* @var array
*/
private $fields = [
'first_name' => [
'display' => '1',
'require' => '1',
],
'last_name' => [
'display' => '1',
'require' => '1',
],
'email' => [
'display' => '1',
'require' => '1',
],
'phone_number' => [
'display' => '1',
'require' => '1',
],
'address' => [
'display' => '1',
'require' => '0',
],
'city' => [
'display' => '1',
'require' => '0',
],
'zip_code' => [
'display' => '1',
'require' => '0',
],
'notes' => [
'display' => '1',
'require' => '0',
],
];
/**
* Upgrade method.
*/
public function up(): void
{
foreach ($this->fields as $field => $props) {
foreach ($props as $prop => $value) {
$setting_name = $prop . '_' . $field;
if ($this->db->get_where('settings', ['name' => $setting_name])->num_rows()) {
$setting = $this->db->get_where('settings', ['name' => $setting_name])->row_array();
$value = $setting['value']; // Use existing value.
$this->db->delete('settings', ['name' => $setting_name]);
}
if (!$this->db->get_where('settings', ['name' => $setting_name])->num_rows()) {
$this->db->insert('settings', [
'name' => $setting_name,
'value' => $value,
]);
}
}
}
}
/**
* Downgrade method.
*/
public function down(): void
{
foreach ($this->fields as $field => $props) {
foreach ($props as $prop => $value) {
$setting_name = $prop . '_' . $field;
if ($this->db->get_where('settings', ['name' => $setting_name])->num_rows()) {
$this->db->delete('settings', ['name' => $setting_name]);
}
}
}
}
}

View File

@@ -0,0 +1,35 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */
class Migration_Rename_service_categories_table_to_categories extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if ($this->db->table_exists('service_categories')) {
$this->dbforge->rename_table('service_categories', 'categories');
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->table_exists('categories')) {
$this->dbforge->rename_table('categories', 'service_categories');
}
}
}

View File

@@ -0,0 +1,85 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */
class Migration_Rename_id_service_categories_column_of_services_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
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(): void
{
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_service_categories`) REFERENCES `' .
$this->db->dbprefix('categories') .
'` (`id`)
ON DELETE SET NULL
ON UPDATE CASCADE
',
);
}
}
}

View File

@@ -0,0 +1,53 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */
class Migration_Rename_is_unavailable_column_of_appointments_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if ($this->db->field_exists('is_unavailable', 'appointments')) {
$fields = [
'is_unavailable' => [
'name' => 'is_unavailability',
'type' => 'TINYINT',
'constraint' => '4',
'default' => '0',
],
];
$this->dbforge->modify_column('appointments', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('is_unavailability', 'appointments')) {
$fields = [
'is_unavailability' => [
'name' => 'is_unavailable',
'type' => 'TINYINT',
'constraint' => '4',
'default' => '0',
],
];
$this->dbforge->modify_column('appointments', $fields);
}
}
}

View File

@@ -0,0 +1,44 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_color_column_to_services_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('color', 'services')) {
$fields = [
'color' => [
'type' => 'VARCHAR',
'constraint' => '256',
'default' => '#7cbae8',
'after' => 'description',
],
];
$this->dbforge->add_column('services', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('color', 'services')) {
$this->dbforge->drop_column('services', 'color');
}
}
}

View File

@@ -0,0 +1,44 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_color_column_to_appointments_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('color', 'appointments')) {
$fields = [
'color' => [
'type' => 'VARCHAR',
'constraint' => '256',
'default' => '#7cbae8',
'after' => 'hash',
],
];
$this->dbforge->add_column('appointments', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('color', 'appointments')) {
$this->dbforge->drop_column('appointments', 'color');
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_matomo_analytics_url_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'matomo_analytics_url'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'matomo_analytics_url',
'value' => '',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'matomo_analytics_url'])->num_rows()) {
$this->db->delete('settings', ['name' => 'matomo_analytics_url']);
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_display_delete_personal_information_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'display_delete_personal_information'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'display_delete_personal_information',
'value' => '0',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'display_delete_personal_information'])->num_rows()) {
$this->db->delete('settings', ['name' => 'display_delete_personal_information']);
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_disable_booking_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'disable_booking'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'disable_booking',
'value' => '0',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'disable_booking'])->num_rows()) {
$this->db->delete('settings', ['name' => 'disable_booking']);
}
}
}

View File

@@ -0,0 +1,39 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_disable_booking_message_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'disable_booking_message'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'disable_booking_message',
'value' =>
'<p style="text-align: center;">Thanks for stopping by!</p><p style="text-align: center;">We are not accepting new appointments at the moment, please check back again later.</p>',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'disable_booking_message'])->num_rows()) {
$this->db->delete('settings', ['name' => 'disable_booking_message']);
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_company_logo_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'company_logo'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'company_logo',
'value' => '',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'company_logo'])->num_rows()) {
$this->db->delete('settings', ['name' => 'company_logo']);
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_company_color_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'company_color'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'company_color',
'value' => '#ffffff',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'company_color'])->num_rows()) {
$this->db->delete('settings', ['name' => 'company_color']);
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_display_login_button_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'display_login_button'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'display_login_button',
'value' => '1',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'display_login_button'])->num_rows()) {
$this->db->delete('settings', ['name' => 'display_login_button']);
}
}
}

View File

@@ -0,0 +1,44 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_is_private_column_to_services_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('is_private', 'services')) {
$fields = [
'is_private' => [
'type' => 'TINYINT',
'constraint' => '4',
'default' => '0',
'after' => 'attendants_number',
],
];
$this->dbforge->add_column('services', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('is_private', 'services')) {
$this->dbforge->drop_column('services', 'is_private');
}
}
}

View File

@@ -0,0 +1,44 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_is_private_column_to_users_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('is_private', 'users')) {
$fields = [
'is_private' => [
'type' => 'TINYINT',
'constraint' => '4',
'default' => '0',
'after' => 'language',
],
];
$this->dbforge->add_column('users', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('is_private', 'users')) {
$this->dbforge->drop_column('users', 'is_private');
}
}
}

View File

@@ -0,0 +1,61 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_timestamp_columns extends EA_Migration
{
/**
* @var string[]
*/
protected $tables = ['appointments', 'categories', 'consents', 'roles', 'services', 'settings', 'users'];
/**
* @var string[]
*/
protected $columns = ['delete_datetime', 'update_datetime', 'create_datetime'];
/**
* Upgrade method.
*/
public function up(): void
{
foreach ($this->tables as $table) {
foreach ($this->columns as $column) {
if (!$this->db->field_exists($column, $table)) {
$fields = [
$column => [
'type' => 'DATETIME',
'null' => true,
'after' => 'id',
],
];
$this->dbforge->add_column($table, $fields);
}
}
}
}
/**
* Downgrade method.
*/
public function down(): void
{
foreach ($this->tables as $table) {
foreach ($this->columns as $column) {
if ($this->db->field_exists($column, $table)) {
$this->dbforge->drop_column($table, $column);
}
}
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_theme_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'theme'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'theme',
'value' => 'default',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'theme'])->num_rows()) {
$this->db->delete('settings', ['name' => 'theme']);
}
}
}

View File

@@ -0,0 +1,40 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_limit_customer_access_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'limit_customer_access'])->num_rows()) {
$this->db->insert('settings', [
'create_datetime' => date('Y-m-d H:i:s'),
'update_datetime' => date('Y-m-d H:i:s'),
'name' => 'limit_customer_access',
'value' => '0',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'limit_customer_access'])->num_rows()) {
$this->db->delete('settings', ['name' => 'limit_customer_access']);
}
}
}

View File

@@ -0,0 +1,84 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Create_webhooks_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->table_exists('webhooks')) {
$this->dbforge->add_field([
'id' => [
'type' => 'INT',
'constraint' => 11,
'auto_increment' => true,
],
'create_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'update_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'delete_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'url' => [
'type' => 'TEXT',
'null' => true,
],
'actions' => [
'type' => 'TEXT',
'null' => true,
],
'secret_token' => [
'type' => 'VARCHAR',
'constraint' => '512',
'null' => true,
],
'is_ssl_verified' => [
'type' => 'TINYINT',
'constraint' => '4',
'default' => true,
],
'notes' => [
'type' => 'TEXT',
'null' => true,
],
]);
$this->dbforge->add_key('id', true);
$this->dbforge->create_table('webhooks', true, ['engine' => 'InnoDB']);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->table_exists('webhooks')) {
$this->dbforge->drop_table('webhooks');
}
}
}

View File

@@ -0,0 +1,47 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_webhooks_column_to_roles_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('webhooks', 'roles')) {
$fields = [
'webhooks' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
],
];
$this->dbforge->add_column('roles', $fields);
$this->db->update('roles', ['webhooks' => '15'], ['slug' => 'admin']);
$this->db->update('roles', ['webhooks' => '0'], ['slug !=' => 'admin']);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('webhooks', 'roles')) {
$this->dbforge->drop_column('roles', 'webhooks');
}
}
}

View File

@@ -0,0 +1,46 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
/**
* @property CI_DB_query_builder $db
* @property CI_DB_forge $dbforge
*/
class Migration_Add_future_booking_limit_setting extends CI_Migration
{
/**
* Upgrade method.
*
* @throws Exception
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'future_booking_limit'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'future_booking_limit',
'value' => '90', // days
]);
}
}
/**
* Downgrade method.
*
* @throws Exception
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'future_booking_limit'])->num_rows()) {
$this->db->delete('settings', ['name' => 'future_booking_limit']);
}
}
}

View File

@@ -0,0 +1,46 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
/**
* @property CI_DB_query_builder $db
* @property CI_DB_forge $dbforge
*/
class Migration_Add_appointment_status_options_setting extends CI_Migration
{
/**
* Upgrade method.
*
* @throws Exception
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'appointment_status_options'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'appointment_status_options',
'value' => '["Booked", "Confirmed", "Rescheduled", "Cancelled", "Draft"]',
]);
}
}
/**
* Downgrade method.
*
* @throws Exception
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'appointment_status_options'])->num_rows()) {
$this->db->delete('settings', ['name' => 'status_options']);
}
}
}

View File

@@ -0,0 +1,44 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_status_column_to_appointments_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('status', 'appointments')) {
$fields = [
'status' => [
'type' => 'VARCHAR',
'constraint' => '512',
'default' => '',
'after' => 'color',
],
];
$this->dbforge->add_column('appointments', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('status', 'appointments')) {
$this->dbforge->drop_column('appointments', 'status');
}
}
}

View File

@@ -0,0 +1,61 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
class Migration_Drop_delete_datetime_column_from_all_tables extends EA_Migration
{
/**
* @var string[]
*/
protected $tables = [
'appointments',
'categories',
'consents',
'roles',
'services',
'settings',
'users',
'webhooks',
];
/**
* Upgrade method.
*/
public function up(): void
{
foreach ($this->tables as $table) {
if ($this->db->field_exists('delete_datetime', $table)) {
$this->dbforge->drop_column($table, 'delete_datetime');
}
}
}
/**
* Downgrade method.
*/
public function down(): void
{
foreach ($this->tables as $table) {
if (!$this->db->field_exists('delete_datetime', $table)) {
$fields = [
'delete_datetime' => [
'type' => 'DATETIME',
'null' => true,
'after' => 'update_datetime',
],
];
$this->dbforge->add_column($table, $fields);
}
}
}
}

View File

@@ -0,0 +1,35 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */
class Migration_Revert_rename_service_categories_table_to_categories extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if ($this->db->table_exists('categories')) {
$this->dbforge->rename_table('categories', 'service_categories');
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->table_exists('service_categories')) {
$this->dbforge->rename_table('service_categories', 'categories');
}
}
}

View File

@@ -0,0 +1,85 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */
class Migration_Revert_rename_id_service_categories_column_of_services_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
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_service_categories`) REFERENCES `' .
$this->db->dbprefix('service_categories') .
'` (`id`)
ON DELETE SET NULL
ON UPDATE CASCADE
',
);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
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('service_categories') .
'` (`id`)
ON DELETE SET NULL
ON UPDATE CASCADE
',
);
}
}
}

View File

@@ -0,0 +1,70 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Create_blocked_periods_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->table_exists('blocked_periods')) {
$this->dbforge->add_field([
'id' => [
'type' => 'INT',
'constraint' => 11,
'auto_increment' => true,
],
'create_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'update_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
],
'start_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'end_datetime' => [
'type' => 'DATETIME',
'null' => true,
],
'notes' => [
'type' => 'TEXT',
'null' => true,
],
]);
$this->dbforge->add_key('id', true);
$this->dbforge->create_table('blocked_periods', true, ['engine' => 'InnoDB']);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->table_exists('blocked_periods')) {
$this->dbforge->drop_table('blocked_periods');
}
}
}

View File

@@ -0,0 +1,47 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_blocked_periods_column_to_roles_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('blocked_periods', 'roles')) {
$fields = [
'blocked_periods' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
],
];
$this->dbforge->add_column('roles', $fields);
$this->db->update('roles', ['blocked_periods' => '15'], ['slug' => 'admin']);
$this->db->update('roles', ['blocked_periods' => '0'], ['slug !=' => 'admin']);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('blocked_periods', 'roles')) {
$this->dbforge->drop_column('roles', 'blocked_periods');
}
}
}

View File

@@ -0,0 +1,56 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_custom_fields_columns_to_users_table extends EA_Migration
{
/**
* @var int
*/
private const FIELD_NUMBER = 5;
/**
* Upgrade method.
*/
public function up(): void
{
for ($i = self::FIELD_NUMBER; $i > 0; $i--) {
$field_name = 'custom_field_' . $i;
if (!$this->db->field_exists($field_name, 'users')) {
$fields = [
$field_name => [
'type' => 'TEXT',
'null' => true,
'after' => 'language',
],
];
$this->dbforge->add_column('users', $fields);
}
}
}
/**
* Downgrade method.
*/
public function down(): void
{
for ($i = self::FIELD_NUMBER; $i > 0; $i--) {
$field_name = 'custom_fields_' . $i;
if ($this->db->field_exists($field_name, 'users')) {
$this->dbforge->drop_column('users', $field_name);
}
}
}
}

View File

@@ -0,0 +1,65 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Insert_custom_field_rows_to_settings_table extends EA_Migration
{
/**
* @var int
*/
private const FIELD_NUMBER = 5;
private const SETTINGS = [
'display' => '0',
'require' => '0',
'label' => '',
];
/**
* Upgrade method.
*/
public function up(): void
{
for ($i = 1; $i <= self::FIELD_NUMBER; $i++) {
$field_name = 'custom_field_' . $i;
foreach (self::SETTINGS as $name => $default_value) {
$setting_name = $name . '_' . $field_name;
if (!$this->db->get_where('settings', ['name' => $setting_name])->num_rows()) {
$this->db->insert('settings', [
'name' => $setting_name,
'value' => $default_value,
]);
}
}
}
}
/**
* Downgrade method.
*/
public function down(): void
{
for ($i = 1; $i >= self::FIELD_NUMBER; $i++) {
$field_name = 'custom_field_' . $i;
foreach (self::SETTINGS as $name => $default_value) {
$setting_name = $name . '_' . $field_name;
if ($this->db->get_where('settings', ['name' => $setting_name])->num_rows()) {
$this->db->delete('settings', ['name' => $setting_name]);
}
}
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_matomo_analytics_site_id_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'matomo_analytics_site_id'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'matomo_analytics_site_id',
'value' => '1',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'matomo_analytics_site_id'])->num_rows()) {
$this->db->delete('settings', ['name' => 'matomo_analytics_site_id']);
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.3.2
* ---------------------------------------------------------------------------- */
class Migration_Add_default_language_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'default_language'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'default_language',
'value' => 'english',
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'default_language'])->num_rows()) {
$this->db->delete('settings', ['name' => 'default_language']);
}
}
}

View File

@@ -0,0 +1,38 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.3.2
* ---------------------------------------------------------------------------- */
class Migration_Add_default_timezone_setting extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->get_where('settings', ['name' => 'default_timezone'])->num_rows()) {
$this->db->insert('settings', [
'name' => 'default_timezone',
'value' => date_default_timezone_get(),
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'default_timezone'])->num_rows()) {
$this->db->delete('settings', ['name' => 'default_timezone']);
}
}
}

View File

@@ -0,0 +1,112 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_caldav_columns_to_user_settings_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('caldav_sync', 'user_settings')) {
$fields = [
'caldav_sync' => [
'type' => 'TINYINT',
'constraint' => '4',
'default' => false,
'after' => 'google_calendar',
],
];
$this->dbforge->add_column('user_settings', $fields);
}
if (!$this->db->field_exists('caldav_url', 'user_settings')) {
$fields = [
'caldav_url' => [
'type' => 'VARCHAR',
'constraint' => '512',
'null' => true,
'after' => 'caldav_sync',
],
];
$this->dbforge->add_column('user_settings', $fields);
}
if (!$this->db->field_exists('caldav_username', 'user_settings')) {
$fields = [
'caldav_username' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
'after' => 'caldav_url',
],
];
$this->dbforge->add_column('user_settings', $fields);
}
if (!$this->db->field_exists('caldav_password', 'user_settings')) {
$fields = [
'caldav_password' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
'after' => 'caldav_username',
],
];
$this->dbforge->add_column('user_settings', $fields);
}
if (!$this->db->field_exists('caldav_calendar', 'user_settings')) {
$fields = [
'caldav_calendar' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
'after' => 'caldav_password',
],
];
$this->dbforge->add_column('user_settings', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('caldav_sync', 'user_settings')) {
$this->dbforge->drop_column('user_settings', 'caldav_sync');
}
if ($this->db->field_exists('caldav_url', 'user_settings')) {
$this->dbforge->drop_column('user_settings', 'caldav_url');
}
if ($this->db->field_exists('caldav_username', 'user_settings')) {
$this->dbforge->drop_column('user_settings', 'caldav_username');
}
if ($this->db->field_exists('caldav_password', 'user_settings')) {
$this->dbforge->drop_column('user_settings', 'caldav_password');
}
if ($this->db->field_exists('caldav_calendar', 'user_settings')) {
$this->dbforge->drop_column('user_settings', 'caldav_calendar');
}
}
}

View File

@@ -0,0 +1,43 @@
<?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.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_id_caldav_calendar_column_to_appointments_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('id_caldav_calendar', 'appointments')) {
$fields = [
'id_caldav_calendar' => [
'type' => 'TEXT',
'null' => null,
'after' => 'id_google_calendar',
],
];
$this->dbforge->add_column('appointments', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('id_caldav_calendar', 'appointments')) {
$this->dbforge->drop_column('appointments', 'id_caldav_calendar');
}
}
}

View File

@@ -0,0 +1,138 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.3.2
* ---------------------------------------------------------------------------- */
class Migration_Add_ldap_rows_to_settings_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
$now = date('Y-m-d H:i:s');
$timestamps = [
'create_datetime' => $now,
'update_datetime' => $now,
];
if (!$this->db->get_where('settings', ['name' => 'ldap_is_active'])->num_rows()) {
$this->db->insert('settings', [
'create_datetime' => $timestamps['create_datetime'],
'update_datetime' => $timestamps['update_datetime'],
'name' => 'ldap_is_active',
'value' => '0',
]);
}
if (!$this->db->get_where('settings', ['name' => 'ldap_host'])->num_rows()) {
$this->db->insert('settings', [
'create_datetime' => $timestamps['create_datetime'],
'update_datetime' => $timestamps['update_datetime'],
'name' => 'ldap_host',
'value' => '',
]);
}
if (!$this->db->get_where('settings', ['name' => 'ldap_port'])->num_rows()) {
$this->db->insert('settings', [
'create_datetime' => $timestamps['create_datetime'],
'update_datetime' => $timestamps['update_datetime'],
'name' => 'ldap_port',
'value' => '',
]);
}
if (!$this->db->get_where('settings', ['name' => 'ldap_user_dn'])->num_rows()) {
$this->db->insert('settings', [
'create_datetime' => $timestamps['create_datetime'],
'update_datetime' => $timestamps['update_datetime'],
'name' => 'ldap_user_dn',
'value' => '',
]);
}
if (!$this->db->get_where('settings', ['name' => 'ldap_password'])->num_rows()) {
$this->db->insert('settings', [
'create_datetime' => $timestamps['create_datetime'],
'update_datetime' => $timestamps['update_datetime'],
'name' => 'ldap_password',
'value' => '',
]);
}
if (!$this->db->get_where('settings', ['name' => 'ldap_base_dn'])->num_rows()) {
$this->db->insert('settings', [
'create_datetime' => $timestamps['create_datetime'],
'update_datetime' => $timestamps['update_datetime'],
'name' => 'ldap_base_dn',
'value' => '',
]);
}
if (!$this->db->get_where('settings', ['name' => 'ldap_filter'])->num_rows()) {
$this->db->insert('settings', [
'create_datetime' => $timestamps['create_datetime'],
'update_datetime' => $timestamps['update_datetime'],
'name' => 'ldap_filter',
'value' => LDAP_DEFAULT_FILTER,
]);
}
if (!$this->db->get_where('settings', ['name' => 'ldap_field_mapping'])->num_rows()) {
$this->db->insert('settings', [
'create_datetime' => $timestamps['create_datetime'],
'update_datetime' => $timestamps['update_datetime'],
'name' => 'ldap_field_mapping',
'value' => json_encode(LDAP_DEFAULT_FIELD_MAPPING, JSON_PRETTY_PRINT),
]);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->get_where('settings', ['name' => 'ldap_is_active'])->num_rows()) {
$this->db->delete('settings', ['name' => 'ldap_is_active']);
}
if ($this->db->get_where('settings', ['name' => 'ldap_host'])->num_rows()) {
$this->db->delete('settings', ['name' => 'ldap_host']);
}
if ($this->db->get_where('settings', ['name' => 'ldap_port'])->num_rows()) {
$this->db->delete('settings', ['name' => 'ldap_port']);
}
if ($this->db->get_where('settings', ['name' => 'ldap_user_dn'])->num_rows()) {
$this->db->delete('settings', ['name' => 'ldap_user_dn']);
}
if ($this->db->get_where('settings', ['name' => 'ldap_password'])->num_rows()) {
$this->db->delete('settings', ['name' => 'ldap_password']);
}
if ($this->db->get_where('settings', ['name' => 'ldap_base_dn'])->num_rows()) {
$this->db->delete('settings', ['name' => 'ldap_base_dn']);
}
if ($this->db->get_where('settings', ['name' => 'ldap_filter'])->num_rows()) {
$this->db->delete('settings', ['name' => 'ldap_filter']);
}
if ($this->db->get_where('settings', ['name' => 'ldap_field_mapping'])->num_rows()) {
$this->db->delete('settings', ['name' => 'ldap_field_mapping']);
}
}
}

View File

@@ -0,0 +1,43 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_ldap_dn_column_to_users_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('ldap_dn', 'users')) {
$fields = [
'ldap_dn' => [
'type' => 'TEXT',
'null' => true,
'after' => 'is_private',
],
];
$this->dbforge->add_column('users', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('ldap_dn', 'users')) {
$this->dbforge->drop_column('users', 'ldap_dn');
}
}
}

View File

@@ -0,0 +1,44 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Drop_caldav_calendar_column_from_user_settings_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if ($this->db->field_exists('caldav_calendar', 'user_settings')) {
$this->dbforge->drop_column('user_settings', 'caldav_calendar');
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if (!$this->db->field_exists('caldav_calendar', 'user_settings')) {
$fields = [
'caldav_calendar' => [
'type' => 'VARCHAR',
'constraint' => '256',
'null' => true,
'after' => 'caldav_password',
],
];
$this->dbforge->add_column('user_settings', $fields);
}
}
}

View File

@@ -0,0 +1,44 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Online Appointment Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Add_secret_header_column_to_webhooks_table extends EA_Migration
{
/**
* Upgrade method.
*/
public function up(): void
{
if (!$this->db->field_exists('secret_header', 'webhooks')) {
$fields = [
'secret_header' => [
'type' => 'VARCHAR',
'constraint' => '256',
'default' => 'X-Ea-Token',
'after' => 'actions',
],
];
$this->dbforge->add_column('webhooks', $fields);
}
}
/**
* Downgrade method.
*/
public function down(): void
{
if ($this->db->field_exists('secret_header', 'webhooks')) {
$this->dbforge->drop_column('webhooks', 'secret_header');
}
}
}

View File

@@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>