Working on creating the migrations
This commit is contained in:
parent
6ea38bc90b
commit
92713506e6
@ -1,6 +1,16 @@
|
||||
<?php
|
||||
xdebug_disable();
|
||||
define('IN_SCRIPT', 1);
|
||||
define('HESK_PATH', '../../');
|
||||
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||
require(HESK_PATH . 'inc/common.inc.php');
|
||||
hesk_load_database_functions();
|
||||
|
||||
set_error_handler(function($errorNumber, $errorMessage, $errorFile, $errorLine) {
|
||||
output("An error occurred: {$errorMessage} in {$errorFile} on {$errorLine}",
|
||||
500,
|
||||
"Content-Type: text/plain");
|
||||
});
|
||||
|
||||
spl_autoload_register(function ($class) {
|
||||
// USED FOR MIGRATIONS
|
||||
@ -22,16 +32,17 @@ $request = json_decode($json, true);
|
||||
/* @var $migration AbstractMigration */
|
||||
$migration = $allMigrations[$request['migrationNumber']];
|
||||
|
||||
hesk_dbConnect();
|
||||
if ($request['direction'] === 'up') {
|
||||
$migration->up();
|
||||
$migration->up($hesk_settings);
|
||||
} elseif ($request['direction'] === 'down') {
|
||||
$migration->down();
|
||||
$migration->down($hesk_settings);
|
||||
} else {
|
||||
output(array("message" => "Invalid direction provided"), 400);
|
||||
}
|
||||
|
||||
function output($data, $response = 200) {
|
||||
function output($data, $response = 200, $header = "Content-Type: application/json") {
|
||||
http_response_code($response);
|
||||
header('Content-Type: application/json');
|
||||
header($header);
|
||||
print json_encode($data);
|
||||
}
|
@ -1,7 +1,47 @@
|
||||
<?php
|
||||
|
||||
abstract class AbstractMigration {
|
||||
abstract function up();
|
||||
abstract function up($hesk_settings);
|
||||
|
||||
abstract function down();
|
||||
abstract function down($hesk_settings);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateVersion($version, $hesk_settings) {
|
||||
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '{$version}' WHERE `Key` = 'modsForHeskVersion'");
|
||||
}
|
||||
}
|
@ -6,13 +6,67 @@ use AbstractMigration;
|
||||
|
||||
class StatusesMigration extends AbstractMigration {
|
||||
|
||||
function up() {
|
||||
// TODO: Implement up() method.
|
||||
die('up called');
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `status_int` INT NOT NULL DEFAULT 0 AFTER `status`;");
|
||||
|
||||
$ticketsRS = $this->executeQuery("SELECT `id`, `status` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets`;");
|
||||
while ($currentResult = hesk_dbFetchAssoc($ticketsRS)) {
|
||||
|
||||
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `status_int` = " . $currentResult['status'] . " WHERE `id` = " . $currentResult['id']);
|
||||
}
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `status`");
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` CHANGE COLUMN `status_int` `status` INT NOT NULL");
|
||||
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (
|
||||
`ID` INT NOT NULL,
|
||||
`ShortNameContentKey` TEXT NOT NULL,
|
||||
`TicketViewContentKey` TEXT NOT NULL,
|
||||
`TextColor` TEXT NOT NULL,
|
||||
`IsNewTicketStatus` INT NOT NULL DEFAULT 0,
|
||||
`IsClosed` INT NOT NULL DEFAULT 0,
|
||||
`IsClosedByClient` INT NOT NULL DEFAULT 0,
|
||||
`IsCustomerReplyStatus` INT NOT NULL DEFAULT 0,
|
||||
`IsStaffClosedOption` INT NOT NULL DEFAULT 0,
|
||||
`IsStaffReopenedStatus` INT NOT NULL DEFAULT 0,
|
||||
`IsDefaultStaffReplyStatus` INT NOT NULL DEFAULT 0,
|
||||
`LockedTicketStatus` INT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`ID`))");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (0, 'open', 'open', '#FF0000', 1, 0, 0, 0, 0, 0, 0, 0);");
|
||||
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (1, 'wait_reply', 'wait_staff_reply', '#FF9933', 0, 0, 0, 1, 0, 1, 0, 0);");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (2, 'replied', 'wait_cust_reply', '#0000FF', 0, 0, 0, 0, 0, 0, 1, 0);");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (3, 'resolved', 'resolved', '#008000', 0, 1, 1, 0, 1, 0, 0, 1);");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (4, 'in_progress', 'in_progress', '#000000', 0, 0, 0, 0, 0, 0, 0, 0);");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (5, 'on_hold', 'on_hold', '#000000', 0, 0, 0, 0, 0, 0, 0, 0);");
|
||||
|
||||
$keyRs = $this->executeQuery("SHOW KEYS FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE Key_name='statuses'");
|
||||
if (hesk_dbNumRows($keyRs) == 0) {
|
||||
//-- Add the key
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD KEY `statuses` (`status`)");
|
||||
}
|
||||
}
|
||||
|
||||
function down() {
|
||||
// TODO: Implement down() method.
|
||||
die('down called');
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `status_int` INT NOT NULL AFTER `status`;");
|
||||
$ticketsRS = $this->executeQuery("SELECT `id`, `status` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets`;");
|
||||
while ($currentResult = hesk_dbFetchAssoc($ticketsRS)) {
|
||||
|
||||
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `status_int` = '" . intval($currentResult['status']) . "' WHERE `id` = " . $currentResult['id']);
|
||||
}
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `status`");
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` CHANGE COLUMN `status_int` `status` INT NOT NULL");
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses`");
|
||||
}
|
||||
}
|
@ -1,9 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Pre140\StatusesMigration;
|
||||
|
||||
function getAllMigrations() {
|
||||
return array(
|
||||
1 => new StatusesMigration()
|
||||
1 => new \Pre140\StatusesMigration(),
|
||||
//1.4.0
|
||||
2 => new \v140\AddAutorefreshColumn(),
|
||||
3 => new \v140\AddDeniedIpsTable(),
|
||||
//1.4.1
|
||||
4 => new \v141\AddDeniedEmailsTable(),
|
||||
5 => new \v141\AddTicketParentColumn(),
|
||||
//1.5.0
|
||||
6 => new \v150\AddActiveColumnToUser(),
|
||||
7 => new \v150\AddCanManSettingsPermissionToUser(),
|
||||
8 => new \v150\AddDefaultNotifyCustomerEmailPreference(),
|
||||
//1.6.0
|
||||
9 => new \v160\AddNotifyNoteUnassignedProperty(),
|
||||
10 => new \v160\AddCanChangeNotificationSettingsPermission(),
|
||||
11 => new \v160\AddEditInfoToNotes(),
|
||||
12 => new \v160\AddNoteIdToAttachments(),
|
||||
13 => new \v160\ModifyTicketIdOnAttachments(),
|
||||
14 => new \v160\CreateSettingsTable(),
|
||||
15 => new \v160\InsertVersionRecord(),
|
||||
//1.6.1
|
||||
16 => new \v161\UpdateVersion(),
|
||||
//1.7.0
|
||||
17 => new \v170\CreateVerifiedEmailsTable(),
|
||||
18 => new \v170\CreatePendingVerificationEmailsTable(),
|
||||
19 => new \v170\CreateStageTicketsTable(),
|
||||
20 => new \v170\UpdateVersion(),
|
||||
//2.0.0
|
||||
21 => new \v200\RemoveNoteIdFromAttachments(),
|
||||
22 => new \v200\RemoveEditInfoFromNotes(),
|
||||
23 => new \v200\RemoveDefaultNotifyCustomerEmailPreference(),
|
||||
24 => new \v200\AddMissingKeyToTickets(),
|
||||
25 => new \v200\UpdateVersion(),
|
||||
|
||||
);
|
||||
}
|
16
install/migrations/v140/AddAutorefreshColumn.php
Normal file
16
install/migrations/v140/AddAutorefreshColumn.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace v140;
|
||||
|
||||
use AbstractMigration;
|
||||
|
||||
class AddAutorefreshColumn extends AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `autorefresh` BIGINT NOT NULL DEFAULT 0 AFTER `replies`;");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `autorefresh`;");
|
||||
}
|
||||
}
|
17
install/migrations/v140/AddDeniedIpsTable.php
Normal file
17
install/migrations/v140/AddDeniedIpsTable.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace v140;
|
||||
|
||||
|
||||
class AddDeniedIpsTable extends \AbstractMigration {
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips` (
|
||||
`ID` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`RangeStart` VARCHAR(100) NOT NULL,
|
||||
`RangeEnd` VARCHAR(100) NOT NULL)");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips`");
|
||||
}
|
||||
}
|
16
install/migrations/v141/AddDeniedEmailsTable.php
Normal file
16
install/migrations/v141/AddDeniedEmailsTable.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace v141;
|
||||
|
||||
class AddDeniedEmailsTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails` (
|
||||
ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
Email VARCHAR(100) NOT NULL);");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails`");
|
||||
}
|
||||
}
|
15
install/migrations/v141/AddTicketParentColumn.php
Normal file
15
install/migrations/v141/AddTicketParentColumn.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v141;
|
||||
|
||||
|
||||
class AddTicketParentColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `parent` MEDIUMINT(8) NULL AFTER `custom20`;");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `parent`");
|
||||
}
|
||||
}
|
15
install/migrations/v150/AddActiveColumnToUser.php
Normal file
15
install/migrations/v150/AddActiveColumnToUser.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v150;
|
||||
|
||||
|
||||
class AddActiveColumnToUser extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `active` ENUM('0', '1') NOT NULL DEFAULT '1'");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `active`");
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace v150;
|
||||
|
||||
|
||||
class AddCanManSettingsPermissionToUser extends \AbstractMigration {
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_manage_settings` ENUM('0', '1') NOT NULL DEFAULT '1'");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `can_manage_settings`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v150;
|
||||
|
||||
|
||||
class AddDefaultNotifyCustomerEmailPreference extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `default_notify_customer_email` ENUM ('0', '1') NOT NULL DEFAULT '1'");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `default_notify_customer_email`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v160;
|
||||
|
||||
|
||||
class AddCanChangeNotificationSettingsPermission extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_change_notification_settings` ENUM('0', '1') NOT NULL DEFAULT '1'");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `can_change_notification_settings`");
|
||||
}
|
||||
}
|
17
install/migrations/v160/AddEditInfoToNotes.php
Normal file
17
install/migrations/v160/AddEditInfoToNotes.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace v160;
|
||||
|
||||
|
||||
class AddEditInfoToNotes extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` ADD COLUMN `edit_date` DATETIME NULL");
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` ADD COLUMN `number_of_edits` INT NOT NULL DEFAULT 0");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` DROP COLUMN `edit_date`");
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` DROP COLUMN `number_of_edits`");
|
||||
}
|
||||
}
|
15
install/migrations/v160/AddNoteIdToAttachments.php
Normal file
15
install/migrations/v160/AddNoteIdToAttachments.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v160;
|
||||
|
||||
|
||||
class AddNoteIdToAttachments extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "attachments` ADD COLUMN `note_id` INT NULL AFTER `ticket_id`");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "attachments` DROP COLUMN `note_id`");
|
||||
}
|
||||
}
|
15
install/migrations/v160/AddNotifyNoteUnassignedProperty.php
Normal file
15
install/migrations/v160/AddNotifyNoteUnassignedProperty.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v160;
|
||||
|
||||
|
||||
class AddNotifyNoteUnassignedProperty extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `notify_note_unassigned` ENUM('0', '1') NOT NULL DEFAULT '0'");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `notify_note_unassigned`");
|
||||
}
|
||||
}
|
15
install/migrations/v160/CreateSettingsTable.php
Normal file
15
install/migrations/v160/CreateSettingsTable.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v160;
|
||||
|
||||
|
||||
class CreateSettingsTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key` NVARCHAR(200) NOT NULL, `Value` NVARCHAR(200) NOT NULL)");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings`");
|
||||
}
|
||||
}
|
15
install/migrations/v160/InsertVersionRecord.php
Normal file
15
install/migrations/v160/InsertVersionRecord.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v160;
|
||||
|
||||
|
||||
class InsertVersionRecord extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('modsForHeskVersion', '1.6.0')");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'modsForHeskVersion'");
|
||||
}
|
||||
}
|
15
install/migrations/v160/ModifyTicketIdOnAttachments.php
Normal file
15
install/migrations/v160/ModifyTicketIdOnAttachments.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v160;
|
||||
|
||||
|
||||
class ModifyTicketIdOnAttachments extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "attachments` MODIFY COLUMN `ticket_id` VARCHAR(13) NULL");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "attachments` MODIFY COLUMN `ticket_id` VARCHAR(13) NOT NULL DEFAULT ''");
|
||||
}
|
||||
}
|
15
install/migrations/v161/UpdateVersion.php
Normal file
15
install/migrations/v161/UpdateVersion.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v170;
|
||||
|
||||
|
||||
class CreatePendingVerificationEmailsTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "pending_verification_emails` (`Email` VARCHAR(255) NOT NULL, `ActivationKey` VARCHAR(500) NOT NULL)");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "pending_verification_emails`");
|
||||
}
|
||||
}
|
65
install/migrations/v170/CreateStageTicketsTable.php
Normal file
65
install/migrations/v170/CreateStageTicketsTable.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace v170;
|
||||
|
||||
|
||||
class CreateStageTicketsTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` (
|
||||
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`trackid` varchar(13) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`category` smallint(5) unsigned NOT NULL DEFAULT '1',
|
||||
`priority` enum('0','1','2','3') COLLATE utf8_unicode_ci NOT NULL DEFAULT '3',
|
||||
`subject` varchar(70) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`message` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`dt` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00',
|
||||
`lastchange` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`ip` varchar(46) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`language` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`status` int(11) NOT NULL DEFAULT '0',
|
||||
`owner` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||
`time_worked` time NOT NULL DEFAULT '00:00:00',
|
||||
`lastreplier` enum('0','1') COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
|
||||
`replierid` smallint(5) unsigned DEFAULT NULL,
|
||||
`archive` enum('0','1') COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
|
||||
`locked` enum('0','1') COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
|
||||
`attachments` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`merged` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`history` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom1` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom2` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom3` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom4` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom5` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom6` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom7` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom8` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom9` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom10` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom11` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom12` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom13` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom14` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom15` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom16` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom17` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom18` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom19` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom20` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`parent` mediumint(8) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `trackid` (`trackid`),
|
||||
KEY `archive` (`archive`),
|
||||
KEY `categories` (`category`),
|
||||
KEY `statuses` (`status`),
|
||||
KEY `owner` (`owner`)
|
||||
)");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets`");
|
||||
}
|
||||
}
|
15
install/migrations/v170/CreateVerifiedEmailsTable.php
Normal file
15
install/migrations/v170/CreateVerifiedEmailsTable.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v170;
|
||||
|
||||
class CreateVerifiedEmailsTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "verified_emails` (`Email` VARCHAR(255) NOT NULL)");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "verified_emails`");
|
||||
}
|
||||
|
||||
}
|
15
install/migrations/v170/UpdateVersion.php
Normal file
15
install/migrations/v170/UpdateVersion.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
19
install/migrations/v200/AddMissingKeyToTickets.php
Normal file
19
install/migrations/v200/AddMissingKeyToTickets.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace v200;
|
||||
|
||||
|
||||
class AddMissingKeyToTickets extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$keyRs = $this->executeQuery("SHOW KEYS FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE Key_name='statuses'");
|
||||
if (hesk_dbNumRows($keyRs) == 0) {
|
||||
//-- Add the key
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD KEY `statuses` (`status`)");
|
||||
}
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP INDEX `statuses`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v200;
|
||||
|
||||
|
||||
class RemoveDefaultNotifyCustomerEmailPreference extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `default_notify_customer_email`");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `default_notify_customer_email` ENUM ('0', '1') NOT NULL DEFAULT '1'");
|
||||
}
|
||||
}
|
17
install/migrations/v200/RemoveEditInfoFromNotes.php
Normal file
17
install/migrations/v200/RemoveEditInfoFromNotes.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace v200;
|
||||
|
||||
|
||||
class RemoveEditInfoFromNotes extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` DROP COLUMN `edit_date`");
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` DROP COLUMN `number_of_edits`");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` ADD COLUMN `edit_date` DATETIME NULL");
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` ADD COLUMN `number_of_edits` INT NOT NULL DEFAULT 0");
|
||||
}
|
||||
}
|
15
install/migrations/v200/RemoveNoteIdFromAttachments.php
Normal file
15
install/migrations/v200/RemoveNoteIdFromAttachments.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v200;
|
||||
|
||||
|
||||
class RemoveNoteIdFromAttachments extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "attachments` DROP COLUMN `note_id`");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "attachments` ADD COLUMN `note_id` INT NULL AFTER `ticket_id`");
|
||||
}
|
||||
}
|
15
install/migrations/v200/UpdateVersion.php
Normal file
15
install/migrations/v200/UpdateVersion.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
@ -37,207 +37,6 @@ function executeQuery($sql)
|
||||
}
|
||||
}
|
||||
|
||||
// Version 1.0.0 - <1.4.0
|
||||
function executePre140Scripts()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
|
||||
//-- Need to do this since we are no longer restricted on IDs and we want an INT for proper INNER JOINs
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `status_int` INT NOT NULL DEFAULT 0 AFTER `status`;");
|
||||
|
||||
$ticketsRS = executeQuery("SELECT `id`, `status` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets`;");
|
||||
while ($currentResult = hesk_dbFetchAssoc($ticketsRS)) {
|
||||
|
||||
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` SET `status_int` = " . $currentResult['status'] . " WHERE `id` = " . $currentResult['id']);
|
||||
}
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `status`");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` CHANGE COLUMN `status_int` `status` INT NOT NULL");
|
||||
|
||||
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (
|
||||
`ID` INT NOT NULL,
|
||||
`ShortNameContentKey` TEXT NOT NULL,
|
||||
`TicketViewContentKey` TEXT NOT NULL,
|
||||
`TextColor` TEXT NOT NULL,
|
||||
`IsNewTicketStatus` INT NOT NULL DEFAULT 0,
|
||||
`IsClosed` INT NOT NULL DEFAULT 0,
|
||||
`IsClosedByClient` INT NOT NULL DEFAULT 0,
|
||||
`IsCustomerReplyStatus` INT NOT NULL DEFAULT 0,
|
||||
`IsStaffClosedOption` INT NOT NULL DEFAULT 0,
|
||||
`IsStaffReopenedStatus` INT NOT NULL DEFAULT 0,
|
||||
`IsDefaultStaffReplyStatus` INT NOT NULL DEFAULT 0,
|
||||
`LockedTicketStatus` INT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`ID`))");
|
||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (0, 'open', 'open', '#FF0000', 1, 0, 0, 0, 0, 0, 0, 0);");
|
||||
|
||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (1, 'wait_reply', 'wait_staff_reply', '#FF9933', 0, 0, 0, 1, 0, 1, 0, 0);");
|
||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (2, 'replied', 'wait_cust_reply', '#0000FF', 0, 0, 0, 0, 0, 0, 1, 0);");
|
||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (3, 'resolved', 'resolved', '#008000', 0, 1, 1, 0, 1, 0, 0, 1);");
|
||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (4, 'in_progress', 'in_progress', '#000000', 0, 0, 0, 0, 0, 0, 0, 0);");
|
||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` (ID, ShortNameContentKey, TicketViewContentKey, TextColor, IsNewTicketStatus, IsClosed, IsClosedByClient, IsCustomerReplyStatus,
|
||||
IsStaffClosedOption, IsStaffReopenedStatus, IsDefaultStaffReplyStatus, LockedTicketStatus)
|
||||
VALUES (5, 'on_hold', 'on_hold', '#000000', 0, 0, 0, 0, 0, 0, 0, 0);");
|
||||
|
||||
$keyRs = executeQuery("SHOW KEYS FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE Key_name='statuses'");
|
||||
if (hesk_dbNumRows($keyRs) == 0) {
|
||||
//-- Add the key
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD KEY `statuses` (`status`)");
|
||||
}
|
||||
}
|
||||
|
||||
// Version 1.4.0
|
||||
function execute140Scripts()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `autorefresh` BIGINT NOT NULL DEFAULT 0 AFTER `replies`;");
|
||||
|
||||
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips` (
|
||||
`ID` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`RangeStart` VARCHAR(100) NOT NULL,
|
||||
`RangeEnd` VARCHAR(100) NOT NULL)");
|
||||
}
|
||||
|
||||
// Version 1.4.1
|
||||
function execute141Scripts()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails` (ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, Email VARCHAR(100) NOT NULL);");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `parent` MEDIUMINT(8) NULL AFTER `custom20`;");
|
||||
}
|
||||
|
||||
// Version 1.5.0
|
||||
function execute150Scripts()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `active` ENUM('0', '1') NOT NULL DEFAULT '1'");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_manage_settings` ENUM('0', '1') NOT NULL DEFAULT '1'");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `default_notify_customer_email` ENUM ('0', '1') NOT NULL DEFAULT '1'");
|
||||
}
|
||||
|
||||
// Version 1.6.0
|
||||
function execute160Scripts()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `notify_note_unassigned` ENUM('0', '1') NOT NULL DEFAULT '0'");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_change_notification_settings` ENUM('0', '1') NOT NULL DEFAULT '1'");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` ADD COLUMN `edit_date` DATETIME NULL");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` ADD COLUMN `number_of_edits` INT NOT NULL DEFAULT 0");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "attachments` ADD COLUMN `note_id` INT NULL AFTER `ticket_id`");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "attachments` MODIFY COLUMN `ticket_id` VARCHAR(13) NULL");
|
||||
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key` NVARCHAR(200) NOT NULL, `Value` NVARCHAR(200) NOT NULL)");
|
||||
executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) VALUES ('modsForHeskVersion', '1.6.0')");
|
||||
}
|
||||
|
||||
// Version 1.6.1
|
||||
function execute161Scripts()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '1.6.1' WHERE `Key` = 'modsForHeskVersion'");
|
||||
}
|
||||
|
||||
// BEGIN Version 1.7.0
|
||||
function execute170Scripts()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "verified_emails` (`Email` VARCHAR(255) NOT NULL)");
|
||||
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "pending_verification_emails` (`Email` VARCHAR(255) NOT NULL, `ActivationKey` VARCHAR(500) NOT NULL)");
|
||||
executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` (
|
||||
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`trackid` varchar(13) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`category` smallint(5) unsigned NOT NULL DEFAULT '1',
|
||||
`priority` enum('0','1','2','3') COLLATE utf8_unicode_ci NOT NULL DEFAULT '3',
|
||||
`subject` varchar(70) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`message` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`dt` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00',
|
||||
`lastchange` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`ip` varchar(46) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`language` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`status` int(11) NOT NULL DEFAULT '0',
|
||||
`owner` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||
`time_worked` time NOT NULL DEFAULT '00:00:00',
|
||||
`lastreplier` enum('0','1') COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
|
||||
`replierid` smallint(5) unsigned DEFAULT NULL,
|
||||
`archive` enum('0','1') COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
|
||||
`locked` enum('0','1') COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',
|
||||
`attachments` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`merged` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`history` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom1` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom2` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom3` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom4` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom5` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom6` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom7` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom8` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom9` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom10` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom11` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom12` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom13` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom14` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom15` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom16` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom17` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom18` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom19` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`custom20` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`parent` mediumint(8) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `trackid` (`trackid`),
|
||||
KEY `archive` (`archive`),
|
||||
KEY `categories` (`category`),
|
||||
KEY `statuses` (`status`),
|
||||
KEY `owner` (`owner`)
|
||||
)");
|
||||
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '1.7.0' WHERE `Key` = 'modsForHeskVersion'");
|
||||
}
|
||||
// END Version 1.7.0
|
||||
|
||||
// BEGIN Version 2.0.0
|
||||
function execute200Scripts()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
||||
hesk_dbConnect();
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "attachments` DROP COLUMN `note_id`");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` DROP COLUMN `edit_date`");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` DROP COLUMN `number_of_edits`");
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `default_notify_customer_email`");
|
||||
executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '2.0.0' WHERE `Key` = 'modsForHeskVersion'");
|
||||
|
||||
$keyRs = executeQuery("SHOW KEYS FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE Key_name='statuses'");
|
||||
if (hesk_dbNumRows($keyRs) == 0) {
|
||||
//-- Add the key
|
||||
executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD KEY `statuses` (`status`)");
|
||||
}
|
||||
}
|
||||
|
||||
function checkForIpOrEmailBans()
|
||||
{
|
||||
global $hesk_settings;
|
||||
|
Loading…
x
Reference in New Issue
Block a user