diff --git a/install/database-validation.php b/install/database-validation.php index 7e3d462f..e26c45cf 100644 --- a/install/database-validation.php +++ b/install/database-validation.php @@ -199,6 +199,11 @@ hesk_dbConnect(); $all_good = $all_good & run_setting_check('admin_sidebar_font_weight'); $all_good = $all_good & run_setting_check('admin_sidebar_header_background'); $all_good = $all_good & run_setting_check('admin_sidebar_header_text'); + output_header_row('3.2.0'); + $all_good &= run_table_check('audit_trail'); + $all_good &= run_table_check('audit_trail_to_replacement_values'); + $all_good &= run_column_check('categories', 'mfh_description'); + $all_good &= run_column_check('custom_fields', 'mfh_description'); if ($all_good) { echo ""; diff --git a/install/migrations/AbstractUpdatableMigration.php b/install/migrations/AbstractUpdatableMigration.php new file mode 100644 index 00000000..98311b79 --- /dev/null +++ b/install/migrations/AbstractUpdatableMigration.php @@ -0,0 +1,27 @@ +migrationNumber = $migrationNumber; + } + + function up($hesk_settings) { + $this->innerUp($hesk_settings); + + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = " . intval($this->migrationNumber) . " + WHERE `Key` = 'migrationNumber'"); + } + + abstract function innerUp($hesk_settings); + + function down($hesk_settings) { + $this->innerDown($hesk_settings); + + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` SET `Value` = " . (intval($this->migrationNumber) - 1) . " + WHERE `Key` = 'migrationNumber'"); + } + + abstract function innerDown($hesk_settings); +} \ No newline at end of file diff --git a/install/migrations/LegacyUpdateMigration.php b/install/migrations/LegacyUpdateMigration.php new file mode 100644 index 00000000..ffbc9afb --- /dev/null +++ b/install/migrations/LegacyUpdateMigration.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/UpdateMigration.php b/install/migrations/UpdateMigration.php index 89fc3a86..2a585e69 100644 --- a/install/migrations/UpdateMigration.php +++ b/install/migrations/UpdateMigration.php @@ -1,19 +1,21 @@ upVersion = $upVersion; $this->downVersion = $downVersion; } - function up($hesk_settings) { + function innerUp($hesk_settings) { $this->updateVersion($this->upVersion, $hesk_settings); } - function down($hesk_settings) { + function innerDown($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 732d9726..8f9fa300 100644 --- a/install/migrations/core.php +++ b/install/migrations/core.php @@ -38,113 +38,116 @@ function getAllMigrations() { 14 => new \v160\CreateSettingsTable(), 15 => new \v160\InsertVersionRecord(), //1.6.1 - 16 => new UpdateMigration('1.6.1', '1.6.0'), + 16 => new LegacyUpdateMigration('1.6.1', '1.6.0'), //1.7.0 17 => new \v170\CreateVerifiedEmailsTable(), 18 => new \v170\CreatePendingVerificationEmailsTable(), 19 => new \v170\CreateStageTicketsTable(), - 20 => new UpdateMigration('1.7.0', '1.6.1'), + 20 => new LegacyUpdateMigration('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 UpdateMigration('2.0.0', '1.7.0'), + 26 => new LegacyUpdateMigration('2.0.0', '1.7.0'), //2.0.1 - 27 => new UpdateMigration('2.0.1', '2.0.0'), + 27 => new LegacyUpdateMigration('2.0.1', '2.0.0'), //2.1.0 - 28 => new UpdateMigration('2.1.0', '2.0.1'), + 28 => new LegacyUpdateMigration('2.1.0', '2.0.1'), //2.1.1 29 => new \v211\FixStageTicketsTable(), - 30 => new UpdateMigration('2.1.1', '2.1.0'), + 30 => new LegacyUpdateMigration('2.1.1', '2.1.0'), //2.2.0 31 => new \v220\AddIsAutocloseOptionToStatuses(), 32 => new \v220\AddClosableColumnToStatuses(), - 33 => new UpdateMigration('2.2.0', '2.1.1'), + 33 => new LegacyUpdateMigration('2.2.0', '2.1.1'), //2.2.1 - 34 => new UpdateMigration('2.2.1', '2.2.0'), + 34 => new LegacyUpdateMigration('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 UpdateMigration('2.3.0', '2.2.1'), + 40 => new \v230\CreatePermissionTemplates(), + 41 => new LegacyUpdateMigration('2.3.0', '2.2.1'), //2.3.1 - 41 => new UpdateMigration('2.3.1', '2.3.0'), + 42 => new LegacyUpdateMigration('2.3.1', '2.3.0'), //2.3.2 - 42 => new UpdateMigration('2.3.2', '2.3.1'), + 43 => new LegacyUpdateMigration('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 UpdateMigration('2.4.0', '2.3.2'), + 44 => new \v240\CreateQuickHelpSectionsTable(), + 45 => new \v240\CreateNewStatusNameTable(), + 46 => new \v240\AddDownloadCountToAttachments(), + 47 => new \v240\AddHtmlColumnToTickets(), + 48 => new LegacyUpdateMigration('2.4.0', '2.3.2'), //2.4.1 - 48 => new UpdateMigration('2.4.1', '2.4.0'), + 49 => new LegacyUpdateMigration('2.4.1', '2.4.0'), //2.4.2 - 49 => new UpdateMigration('2.4.2', '2.4.1'), + 50 => new LegacyUpdateMigration('2.4.2', '2.4.1'), //2.5.0 - 50 => new \v250\MigrateSettingsToDatabase(), - 51 => new \v250\AddUserAgentAndScreenResToTickets(), - 52 => new \v250\AddNavbarTitleUrl(), - 53 => new UpdateMigration('2.5.0', '2.4.2'), + 51 => new \v250\MigrateSettingsToDatabase(), + 52 => new \v250\AddUserAgentAndScreenResToTickets(), + 53 => new \v250\AddNavbarTitleUrl(), + 54 => new LegacyUpdateMigration('2.5.0', '2.4.2'), //2.5.1 - 54 => new UpdateMigration('2.5.1', '2.5.0'), + 55 => new LegacyUpdateMigration('2.5.1', '2.5.0'), //2.5.2 - 55 => new UpdateMigration('2.5.2', '2.5.1'), + 56 => new LegacyUpdateMigration('2.5.2', '2.5.1'), //2.5.3 - 56 => new UpdateMigration('2.5.3', '2.5.2'), + 57 => new LegacyUpdateMigration('2.5.3', '2.5.2'), //2.5.4 - 57 => new UpdateMigration('2.5.4', '2.5.3'), + 58 => new LegacyUpdateMigration('2.5.4', '2.5.3'), //2.5.5 - 58 => new UpdateMigration('2.5.5', '2.5.4'), + 59 => new LegacyUpdateMigration('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'), + 60 => new \v260\AddApiTables(), + 61 => new \v260\AddLoggingTable(), + 62 => new \v260\AddTempAttachmentTable(), + 63 => new \v260\AddCalendarModule(), + 64 => new \v260\AddPrimaryKeyToSettings(), + 65 => new \v260\ConvertStatusPropertiesToInts(), + 66 => new LegacyUpdateMigration('2.6.0', '2.5.5'), //2.6.1 - 66 => new UpdateMigration('2.6.1', '2.6.0'), + 67 => new LegacyUpdateMigration('2.6.1', '2.6.0'), //2.6.2 - 67 => new \v262\AddMissingColumnsToStageTickets(), - 68 => new UpdateMigration('2.6.2', '2.6.1'), + 68 => new \v262\AddMissingColumnsToStageTickets(), + 69 => new LegacyUpdateMigration('2.6.2', '2.6.1'), //2.6.3 - 69 => new UpdateMigration('2.6.3', '2.6.2'), + 70 => new LegacyUpdateMigration('2.6.3', '2.6.2'), //2.6.4 - 70 => new UpdateMigration('2.6.4', '2.6.3'), + 71 => new LegacyUpdateMigration('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'), + 72 => new \v300\MigrateHeskCustomStatuses(), + 73 => new \v300\MigrateAutorefreshOption(), + 74 => new \v300\AddColorSchemeSetting(), + 75 => new LegacyUpdateMigration('3.0.0', '2.6.4'), //3.0.1 - 75 => new UpdateMigration('3.0.1', '3.0.0'), + 76 => new LegacyUpdateMigration('3.0.1', '3.0.0'), //3.0.2 - 76 => new \v302\AddMissingCustomFields(), - 77 => new UpdateMigration('3.0.2', '3.0.1'), + 77 => new \v302\AddMissingCustomFields(), + 78 => new LegacyUpdateMigration('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'), + 79 => new LegacyUpdateMigration('3.0.3', '3.0.2'), + 80 => new LegacyUpdateMigration('3.0.4', '3.0.3'), + 81 => new LegacyUpdateMigration('3.0.5', '3.0.4'), + 82 => new LegacyUpdateMigration('3.0.6', '3.0.5'), + 83 => new LegacyUpdateMigration('3.0.7', '3.0.6'), //3.1.0 - 83 => new \v310\AddStackTraceToLogs(), - 84 => new \v310\AddCustomNavElements(), - 85 => new \v310\AddMoreColorOptionsToCategories(), - 86 => new \v310\AddNewLoginSettings(), - 87 => new \v310\AddApiUrlRewriteSetting(), - 88 => new \v310\ConvertPresetToIndividualColors(), - 89 => new UpdateMigration('3.1.0', '3.0.7'), + 84 => new \v310\AddStackTraceToLogs(), + 85 => new \v310\AddCustomNavElements(), + 86 => new \v310\AddMoreColorOptionsToCategories(), + 87 => new \v310\AddNewLoginSettings(), + 88 => new \v310\AddApiUrlRewriteSetting(), + 89 => new \v310\ConvertPresetToIndividualColors(), + 90 => new LegacyUpdateMigration('3.1.0', '3.0.7'), //3.1.1 - 90 => new UpdateMigration('3.1.1', '3.1.0'), + 91 => new LegacyUpdateMigration('3.1.1', '3.1.0'), //3.2.0 - 91 => new \v320\AddDescriptionToCategoriesAndCustomFields(), - 92 => new \v320\AddAuditTrail(), + 92 => new \v320\AddDescriptionToCategoriesAndCustomFields(), + 93 => new \v320\AddAuditTrail(), + 94 => new \v320\AddMigrationSetting(), + 95 => new UpdateMigration('3.2.0', '3.1.1', 95), ); } \ No newline at end of file diff --git a/install/migrations/v200/MigrateIpAndEmailBans.php b/install/migrations/v200/MigrateIpAndEmailBans.php index 604b370a..3174fe83 100644 --- a/install/migrations/v200/MigrateIpAndEmailBans.php +++ b/install/migrations/v200/MigrateIpAndEmailBans.php @@ -46,8 +46,5 @@ class MigrateIpAndEmailBans extends \AbstractMigration { while ($row = hesk_dbFetchAssoc($ips)) { $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips` (`RangeStart`, `RangeEnd`) VALUES (" . $row['ip_from'] . ", " . $row['ip_to'] . ")"); } - - $this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_ips`"); - $this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_emails`"); } } \ No newline at end of file diff --git a/install/migrations/v230/CreatePermissionTemplates.php b/install/migrations/v230/CreatePermissionTemplates.php index bd7365ca..fad3cff9 100644 --- a/install/migrations/v230/CreatePermissionTemplates.php +++ b/install/migrations/v230/CreatePermissionTemplates.php @@ -19,6 +19,7 @@ class CreatePermissionTemplates extends \AbstractMigration { } function down($hesk_settings) { - // TODO: Implement down() method. + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `permission_template`"); + $this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates`"); } } \ No newline at end of file diff --git a/install/migrations/v310/ConvertPresetToIndividualColors.php b/install/migrations/v310/ConvertPresetToIndividualColors.php index b3c0127b..c0d8461d 100644 --- a/install/migrations/v310/ConvertPresetToIndividualColors.php +++ b/install/migrations/v310/ConvertPresetToIndividualColors.php @@ -14,7 +14,7 @@ class ConvertPresetToIndividualColors extends \AbstractMigration { $theme = $theme_preset_row['Value']; } - $light_theme = preg_match('/.*-light/g', $theme); + $light_theme = preg_match_all('/.*-light/', $theme); $navbar = array( 'background' => '', 'text' => '#fff', diff --git a/install/migrations/v320/AddMigrationSetting.php b/install/migrations/v320/AddMigrationSetting.php new file mode 100644 index 00000000..72c9c0b3 --- /dev/null +++ b/install/migrations/v320/AddMigrationSetting.php @@ -0,0 +1,16 @@ +executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` (`Key`, `Value`) + VALUES ('migrationNumber', '94')"); + } + + function down($hesk_settings) { + $this->executeQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "settings` WHERE `Key` = 'migrationNumber'"); + } +} \ No newline at end of file