Migrated some more SQL changes

master
Mike Koch 7 years ago
parent d29ec0374e
commit 2c8a4ad86e
No known key found for this signature in database
GPG Key ID: 9BA5D7F8391455ED

@ -1,15 +0,0 @@
<?php
abstract class AbstractUpdateMigration extends AbstractMigration {
abstract function getUpVersion();
abstract function getDownVersion();
function up($hesk_settings) {
$this->updateVersion($this->getUpVersion(), $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion($this->getDownVersion(), $hesk_settings);
}
}

@ -0,0 +1,19 @@
<?php
class UpdateMigration extends AbstractMigration {
private $upVersion;
private $downVersion;
public function __construct($upVersion, $downVersion) {
$this->upVersion = $upVersion;
$this->downVersion = $downVersion;
}
function up($hesk_settings) {
$this->updateVersion($this->upVersion, $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion($this->downVersion, $hesk_settings);
}
}

@ -22,57 +22,100 @@ function getAllMigrations() {
14 => new \v160\CreateSettingsTable(),
15 => new \v160\InsertVersionRecord(),
//1.6.1
16 => new \v161\UpdateVersion(),
16 => new UpdateMigration('1.6.1', '1.6.0'),
//1.7.0
17 => new \v170\CreateVerifiedEmailsTable(),
18 => new \v170\CreatePendingVerificationEmailsTable(),
19 => new \v170\CreateStageTicketsTable(),
20 => new \v170\UpdateVersion(),
20 => new UpdateMigration('1.7.0', '1.6.1'),
//2.0.0
21 => new \v200\RemoveNoteIdFromAttachments(),
22 => new \v200\RemoveEditInfoFromNotes(),
23 => new \v200\RemoveDefaultNotifyCustomerEmailPreference(),
24 => new \v200\AddMissingKeyToTickets(),
25 => new \v200\MigrateIpAndEmailBans(),
26 => new \v200\UpdateVersion(),
26 => new UpdateMigration('2.0.0', '1.7.0'),
//2.0.1
27 => new \v201\UpdateVersion(),
27 => new UpdateMigration('2.0.1', '2.0.0'),
//2.1.0
28 => new \v210\UpdateVersion(),
28 => new UpdateMigration('2.1.0', '2.0.1'),
//2.1.1
29 => new \v211\FixStageTicketsTable(),
30 => new \v211\UpdateVersion(),
30 => new UpdateMigration('2.1.1', '2.1.0'),
//2.2.0
31 => new \v220\AddIsAutocloseOptionToStatuses(),
32 => new \v220\AddClosableColumnToStatuses(),
33 => new \v220\UpdateVersion(),
33 => new UpdateMigration('2.2.0', '2.1.1'),
//2.2.1
34 => new \v221\UpdateVersion(),
34 => new UpdateMigration('2.2.1', '2.2.0'),
//2.3.0
35 => new \v230\AddIconToServiceMessages(),
36 => new \v230\ConsolidateStatusColumns(),
37 => new \v230\AddCoordinatesToTickets(),
38 => new \v230\AddCategoryManager(),
39 => new \v230\MovePermissionsToHeskPrivilegesColumn(),
40 => new \v230\UpdateVersion(),
40 => new UpdateMigration('2.3.0', '2.2.1'),
//2.3.1
41 => new \v231\UpdateVersion(),
41 => new UpdateMigration('2.3.1', '2.3.0'),
//2.3.2
42 => new \v232\UpdateVersion(),
42 => new UpdateMigration('2.3.2', '2.3.1'),
//2.4.0
43 => new \v240\CreateQuickHelpSectionsTable(),
44 => new \v240\CreateNewStatusNameTable(),
45 => new \v240\AddDownloadCountToAttachments(),
46 => new \v240\AddHtmlColumnToTickets(),
47 => new \v240\UpdateVersion(),
47 => new UpdateMigration('2.4.0', '2.3.2'),
//2.4.1
48 => new \v241\UpdateVersion(),
48 => new UpdateMigration('2.4.1', '2.4.0'),
//2.4.2
49 => new \v242\UpdateVersion(),
49 => new UpdateMigration('2.4.2', '2.4.1'),
//2.5.0
50 => new \v250\MigrateSettingsToDatabase(),
51 => new \v250\AddUserAgentAndScreenResToTickets(),
52 => new \v250\AddNavbarTitleUrl(),
53 => new \v250\UpdateVersion(),
53 => new UpdateMigration('2.5.0', '2.4.2'),
//2.5.1
54 => new UpdateMigration('2.5.1', '2.5.0'),
//2.5.2
55 => new UpdateMigration('2.5.2', '2.5.1'),
//2.5.3
56 => new UpdateMigration('2.5.3', '2.5.2'),
//2.5.4
57 => new UpdateMigration('2.5.4', '2.5.3'),
//2.5.5
58 => new UpdateMigration('2.5.5', '2.5.4'),
//2.6.0
59 => new \v260\AddApiTables(),
60 => new \v260\AddLoggingTable(),
61 => new \v260\AddTempAttachmentTable(),
62 => new \v260\AddCalendarModule(),
63 => new \v260\AddPrimaryKeyToSettings(),
64 => new \v260\ConvertStatusPropertiesToInts(),
65 => new UpdateMigration('2.6.0', '2.5.5'),
//2.6.1
66 => new UpdateMigration('2.6.1', '2.6.0'),
//2.6.2
67 => new \v262\AddMissingColumnsToStageTickets(),
68 => new UpdateMigration('2.6.2', '2.6.1'),
//2.6.3
69 => new UpdateMigration('2.6.3', '2.6.2'),
//2.6.4
70 => new UpdateMigration('2.6.4', '2.6.3'),
//3.0.0
71 => new \v300\MigrateHeskCustomStatuses(),
72 => new \v300\MigrateAutorefreshOption(),
73 => new \v300\AddColorSchemeSetting(),
74 => new UpdateMigration('3.0.0', '2.6.4'),
//3.0.1
75 => new UpdateMigration('3.0.1', '3.0.0'),
//3.0.2
76 => new \v302\AddMissingCustomFields(),
77 => new UpdateMigration('3.0.2', '3.0.1'),
//3.0.3 - 3.0.7
78 => new UpdateMigration('3.0.3', '3.0.2'),
79 => new UpdateMigration('3.0.4', '3.0.3'),
80 => new UpdateMigration('3.0.5', '3.0.4'),
81 => new UpdateMigration('3.0.6', '3.0.5'),
82 => new UpdateMigration('3.0.7', '3.0.6'),
);
}

@ -1,15 +0,0 @@
<?php
namespace v161;
class UpdateVersion extends \AbstractMigration {
function up($hesk_settings) {
$this->updateVersion('1.6.1', $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion('1.6.0', $hesk_settings);
}
}

@ -1,15 +0,0 @@
<?php
namespace v170;
class UpdateVersion extends \AbstractMigration {
function up($hesk_settings) {
$this->updateVersion('1.7.0', $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion('1.6.1', $hesk_settings);
}
}

@ -1,15 +0,0 @@
<?php
namespace v200;
class UpdateVersion extends \AbstractMigration {
function up($hesk_settings) {
$this->updateVersion('2.0.0', $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion('1.7.0', $hesk_settings);
}
}

@ -1,15 +0,0 @@
<?php
namespace v201;
class UpdateVersion extends \AbstractMigration {
function up($hesk_settings) {
$this->updateVersion('2.0.1', $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion('2.0.0', $hesk_settings);
}
}

@ -1,15 +0,0 @@
<?php
namespace v210;
class UpdateVersion extends \AbstractMigration {
function up($hesk_settings) {
$this->updateVersion('2.1.0', $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion('2.0.1', $hesk_settings);
}
}

@ -1,15 +0,0 @@
<?php
namespace v211;
class UpdateVersion extends \AbstractMigration {
function up($hesk_settings) {
$this->updateVersion('2.1.1', $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion('2.1.0', $hesk_settings);
}
}

@ -1,15 +0,0 @@
<?php
namespace v220;
class UpdateVersion extends \AbstractMigration {
function up($hesk_settings) {
$this->updateVersion('2.2.0', $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion('2.1.1', $hesk_settings);
}
}

@ -1,15 +0,0 @@
<?php
namespace v221;
class UpdateVersion extends \AbstractMigration {
function up($hesk_settings) {
$this->updateVersion('2.2.1', $hesk_settings);
}
function down($hesk_settings) {
$this->updateVersion('2.2.0', $hesk_settings);
}
}

@ -1,15 +0,0 @@
<?php
namespace v230;
class UpdateVersion extends \AbstractUpdateMigration {
function getUpVersion() {
return '2.3.0';
}
function getDownVersion() {
return '2.2.1';
}
}

@ -1,15 +0,0 @@
<?php
namespace v231;
class UpdateVersion extends \AbstractUpdateMigration {
function getUpVersion() {
return '2.3.1';
}
function getDownVersion() {
return '2.3.0';
}
}

@ -1,15 +0,0 @@
<?php
namespace v232;
class UpdateVersion extends \AbstractUpdateMigration {
function getUpVersion() {
return '2.3.2';
}
function getDownVersion() {
return '2.3.1';
}
}

@ -1,15 +0,0 @@
<?php
namespace v240;
class UpdateVersion extends \AbstractUpdateMigration {
function getUpVersion() {
return '2.4.0';
}
function getDownVersion() {
return '2.3.2';
}
}

@ -1,15 +0,0 @@
<?php
namespace v241;
class UpdateVersion extends \AbstractUpdateMigration {
function getUpVersion() {
return '2.4.1';
}
function getDownVersion() {
return '2.4.0';
}
}

@ -1,15 +0,0 @@
<?php
namespace v242;
class UpdateVersion extends \AbstractUpdateMigration {
function getUpVersion() {
return '2.4.2';
}
function getDownVersion() {
return '2.4.1';
}
}

@ -1,15 +0,0 @@
<?php
namespace v250;
class UpdateVersion extends \AbstractUpdateMigration {
function getUpVersion() {
return '2.5.0';
}
function getDownVersion() {
return '2.4.2';
}
}

@ -0,0 +1,20 @@
<?php
namespace v260;
class AddApiTables extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('public_api', '0')");
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "user_api_tokens` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL,
`token` VARCHAR(500) NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
}
function down($hesk_settings) {
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'public_api'");
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "user_api_tokens`");
}
}

@ -0,0 +1,49 @@
<?php
namespace v260;
class AddCalendarModule extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`start` DATETIME,
`end` DATETIME,
`all_day` ENUM('0','1') NOT NULL,
`name` VARCHAR(255) NOT NULL,
`location` VARCHAR(255),
`comments` MEDIUMTEXT,
`category` INT NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event_reminder` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL,
`event_id` INT NOT NULL,
`amount` INT NOT NULL,
`unit` INT NOT NULL,
`email_sent` ENUM('0', '1') NOT NULL DEFAULT '0') ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `due_date` DATETIME");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `overdue_email_sent` ENUM('0','1')");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ADD COLUMN `color` VARCHAR(7)");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ADD COLUMN `usage` INT NOT NULL DEFAULT 0");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `notify_overdue_unassigned` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `notify_note_unassigned`");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `default_calendar_view` INT NOT NULL DEFAULT '0' AFTER `notify_note_unassigned`");
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('enable_calendar', '1')");
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('first_day_of_week', '0')");
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('default_calendar_view', 'month')");
}
function down($hesk_settings) {
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event`");
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event_reminder`");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `due_date`");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `overdue_email_sent`");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` DROP COLUMN `color`");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` DROP COLUMN `usage`");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `notify_overdue_unassigned`");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `default_calendar_view`");
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'enable_calendar'");
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'first_day_of_week'");
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'default_calendar_view'");
}
}

@ -0,0 +1,21 @@
<?php
namespace v260;
class AddLoggingTable extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "logging` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(200),
`message` MEDIUMTEXT NOT NULL,
`severity` INT NOT NULL,
`location` MEDIUMTEXT,
`timestamp` TIMESTAMP NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
}
function down($hesk_settings) {
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "logging`");
}
}

