From 92713506e665da16855510050032424e4e0f0274 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Sun, 1 Oct 2017 22:03:09 -0400 Subject: [PATCH] Working on creating the migrations --- install/ajax/process-migration.php | 19 +- install/migrations/AbstractMigration.php | 44 +++- .../migrations/Pre140/StatusesMigration.php | 66 +++++- install/migrations/core.php | 36 +++- .../migrations/v140/AddAutorefreshColumn.php | 16 ++ install/migrations/v140/AddDeniedIpsTable.php | 17 ++ .../migrations/v141/AddDeniedEmailsTable.php | 16 ++ .../migrations/v141/AddTicketParentColumn.php | 15 ++ .../migrations/v150/AddActiveColumnToUser.php | 15 ++ .../AddCanManSettingsPermissionToUser.php | 14 ++ ...ddDefaultNotifyCustomerEmailPreference.php | 15 ++ ...anChangeNotificationSettingsPermission.php | 15 ++ .../migrations/v160/AddEditInfoToNotes.php | 17 ++ .../v160/AddNoteIdToAttachments.php | 15 ++ .../v160/AddNotifyNoteUnassignedProperty.php | 15 ++ .../migrations/v160/CreateSettingsTable.php | 15 ++ .../migrations/v160/InsertVersionRecord.php | 15 ++ .../v160/ModifyTicketIdOnAttachments.php | 15 ++ install/migrations/v161/UpdateVersion.php | 15 ++ .../CreatePendingVerificationEmailsTable.php | 15 ++ .../v170/CreateStageTicketsTable.php | 65 ++++++ .../v170/CreateVerifiedEmailsTable.php | 15 ++ install/migrations/v170/UpdateVersion.php | 15 ++ .../v200/AddMissingKeyToTickets.php | 19 ++ ...veDefaultNotifyCustomerEmailPreference.php | 15 ++ .../v200/RemoveEditInfoFromNotes.php | 17 ++ .../v200/RemoveNoteIdFromAttachments.php | 15 ++ install/migrations/v200/UpdateVersion.php | 15 ++ install/mods-for-hesk/sql/installSql.php | 201 ------------------ 29 files changed, 571 insertions(+), 216 deletions(-) create mode 100644 install/migrations/v140/AddAutorefreshColumn.php create mode 100644 install/migrations/v140/AddDeniedIpsTable.php create mode 100644 install/migrations/v141/AddDeniedEmailsTable.php create mode 100644 install/migrations/v141/AddTicketParentColumn.php create mode 100644 install/migrations/v150/AddActiveColumnToUser.php create mode 100644 install/migrations/v150/AddCanManSettingsPermissionToUser.php create mode 100644 install/migrations/v150/AddDefaultNotifyCustomerEmailPreference.php create mode 100644 install/migrations/v160/AddCanChangeNotificationSettingsPermission.php create mode 100644 install/migrations/v160/AddEditInfoToNotes.php create mode 100644 install/migrations/v160/AddNoteIdToAttachments.php create mode 100644 install/migrations/v160/AddNotifyNoteUnassignedProperty.php create mode 100644 install/migrations/v160/CreateSettingsTable.php create mode 100644 install/migrations/v160/InsertVersionRecord.php create mode 100644 install/migrations/v160/ModifyTicketIdOnAttachments.php create mode 100644 install/migrations/v161/UpdateVersion.php create mode 100644 install/migrations/v170/CreatePendingVerificationEmailsTable.php create mode 100644 install/migrations/v170/CreateStageTicketsTable.php create mode 100644 install/migrations/v170/CreateVerifiedEmailsTable.php create mode 100644 install/migrations/v170/UpdateVersion.php create mode 100644 install/migrations/v200/AddMissingKeyToTickets.php create mode 100644 install/migrations/v200/RemoveDefaultNotifyCustomerEmailPreference.php create mode 100644 install/migrations/v200/RemoveEditInfoFromNotes.php create mode 100644 install/migrations/v200/RemoveNoteIdFromAttachments.php create mode 100644 install/migrations/v200/UpdateVersion.php diff --git a/install/ajax/process-migration.php b/install/ajax/process-migration.php index 4b92687d..6bd6e294 100644 --- a/install/ajax/process-migration.php +++ b/install/ajax/process-migration.php @@ -1,6 +1,16 @@ 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); } \ No newline at end of file diff --git a/install/migrations/AbstractMigration.php b/install/migrations/AbstractMigration.php index e8212ad2..ea650203 100644 --- a/install/migrations/AbstractMigration.php +++ b/install/migrations/AbstractMigration.php @@ -1,7 +1,47 @@ executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = '{$version}' WHERE `Key` = 'modsForHeskVersion'"); + } } \ No newline at end of file diff --git a/install/migrations/Pre140/StatusesMigration.php b/install/migrations/Pre140/StatusesMigration.php index 3c7604a8..cad7d525 100644 --- a/install/migrations/Pre140/StatusesMigration.php +++ b/install/migrations/Pre140/StatusesMigration.php @@ -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`"); } } \ No newline at end of file diff --git a/install/migrations/core.php b/install/migrations/core.php index f4eab26e..aadf0b09 100644 --- a/install/migrations/core.php +++ b/install/migrations/core.php @@ -1,9 +1,39 @@ 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(), + ); } \ No newline at end of file diff --git a/install/migrations/v140/AddAutorefreshColumn.php b/install/migrations/v140/AddAutorefreshColumn.php new file mode 100644 index 00000000..19efc3cd --- /dev/null +++ b/install/migrations/v140/AddAutorefreshColumn.php @@ -0,0 +1,16 @@ +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`;"); + } +} \ No newline at end of file diff --git a/install/migrations/v140/AddDeniedIpsTable.php b/install/migrations/v140/AddDeniedIpsTable.php new file mode 100644 index 00000000..7d6f702e --- /dev/null +++ b/install/migrations/v140/AddDeniedIpsTable.php @@ -0,0 +1,17 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v141/AddDeniedEmailsTable.php b/install/migrations/v141/AddDeniedEmailsTable.php new file mode 100644 index 00000000..0f5d804c --- /dev/null +++ b/install/migrations/v141/AddDeniedEmailsTable.php @@ -0,0 +1,16 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v141/AddTicketParentColumn.php b/install/migrations/v141/AddTicketParentColumn.php new file mode 100644 index 00000000..91e0f422 --- /dev/null +++ b/install/migrations/v141/AddTicketParentColumn.php @@ -0,0 +1,15 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v150/AddActiveColumnToUser.php b/install/migrations/v150/AddActiveColumnToUser.php new file mode 100644 index 00000000..efad4777 --- /dev/null +++ b/install/migrations/v150/AddActiveColumnToUser.php @@ -0,0 +1,15 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v150/AddCanManSettingsPermissionToUser.php b/install/migrations/v150/AddCanManSettingsPermissionToUser.php new file mode 100644 index 00000000..ca726a4c --- /dev/null +++ b/install/migrations/v150/AddCanManSettingsPermissionToUser.php @@ -0,0 +1,14 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v150/AddDefaultNotifyCustomerEmailPreference.php b/install/migrations/v150/AddDefaultNotifyCustomerEmailPreference.php new file mode 100644 index 00000000..9bbcf5fe --- /dev/null +++ b/install/migrations/v150/AddDefaultNotifyCustomerEmailPreference.php @@ -0,0 +1,15 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v160/AddCanChangeNotificationSettingsPermission.php b/install/migrations/v160/AddCanChangeNotificationSettingsPermission.php new file mode 100644 index 00000000..32a30b4b --- /dev/null +++ b/install/migrations/v160/AddCanChangeNotificationSettingsPermission.php @@ -0,0 +1,15 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v160/AddEditInfoToNotes.php b/install/migrations/v160/AddEditInfoToNotes.php new file mode 100644 index 00000000..0fc4aa7e --- /dev/null +++ b/install/migrations/v160/AddEditInfoToNotes.php @@ -0,0 +1,17 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v160/AddNoteIdToAttachments.php b/install/migrations/v160/AddNoteIdToAttachments.php new file mode 100644 index 00000000..eb7fb080 --- /dev/null +++ b/install/migrations/v160/AddNoteIdToAttachments.php @@ -0,0 +1,15 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v160/AddNotifyNoteUnassignedProperty.php b/install/migrations/v160/AddNotifyNoteUnassignedProperty.php new file mode 100644 index 00000000..92f39262 --- /dev/null +++ b/install/migrations/v160/AddNotifyNoteUnassignedProperty.php @@ -0,0 +1,15 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v160/CreateSettingsTable.php b/install/migrations/v160/CreateSettingsTable.php new file mode 100644 index 00000000..d7ee32c6 --- /dev/null +++ b/install/migrations/v160/CreateSettingsTable.php @@ -0,0 +1,15 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v160/InsertVersionRecord.php b/install/migrations/v160/InsertVersionRecord.php new file mode 100644 index 00000000..c99b47d8 --- /dev/null +++ b/install/migrations/v160/InsertVersionRecord.php @@ -0,0 +1,15 @@ +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'"); + } +} \ No newline at end of file diff --git a/install/migrations/v160/ModifyTicketIdOnAttachments.php b/install/migrations/v160/ModifyTicketIdOnAttachments.php new file mode 100644 index 00000000..65cf4f16 --- /dev/null +++ b/install/migrations/v160/ModifyTicketIdOnAttachments.php @@ -0,0 +1,15 @@ +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 ''"); + } +} \ No newline at end of file diff --git a/install/migrations/v161/UpdateVersion.php b/install/migrations/v161/UpdateVersion.php new file mode 100644 index 00000000..aec92254 --- /dev/null +++ b/install/migrations/v161/UpdateVersion.php @@ -0,0 +1,15 @@ +updateVersion('1.6.1', $hesk_settings); + } + + function down($hesk_settings) { + $this->updateVersion('1.6.0', $hesk_settings); + } +} \ No newline at end of file diff --git a/install/migrations/v170/CreatePendingVerificationEmailsTable.php b/install/migrations/v170/CreatePendingVerificationEmailsTable.php new file mode 100644 index 00000000..4b9af7b7 --- /dev/null +++ b/install/migrations/v170/CreatePendingVerificationEmailsTable.php @@ -0,0 +1,15 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v170/CreateStageTicketsTable.php b/install/migrations/v170/CreateStageTicketsTable.php new file mode 100644 index 00000000..17b62a26 --- /dev/null +++ b/install/migrations/v170/CreateStageTicketsTable.php @@ -0,0 +1,65 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v170/CreateVerifiedEmailsTable.php b/install/migrations/v170/CreateVerifiedEmailsTable.php new file mode 100644 index 00000000..4f0e5a13 --- /dev/null +++ b/install/migrations/v170/CreateVerifiedEmailsTable.php @@ -0,0 +1,15 @@ +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`"); + } + +} \ No newline at end of file diff --git a/install/migrations/v170/UpdateVersion.php b/install/migrations/v170/UpdateVersion.php new file mode 100644 index 00000000..fbc86854 --- /dev/null +++ b/install/migrations/v170/UpdateVersion.php @@ -0,0 +1,15 @@ +updateVersion('1.7.0', $hesk_settings); + } + + function down($hesk_settings) { + $this->updateVersion('1.6.1', $hesk_settings); + } +} \ No newline at end of file diff --git a/install/migrations/v200/AddMissingKeyToTickets.php b/install/migrations/v200/AddMissingKeyToTickets.php new file mode 100644 index 00000000..75c32d9a --- /dev/null +++ b/install/migrations/v200/AddMissingKeyToTickets.php @@ -0,0 +1,19 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v200/RemoveDefaultNotifyCustomerEmailPreference.php b/install/migrations/v200/RemoveDefaultNotifyCustomerEmailPreference.php new file mode 100644 index 00000000..93f42941 --- /dev/null +++ b/install/migrations/v200/RemoveDefaultNotifyCustomerEmailPreference.php @@ -0,0 +1,15 @@ +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'"); + } +} \ No newline at end of file diff --git a/install/migrations/v200/RemoveEditInfoFromNotes.php b/install/migrations/v200/RemoveEditInfoFromNotes.php new file mode 100644 index 00000000..2793fb14 --- /dev/null +++ b/install/migrations/v200/RemoveEditInfoFromNotes.php @@ -0,0 +1,17 @@ +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"); + } +} \ No newline at end of file diff --git a/install/migrations/v200/RemoveNoteIdFromAttachments.php b/install/migrations/v200/RemoveNoteIdFromAttachments.php new file mode 100644 index 00000000..3c07a1c8 --- /dev/null +++ b/install/migrations/v200/RemoveNoteIdFromAttachments.php @@ -0,0 +1,15 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v200/UpdateVersion.php b/install/migrations/v200/UpdateVersion.php new file mode 100644 index 00000000..e002db74 --- /dev/null +++ b/install/migrations/v200/UpdateVersion.php @@ -0,0 +1,15 @@ +updateVersion('2.0.0', $hesk_settings); + } + + function down($hesk_settings) { + $this->updateVersion('1.7.0', $hesk_settings); + } +} \ No newline at end of file diff --git a/install/mods-for-hesk/sql/installSql.php b/install/mods-for-hesk/sql/installSql.php index 19991d8c..5345902b 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -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;