From 2c8a4ad86e749bdeb6ad4f225b608a5227df4d84 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 3 Oct 2017 22:05:35 -0400 Subject: [PATCH] Migrated some more SQL changes --- .../migrations/AbstractUpdateMigration.php | 15 - install/migrations/UpdateMigration.php | 19 + install/migrations/core.php | 73 +++- install/migrations/v161/UpdateVersion.php | 15 - install/migrations/v170/UpdateVersion.php | 15 - install/migrations/v200/UpdateVersion.php | 15 - install/migrations/v201/UpdateVersion.php | 15 - install/migrations/v210/UpdateVersion.php | 15 - install/migrations/v211/UpdateVersion.php | 15 - install/migrations/v220/UpdateVersion.php | 15 - install/migrations/v221/UpdateVersion.php | 15 - install/migrations/v230/UpdateVersion.php | 15 - install/migrations/v231/UpdateVersion.php | 15 - install/migrations/v232/UpdateVersion.php | 15 - install/migrations/v240/UpdateVersion.php | 15 - install/migrations/v241/UpdateVersion.php | 15 - install/migrations/v242/UpdateVersion.php | 15 - install/migrations/v250/UpdateVersion.php | 15 - install/migrations/v260/AddApiTables.php | 20 + install/migrations/v260/AddCalendarModule.php | 49 +++ install/migrations/v260/AddLoggingTable.php | 21 ++ .../v260/AddPrimaryKeyToSettings.php | 14 + .../v260/AddTempAttachmentTable.php | 21 ++ .../v260/ConvertStatusPropertiesToInts.php | 29 ++ .../v262/AddMissingColumnsToStageTickets.php | 17 + .../migrations/v300/AddColorSchemeSetting.php | 15 + .../v300/MigrateAutorefreshOption.php | 17 + .../v300/MigrateHeskCustomStatuses.php | 65 ++++ .../v302/AddMissingCustomFields.php | 75 ++++ install/mods-for-hesk/sql/installSql.php | 347 ------------------ 30 files changed, 420 insertions(+), 602 deletions(-) delete mode 100644 install/migrations/AbstractUpdateMigration.php create mode 100644 install/migrations/UpdateMigration.php delete mode 100644 install/migrations/v161/UpdateVersion.php delete mode 100644 install/migrations/v170/UpdateVersion.php delete mode 100644 install/migrations/v200/UpdateVersion.php delete mode 100644 install/migrations/v201/UpdateVersion.php delete mode 100644 install/migrations/v210/UpdateVersion.php delete mode 100644 install/migrations/v211/UpdateVersion.php delete mode 100644 install/migrations/v220/UpdateVersion.php delete mode 100644 install/migrations/v221/UpdateVersion.php delete mode 100644 install/migrations/v230/UpdateVersion.php delete mode 100644 install/migrations/v231/UpdateVersion.php delete mode 100644 install/migrations/v232/UpdateVersion.php delete mode 100644 install/migrations/v240/UpdateVersion.php delete mode 100644 install/migrations/v241/UpdateVersion.php delete mode 100644 install/migrations/v242/UpdateVersion.php delete mode 100644 install/migrations/v250/UpdateVersion.php create mode 100644 install/migrations/v260/AddApiTables.php create mode 100644 install/migrations/v260/AddCalendarModule.php create mode 100644 install/migrations/v260/AddLoggingTable.php create mode 100644 install/migrations/v260/AddPrimaryKeyToSettings.php create mode 100644 install/migrations/v260/AddTempAttachmentTable.php create mode 100644 install/migrations/v260/ConvertStatusPropertiesToInts.php create mode 100644 install/migrations/v262/AddMissingColumnsToStageTickets.php create mode 100644 install/migrations/v300/AddColorSchemeSetting.php create mode 100644 install/migrations/v300/MigrateAutorefreshOption.php create mode 100644 install/migrations/v300/MigrateHeskCustomStatuses.php create mode 100644 install/migrations/v302/AddMissingCustomFields.php diff --git a/install/migrations/AbstractUpdateMigration.php b/install/migrations/AbstractUpdateMigration.php deleted file mode 100644 index c1f9ce16..00000000 --- a/install/migrations/AbstractUpdateMigration.php +++ /dev/null @@ -1,15 +0,0 @@ -updateVersion($this->getUpVersion(), $hesk_settings); - } - - function down($hesk_settings) { - $this->updateVersion($this->getDownVersion(), $hesk_settings); - } -} \ No newline at end of file diff --git a/install/migrations/UpdateMigration.php b/install/migrations/UpdateMigration.php new file mode 100644 index 00000000..89fc3a86 --- /dev/null +++ b/install/migrations/UpdateMigration.php @@ -0,0 +1,19 @@ +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); + } +} \ No newline at end of file diff --git a/install/migrations/core.php b/install/migrations/core.php index 7b9c5979..8032096b 100644 --- a/install/migrations/core.php +++ b/install/migrations/core.php @@ -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'), ); } \ No newline at end of file diff --git a/install/migrations/v161/UpdateVersion.php b/install/migrations/v161/UpdateVersion.php deleted file mode 100644 index aec92254..00000000 --- a/install/migrations/v161/UpdateVersion.php +++ /dev/null @@ -1,15 +0,0 @@ -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/UpdateVersion.php b/install/migrations/v170/UpdateVersion.php deleted file mode 100644 index fbc86854..00000000 --- a/install/migrations/v170/UpdateVersion.php +++ /dev/null @@ -1,15 +0,0 @@ -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/UpdateVersion.php b/install/migrations/v200/UpdateVersion.php deleted file mode 100644 index e002db74..00000000 --- a/install/migrations/v200/UpdateVersion.php +++ /dev/null @@ -1,15 +0,0 @@ -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/migrations/v201/UpdateVersion.php b/install/migrations/v201/UpdateVersion.php deleted file mode 100644 index d9d93464..00000000 --- a/install/migrations/v201/UpdateVersion.php +++ /dev/null @@ -1,15 +0,0 @@ -updateVersion('2.0.1', $hesk_settings); - } - - function down($hesk_settings) { - $this->updateVersion('2.0.0', $hesk_settings); - } -} \ No newline at end of file diff --git a/install/migrations/v210/UpdateVersion.php b/install/migrations/v210/UpdateVersion.php deleted file mode 100644 index aa815c03..00000000 --- a/install/migrations/v210/UpdateVersion.php +++ /dev/null @@ -1,15 +0,0 @@ -updateVersion('2.1.0', $hesk_settings); - } - - function down($hesk_settings) { - $this->updateVersion('2.0.1', $hesk_settings); - } -} \ No newline at end of file diff --git a/install/migrations/v211/UpdateVersion.php b/install/migrations/v211/UpdateVersion.php deleted file mode 100644 index 4b12c3c0..00000000 --- a/install/migrations/v211/UpdateVersion.php +++ /dev/null @@ -1,15 +0,0 @@ -updateVersion('2.1.1', $hesk_settings); - } - - function down($hesk_settings) { - $this->updateVersion('2.1.0', $hesk_settings); - } -} \ No newline at end of file diff --git a/install/migrations/v220/UpdateVersion.php b/install/migrations/v220/UpdateVersion.php deleted file mode 100644 index 28364d6f..00000000 --- a/install/migrations/v220/UpdateVersion.php +++ /dev/null @@ -1,15 +0,0 @@ -updateVersion('2.2.0', $hesk_settings); - } - - function down($hesk_settings) { - $this->updateVersion('2.1.1', $hesk_settings); - } -} \ No newline at end of file diff --git a/install/migrations/v221/UpdateVersion.php b/install/migrations/v221/UpdateVersion.php deleted file mode 100644 index 085e17c1..00000000 --- a/install/migrations/v221/UpdateVersion.php +++ /dev/null @@ -1,15 +0,0 @@ -updateVersion('2.2.1', $hesk_settings); - } - - function down($hesk_settings) { - $this->updateVersion('2.2.0', $hesk_settings); - } -} \ No newline at end of file diff --git a/install/migrations/v230/UpdateVersion.php b/install/migrations/v230/UpdateVersion.php deleted file mode 100644 index 18b7bf65..00000000 --- a/install/migrations/v230/UpdateVersion.php +++ /dev/null @@ -1,15 +0,0 @@ -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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v260/AddCalendarModule.php b/install/migrations/v260/AddCalendarModule.php new file mode 100644 index 00000000..4e1344ad --- /dev/null +++ b/install/migrations/v260/AddCalendarModule.php @@ -0,0 +1,49 @@ +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'"); + } +} \ No newline at end of file diff --git a/install/migrations/v260/AddLoggingTable.php b/install/migrations/v260/AddLoggingTable.php new file mode 100644 index 00000000..b1f55305 --- /dev/null +++ b/install/migrations/v260/AddLoggingTable.php @@ -0,0 +1,21 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v260/AddPrimaryKeyToSettings.php b/install/migrations/v260/AddPrimaryKeyToSettings.php new file mode 100644 index 00000000..f77bc234 --- /dev/null +++ b/install/migrations/v260/AddPrimaryKeyToSettings.php @@ -0,0 +1,14 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` ADD PRIMARY KEY (`Key`)"); + } + + function down($hesk_settings) { + } +} \ No newline at end of file diff --git a/install/migrations/v260/AddTempAttachmentTable.php b/install/migrations/v260/AddTempAttachmentTable.php new file mode 100644 index 00000000..b66d7b70 --- /dev/null +++ b/install/migrations/v260/AddTempAttachmentTable.php @@ -0,0 +1,21 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v260/ConvertStatusPropertiesToInts.php b/install/migrations/v260/ConvertStatusPropertiesToInts.php new file mode 100644 index 00000000..7f04f9b3 --- /dev/null +++ b/install/migrations/v260/ConvertStatusPropertiesToInts.php @@ -0,0 +1,29 @@ +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'"); + } +} \ No newline at end of file diff --git a/install/migrations/v262/AddMissingColumnsToStageTickets.php b/install/migrations/v262/AddMissingColumnsToStageTickets.php new file mode 100644 index 00000000..702c3878 --- /dev/null +++ b/install/migrations/v262/AddMissingColumnsToStageTickets.php @@ -0,0 +1,17 @@ +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`"); + } +} \ No newline at end of file diff --git a/install/migrations/v300/AddColorSchemeSetting.php b/install/migrations/v300/AddColorSchemeSetting.php new file mode 100644 index 00000000..e488350b --- /dev/null +++ b/install/migrations/v300/AddColorSchemeSetting.php @@ -0,0 +1,15 @@ +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'"); + } +} \ No newline at end of file diff --git a/install/migrations/v300/MigrateAutorefreshOption.php b/install/migrations/v300/MigrateAutorefreshOption.php new file mode 100644 index 00000000..3a1366ba --- /dev/null +++ b/install/migrations/v300/MigrateAutorefreshOption.php @@ -0,0 +1,17 @@ +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"); + } +} \ No newline at end of file diff --git a/install/migrations/v300/MigrateHeskCustomStatuses.php b/install/migrations/v300/MigrateHeskCustomStatuses.php new file mode 100644 index 00000000..5f2a5132 --- /dev/null +++ b/install/migrations/v300/MigrateHeskCustomStatuses.php @@ -0,0 +1,65 @@ +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) { + } +} \ No newline at end of file diff --git a/install/migrations/v302/AddMissingCustomFields.php b/install/migrations/v302/AddMissingCustomFields.php new file mode 100644 index 00000000..9975c831 --- /dev/null +++ b/install/migrations/v302/AddMissingCustomFields.php @@ -0,0 +1,75 @@ +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`"); + } +} \ 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 453f3a08..93848b24 100644 --- a/install/mods-for-hesk/sql/installSql.php +++ b/install/mods-for-hesk/sql/installSql.php @@ -1,351 +1,4 @@ $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;