@ -0,0 +1,14 @@
<?php
namespace v260;
class AddPrimaryKeyToSettings extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` ADD PRIMARY KEY (`Key`)");
}
function down($hesk_settings) {
}
}

@ -0,0 +1,21 @@
<?php
namespace v260;
class AddTempAttachmentTable extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`file_name` VARCHAR(255) NOT NULL,
`saved_name` VARCHAR(255) NOT NULL,
`size` INT(10) UNSIGNED NOT NULL,
`type` ENUM('0','1') NOT NULL,
`date_uploaded` TIMESTAMP NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
}
function down($hesk_settings) {
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment`");
}
}

@ -0,0 +1,29 @@
<?php
namespace v260;
class ConvertStatusPropertiesToInts extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` CHANGE `IsNewTicketStatus` `IsNewTicketStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsClosed` `IsClosed` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsClosedByClient` `IsClosedByClient` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsCustomerReplyStatus` `IsCustomerReplyStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsStaffClosedOption` `IsStaffClosedOption` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsStaffReopenedStatus` `IsStaffReopenedStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsDefaultStaffReplyStatus` `IsDefaultStaffReplyStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `LockedTicketStatus` `LockedTicketStatus` INT( 1 ) NOT NULL DEFAULT '0'");
}
function down($hesk_settings) {
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` CHANGE `IsNewTicketStatus` `IsNewTicketStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsClosed` `IsClosed` ENUM('0','1') NOT NULL DEFAULT '0',
CHANGE `IsClosedByClient` `IsClosedByClient` ENUM('0','1') NOT NULL DEFAULT '0',
CHANGE `IsCustomerReplyStatus` `IsCustomerReplyStatus` ENUM('0','1') NOT NULL DEFAULT '0',
CHANGE `IsStaffClosedOption` `IsStaffClosedOption` ENUM('0','1') NOT NULL DEFAULT '0',
CHANGE `IsStaffReopenedStatus` `IsStaffReopenedStatus` ENUM('0','1') NOT NULL DEFAULT '0',
CHANGE `IsDefaultStaffReplyStatus` `IsDefaultStaffReplyStatus` ENUM('0','1') NOT NULL DEFAULT '0',
CHANGE `LockedTicketStatus` `LockedTicketStatus` ENUM('0','1') NOT NULL DEFAULT '0'");
}
}

@ -0,0 +1,17 @@
<?php
namespace v262;
class AddMissingColumnsToStageTickets extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `due_date` DATETIME");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `overdue_email_sent` ENUM('0','1')");
}
function down($hesk_settings) {
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` DROP COLUMN `due_date`");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` DROP COLUMN `overdue_email_sent`");
}
}

@ -0,0 +1,15 @@
<?php
namespace v300;
class AddColorSchemeSetting extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('admin_color_scheme', 'skin-blue')");
}
function down($hesk_settings) {
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'admin_color_scheme'");
}
}

@ -0,0 +1,17 @@
<?php
namespace v300;
class MigrateAutorefreshOption extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `autoreload` = `autorefresh` / 10");
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `autorefresh`");
}
function down($hesk_settings) {
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `autorefresh` BIGINT NOT NULL DEFAULT 0");
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `autorefresh` = `autoreload` * 10");
}
}

@ -0,0 +1,65 @@
<?php
namespace v300;
class MigrateHeskCustomStatuses extends \AbstractMigration {
function up($hesk_settings) {
$hesk_statuses = $this->executeQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "custom_statuses` ORDER BY `order`");
$next_status_id_rs = $this->executeQuery("SELECT MAX(`ID`) AS `last_id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses`");
$next_status_id_row = hesk_dbFetchAssoc($next_status_id_rs);
$next_status_id = intval($next_status_id_row['last_id']) + 1;
$next_sort_rs = $this->executeQuery("SELECT MAX(`sort`) AS `last_sort` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses`");
$next_sort_row = hesk_dbFetchAssoc($next_sort_rs);
$next_sort = intval($next_sort_row['last_sort']) + 10;
while ($row = hesk_dbFetchAssoc($hesk_statuses)) {
$closable = $row['can_customers_change'] == '1' ? 'yes' : 'sonly';
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (`ID`,
`TextColor`,
`IsNewTicketStatus`,
`IsClosed`,
`IsClosedByClient`,
`IsCustomerReplyStatus`,
`IsStaffClosedOption`,
`IsStaffReopenedStatus`,
`IsDefaultStaffReplyStatus`,
`LockedTicketStatus`,
`IsAutocloseOption`,
`Closable`,
`Key`,
`sort`)
VALUES (" . $next_status_id . ",
'#" . $row['color'] . "',
0,
0,
0,
0,
0,
0,
0,
0,
0,
'" . $closable . "',
'STORED IN XREF TABLE',
" . $next_sort . ")");
$languages = json_decode($row['name']);
foreach ($languages as $language => $text) {
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "text_to_status_xref` (`language`, `text`, `status_id`)
VALUES ('" . $language . "', '" . $text . "', " . $next_status_id . ")");
}
// Increment the next ID and sort
$next_status_id++;
$next_sort += 10;
}
}
function down($hesk_settings) {
}
}

@ -0,0 +1,75 @@
<?php
namespace v302;
class AddMissingCustomFields extends \AbstractMigration {
function up($hesk_settings) {
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets`
ADD COLUMN `custom21` MEDIUMTEXT,
ADD COLUMN `custom22` MEDIUMTEXT,
ADD COLUMN `custom23` MEDIUMTEXT,
ADD COLUMN `custom24` MEDIUMTEXT,
ADD COLUMN `custom25` MEDIUMTEXT,
ADD COLUMN `custom26` MEDIUMTEXT,
ADD COLUMN `custom27` MEDIUMTEXT,
ADD COLUMN `custom28` MEDIUMTEXT,
ADD COLUMN `custom29` MEDIUMTEXT,
ADD COLUMN `custom30` MEDIUMTEXT,
ADD COLUMN `custom31` MEDIUMTEXT,
ADD COLUMN `custom32` MEDIUMTEXT,
ADD COLUMN `custom33` MEDIUMTEXT,
ADD COLUMN `custom34` MEDIUMTEXT,
ADD COLUMN `custom35` MEDIUMTEXT,
ADD COLUMN `custom36` MEDIUMTEXT,
ADD COLUMN `custom37` MEDIUMTEXT,
ADD COLUMN `custom38` MEDIUMTEXT,
ADD COLUMN `custom39` MEDIUMTEXT,
ADD COLUMN `custom40` MEDIUMTEXT,
ADD COLUMN `custom41` MEDIUMTEXT,
ADD COLUMN `custom42` MEDIUMTEXT,
ADD COLUMN `custom43` MEDIUMTEXT,
ADD COLUMN `custom44` MEDIUMTEXT,
ADD COLUMN `custom45` MEDIUMTEXT,
ADD COLUMN `custom46` MEDIUMTEXT,
ADD COLUMN `custom47` MEDIUMTEXT,
ADD COLUMN `custom48` MEDIUMTEXT,
ADD COLUMN `custom49` MEDIUMTEXT,
ADD COLUMN `custom50` MEDIUMTEXT");
}
function down($hesk_settings) {
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets`
DROP COLUMN `custom21`,
DROP COLUMN `custom22`,
DROP COLUMN `custom23`,
DROP COLUMN `custom24`,
DROP COLUMN `custom25`,
DROP COLUMN `custom26`,
DROP COLUMN `custom27`,
DROP COLUMN `custom28`,
DROP COLUMN `custom29`,
DROP COLUMN `custom30`,
DROP COLUMN `custom31`,
DROP COLUMN `custom32`,
DROP COLUMN `custom33`,
DROP COLUMN `custom34`,
DROP COLUMN `custom35`,
DROP COLUMN `custom36`,
DROP COLUMN `custom37`,
DROP COLUMN `custom38`,
DROP COLUMN `custom39`,
DROP COLUMN `custom40`,
DROP COLUMN `custom41`,
DROP COLUMN `custom42`,
DROP COLUMN `custom43`,
DROP COLUMN `custom44`,
DROP COLUMN `custom45`,
DROP COLUMN `custom46`,
DROP COLUMN `custom47`,
DROP COLUMN `custom48`,
DROP COLUMN `custom49`,
DROP COLUMN `custom50`");
}
}

@ -1,351 +1,4 @@
<?php
require(HESK_PATH . 'hesk_settings.inc.php');
function executeQuery($sql)
{
global $hesk_last_query;
global $hesk_db_link;
if (function_exists('mysqli_connect')) {
if (!$hesk_db_link && !hesk_dbConnect()) {
return false;
}
$hesk_last_query = $sql;
if ($res = @mysqli_query($hesk_db_link, $sql)) {
return $res;
} else {
http_response_code(500);
print "Could not execute query: $sql. MySQL said: " . mysqli_error($hesk_db_link);
die();
}
} else {
if (!$hesk_db_link && !hesk_dbConnect()) {
return false;
}
$hesk_last_query = $sql;
if ($res = @mysql_query($sql, $hesk_db_link)) {
return $res;
} else {
http_response_code(500);
print "Could not execute query: $sql. MySQL said: " . mysql_error();
die();
}
}
}
// Version 2.5.1
function execute251Scripts()
{
global $hesk_settings;
hesk_dbConnect();
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '2.5.1' WHERE `Key` = 'modsForHeskVersion'");
}
// Version 2.5.2
function execute252Scripts()
{
global $hesk_settings;
hesk_dbConnect();
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '2.5.2' WHERE `Key` = 'modsForHeskVersion'");
}
// Version 2.5.3
function execute253Scripts()
{
global $hesk_settings;
hesk_dbConnect();
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '2.5.3' WHERE `Key` = 'modsForHeskVersion'");
}
// Version 2.5.4
function execute254Scripts()
{
global $hesk_settings;
hesk_dbConnect();
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '2.5.4' WHERE `Key` = 'modsForHeskVersion'");
}
// Version 2.5.5
function execute255Scripts()
{
updateVersion('2.5.5');
}
function updateVersion($version) {
global $hesk_settings;
hesk_dbConnect();
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '{$version}' WHERE `Key` = 'modsForHeskVersion'");
}
// Version 2.6.0
function execute260Scripts()
{
global $hesk_settings;
hesk_dbConnect();
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('public_api', '0')");
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "logging` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(200),
`message` MEDIUMTEXT NOT NULL,
`severity` INT NOT NULL,
`location` MEDIUMTEXT,
`timestamp` TIMESTAMP NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "user_api_tokens` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL,
`token` VARCHAR(500) NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "temp_attachment` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`file_name` VARCHAR(255) NOT NULL,
`saved_name` VARCHAR(255) NOT NULL,
`size` INT(10) UNSIGNED NOT NULL,
`type` ENUM('0','1') NOT NULL,
`date_uploaded` TIMESTAMP NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`start` DATETIME,
`end` DATETIME,
`all_day` ENUM('0','1') NOT NULL,
`name` VARCHAR(255) NOT NULL,
`location` VARCHAR(255),
`comments` MEDIUMTEXT,
`category` INT NOT NULL) ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "calendar_event_reminder` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL,
`event_id` INT NOT NULL,
`amount` INT NOT NULL,
`unit` INT NOT NULL,
`email_sent` ENUM('0', '1') NOT NULL DEFAULT '0') ENGINE = MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `due_date` DATETIME");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `overdue_email_sent` ENUM('0','1')");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ADD COLUMN `color` VARCHAR(7)");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ADD COLUMN `usage` INT NOT NULL DEFAULT 0");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `notify_overdue_unassigned` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `notify_note_unassigned`");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `default_calendar_view` INT NOT NULL DEFAULT '0' AFTER `notify_note_unassigned`");
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('enable_calendar', '1')");
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('first_day_of_week', '0')");
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('default_calendar_view', 'month')");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` ADD PRIMARY KEY ( `Key` )");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` CHANGE `IsNewTicketStatus` `IsNewTicketStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsClosed` `IsClosed` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsClosedByClient` `IsClosedByClient` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsCustomerReplyStatus` `IsCustomerReplyStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsStaffClosedOption` `IsStaffClosedOption` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsStaffReopenedStatus` `IsStaffReopenedStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `IsDefaultStaffReplyStatus` `IsDefaultStaffReplyStatus` INT( 1 ) NOT NULL DEFAULT '0',
CHANGE `LockedTicketStatus` `LockedTicketStatus` INT( 1 ) NOT NULL DEFAULT '0'");
updateVersion('2.6.0');
}
// Version 2.6.1
function execute261Scripts() {
updateVersion('2.6.1');
}
// Version 2.6.2
function execute262Scripts() {
global $hesk_settings;
hesk_dbConnect();
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `due_date` DATETIME");
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `overdue_email_sent` ENUM('0','1')");
updateVersion('2.6.2');
}
// Version 2.6.3
function execute263Scripts() {
global $hesk_settings;
hesk_dbConnect();
updateVersion('2.6.3');
}
// Version 2.6.4
function execute264Scripts() {
global $hesk_settings;
hesk_dbConnect();
updateVersion('2.6.4');
}
// Verison 3.0.0 Beta 1
function execute300Beta1Scripts() {
global $hesk_settings;
hesk_dbConnect();
$hesk_statuses = executeQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "custom_statuses` ORDER BY `order`");
$next_status_id_rs = executeQuery("SELECT MAX(`ID`) AS `last_id` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses`");
$next_status_id_row = hesk_dbFetchAssoc($next_status_id_rs);
$next_status_id = intval($next_status_id_row['last_id']) + 1;
$next_sort_rs = executeQuery("SELECT MAX(`sort`) AS `last_sort` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses`");
$next_sort_row = hesk_dbFetchAssoc($next_sort_rs);
$next_sort = intval($next_sort_row['last_sort']) + 10;
while ($row = hesk_dbFetchAssoc($hesk_statuses)) {
$closable = $row['can_customers_change'] == '1' ? 'yes' : 'sonly';
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (`ID`,
`TextColor`,
`IsNewTicketStatus`,
`IsClosed`,
`IsClosedByClient`,
`IsCustomerReplyStatus`,
`IsStaffClosedOption`,
`IsStaffReopenedStatus`,
`IsDefaultStaffReplyStatus`,
`LockedTicketStatus`,
`IsAutocloseOption`,
`Closable`,
`Key`,
`sort`)
VALUES (" . $next_status_id . ",
'#" . $row['color'] . "',
0,
0,
0,
0,
0,
0,
0,
0,
0,
'" . $closable . "',
'STORED IN XREF TABLE',
" . $next_sort . ")");
$languages = json_decode($row['name']);
foreach ($languages as $language => $text) {
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "text_to_status_xref` (`language`, `text`, `status_id`)
VALUES ('" . $language . "', '" . $text . "', " . $next_status_id . ")");
}
// Increment the next ID and sort
$next_status_id++;
$next_sort += 10;
}
// Migrate user's autorefresh columns to the new autoreload column
// Mods for HESK is in millis; HESK is in seconds.
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `autoreload` = `autorefresh` / 10");
// Add the admin_color_scheme setting
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('admin_color_scheme', 'skin-blue')");
updateVersion('3.0.0 beta 1');
}
function execute300RC1Scripts() {
global $hesk_settings;
hesk_dbConnect();
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `autorefresh`");
updateVersion('3.0.0 RC 1');
}
function execute300Scripts() {
global $hesk_settings;
hesk_dbConnect();
updateVersion('3.0.0');
}
function execute301Scripts() {
global $hesk_settings;
hesk_dbConnect();
updateVersion('3.0.1');
}
function execute302Scripts() {
global $hesk_settings;
hesk_dbConnect();
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets`
ADD COLUMN `custom21` MEDIUMTEXT,
ADD COLUMN `custom22` MEDIUMTEXT,
ADD COLUMN `custom23` MEDIUMTEXT,
ADD COLUMN `custom24` MEDIUMTEXT,
ADD COLUMN `custom25` MEDIUMTEXT,
ADD COLUMN `custom26` MEDIUMTEXT,
ADD COLUMN `custom27` MEDIUMTEXT,
ADD COLUMN `custom28` MEDIUMTEXT,
ADD COLUMN `custom29` MEDIUMTEXT,
ADD COLUMN `custom30` MEDIUMTEXT,
ADD COLUMN `custom31` MEDIUMTEXT,
ADD COLUMN `custom32` MEDIUMTEXT,
ADD COLUMN `custom33` MEDIUMTEXT,
ADD COLUMN `custom34` MEDIUMTEXT,
ADD COLUMN `custom35` MEDIUMTEXT,
ADD COLUMN `custom36` MEDIUMTEXT,
ADD COLUMN `custom37` MEDIUMTEXT,
ADD COLUMN `custom38` MEDIUMTEXT,
ADD COLUMN `custom39` MEDIUMTEXT,
ADD COLUMN `custom40` MEDIUMTEXT,
ADD COLUMN `custom41` MEDIUMTEXT,
ADD COLUMN `custom42` MEDIUMTEXT,
ADD COLUMN `custom43` MEDIUMTEXT,
ADD COLUMN `custom44` MEDIUMTEXT,
ADD COLUMN `custom45` MEDIUMTEXT,
ADD COLUMN `custom46` MEDIUMTEXT,
ADD COLUMN `custom47` MEDIUMTEXT,
ADD COLUMN `custom48` MEDIUMTEXT,
ADD COLUMN `custom49` MEDIUMTEXT,
ADD COLUMN `custom50` MEDIUMTEXT");
updateVersion('3.0.2');
}
function execute303Scripts() {
global $hesk_settings;
hesk_dbConnect();
updateVersion('3.0.3');
}
function execute304Scripts() {
global $hesk_settings;
hesk_dbConnect();
updateVersion('3.0.4');
}
function execute305Scripts() {
global $hesk_settings;
hesk_dbConnect();
updateVersion('3.0.5');
}
function execute306Scripts() {
global $hesk_settings;
hesk_dbConnect();
updateVersion('3.0.6');
}
function execute307Scripts() {
global $hesk_settings;
hesk_dbConnect();
updateVersion('3.0.7');
}
function execute310Scripts() {
global $hesk_settings;

Loading…
Cancel
Save