Fix some migrations, add new ones to keep track of migration number

master
Mike Koch 7 years ago
parent 8b7f0ace3a
commit 0df87dde57
No known key found for this signature in database
GPG Key ID: 9BA5D7F8391455ED

@ -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_font_weight');
$all_good = $all_good & run_setting_check('admin_sidebar_header_background'); $all_good = $all_good & run_setting_check('admin_sidebar_header_background');
$all_good = $all_good & run_setting_check('admin_sidebar_header_text'); $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) { if ($all_good) {
echo "<script>$('#all-good').show()</script>"; echo "<script>$('#all-good').show()</script>";

@ -0,0 +1,27 @@
<?php
abstract class AbstractUpdatableMigration extends AbstractMigration {
private $migrationNumber;
function __construct($migrationNumber) {
$this->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);
}

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

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

@ -38,113 +38,116 @@ function getAllMigrations() {
14 => new \v160\CreateSettingsTable(), 14 => new \v160\CreateSettingsTable(),
15 => new \v160\InsertVersionRecord(), 15 => new \v160\InsertVersionRecord(),
//1.6.1 //1.6.1
16 => new UpdateMigration('1.6.1', '1.6.0'), 16 => new LegacyUpdateMigration('1.6.1', '1.6.0'),
//1.7.0 //1.7.0
17 => new \v170\CreateVerifiedEmailsTable(), 17 => new \v170\CreateVerifiedEmailsTable(),
18 => new \v170\CreatePendingVerificationEmailsTable(), 18 => new \v170\CreatePendingVerificationEmailsTable(),
19 => new \v170\CreateStageTicketsTable(), 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 //2.0.0
21 => new \v200\RemoveNoteIdFromAttachments(), 21 => new \v200\RemoveNoteIdFromAttachments(),
22 => new \v200\RemoveEditInfoFromNotes(), 22 => new \v200\RemoveEditInfoFromNotes(),
23 => new \v200\RemoveDefaultNotifyCustomerEmailPreference(), 23 => new \v200\RemoveDefaultNotifyCustomerEmailPreference(),
24 => new \v200\AddMissingKeyToTickets(), 24 => new \v200\AddMissingKeyToTickets(),
25 => new \v200\MigrateIpAndEmailBans(), 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 //2.0.1
27 => new UpdateMigration('2.0.1', '2.0.0'), 27 => new LegacyUpdateMigration('2.0.1', '2.0.0'),
//2.1.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 //2.1.1
29 => new \v211\FixStageTicketsTable(), 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 //2.2.0
31 => new \v220\AddIsAutocloseOptionToStatuses(), 31 => new \v220\AddIsAutocloseOptionToStatuses(),
32 => new \v220\AddClosableColumnToStatuses(), 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 //2.2.1
34 => new UpdateMigration('2.2.1', '2.2.0'), 34 => new LegacyUpdateMigration('2.2.1', '2.2.0'),
//2.3.0 //2.3.0
35 => new \v230\AddIconToServiceMessages(), 35 => new \v230\AddIconToServiceMessages(),
36 => new \v230\ConsolidateStatusColumns(), 36 => new \v230\ConsolidateStatusColumns(),
37 => new \v230\AddCoordinatesToTickets(), 37 => new \v230\AddCoordinatesToTickets(),
38 => new \v230\AddCategoryManager(), 38 => new \v230\AddCategoryManager(),
39 => new \v230\MovePermissionsToHeskPrivilegesColumn(), 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 //2.3.1
41 => new UpdateMigration('2.3.1', '2.3.0'), 42 => new LegacyUpdateMigration('2.3.1', '2.3.0'),
//2.3.2 //2.3.2
42 => new UpdateMigration('2.3.2', '2.3.1'), 43 => new LegacyUpdateMigration('2.3.2', '2.3.1'),
//2.4.0 //2.4.0
43 => new \v240\CreateQuickHelpSectionsTable(), 44 => new \v240\CreateQuickHelpSectionsTable(),
44 => new \v240\CreateNewStatusNameTable(), 45 => new \v240\CreateNewStatusNameTable(),
45 => new \v240\AddDownloadCountToAttachments(), 46 => new \v240\AddDownloadCountToAttachments(),
46 => new \v240\AddHtmlColumnToTickets(), 47 => new \v240\AddHtmlColumnToTickets(),
47 => new UpdateMigration('2.4.0', '2.3.2'), 48 => new LegacyUpdateMigration('2.4.0', '2.3.2'),
//2.4.1 //2.4.1
48 => new UpdateMigration('2.4.1', '2.4.0'), 49 => new LegacyUpdateMigration('2.4.1', '2.4.0'),
//2.4.2 //2.4.2
49 => new UpdateMigration('2.4.2', '2.4.1'), 50 => new LegacyUpdateMigration('2.4.2', '2.4.1'),
//2.5.0 //2.5.0
50 => new \v250\MigrateSettingsToDatabase(), 51 => new \v250\MigrateSettingsToDatabase(),
51 => new \v250\AddUserAgentAndScreenResToTickets(), 52 => new \v250\AddUserAgentAndScreenResToTickets(),
52 => new \v250\AddNavbarTitleUrl(), 53 => new \v250\AddNavbarTitleUrl(),
53 => new UpdateMigration('2.5.0', '2.4.2'), 54 => new LegacyUpdateMigration('2.5.0', '2.4.2'),
//2.5.1 //2.5.1
54 => new UpdateMigration('2.5.1', '2.5.0'), 55 => new LegacyUpdateMigration('2.5.1', '2.5.0'),
//2.5.2 //2.5.2
55 => new UpdateMigration('2.5.2', '2.5.1'), 56 => new LegacyUpdateMigration('2.5.2', '2.5.1'),
//2.5.3 //2.5.3
56 => new UpdateMigration('2.5.3', '2.5.2'), 57 => new LegacyUpdateMigration('2.5.3', '2.5.2'),
//2.5.4 //2.5.4
57 => new UpdateMigration('2.5.4', '2.5.3'), 58 => new LegacyUpdateMigration('2.5.4', '2.5.3'),
//2.5.5 //2.5.5
58 => new UpdateMigration('2.5.5', '2.5.4'), 59 => new LegacyUpdateMigration('2.5.5', '2.5.4'),
//2.6.0 //2.6.0
59 => new \v260\AddApiTables(), 60 => new \v260\AddApiTables(),
60 => new \v260\AddLoggingTable(), 61 => new \v260\AddLoggingTable(),
61 => new \v260\AddTempAttachmentTable(), 62 => new \v260\AddTempAttachmentTable(),
62 => new \v260\AddCalendarModule(), 63 => new \v260\AddCalendarModule(),
63 => new \v260\AddPrimaryKeyToSettings(), 64 => new \v260\AddPrimaryKeyToSettings(),
64 => new \v260\ConvertStatusPropertiesToInts(), 65 => new \v260\ConvertStatusPropertiesToInts(),
65 => new UpdateMigration('2.6.0', '2.5.5'), 66 => new LegacyUpdateMigration('2.6.0', '2.5.5'),
//2.6.1 //2.6.1
66 => new UpdateMigration('2.6.1', '2.6.0'), 67 => new LegacyUpdateMigration('2.6.1', '2.6.0'),
//2.6.2 //2.6.2
67 => new \v262\AddMissingColumnsToStageTickets(), 68 => new \v262\AddMissingColumnsToStageTickets(),
68 => new UpdateMigration('2.6.2', '2.6.1'), 69 => new LegacyUpdateMigration('2.6.2', '2.6.1'),
//2.6.3 //2.6.3
69 => new UpdateMigration('2.6.3', '2.6.2'), 70 => new LegacyUpdateMigration('2.6.3', '2.6.2'),
//2.6.4 //2.6.4
70 => new UpdateMigration('2.6.4', '2.6.3'), 71 => new LegacyUpdateMigration('2.6.4', '2.6.3'),
//3.0.0 //3.0.0
71 => new \v300\MigrateHeskCustomStatuses(), 72 => new \v300\MigrateHeskCustomStatuses(),
72 => new \v300\MigrateAutorefreshOption(), 73 => new \v300\MigrateAutorefreshOption(),
73 => new \v300\AddColorSchemeSetting(), 74 => new \v300\AddColorSchemeSetting(),
74 => new UpdateMigration('3.0.0', '2.6.4'), 75 => new LegacyUpdateMigration('3.0.0', '2.6.4'),
//3.0.1 //3.0.1
75 => new UpdateMigration('3.0.1', '3.0.0'), 76 => new LegacyUpdateMigration('3.0.1', '3.0.0'),
//3.0.2 //3.0.2
76 => new \v302\AddMissingCustomFields(), 77 => new \v302\AddMissingCustomFields(),
77 => new UpdateMigration('3.0.2', '3.0.1'), 78 => new LegacyUpdateMigration('3.0.2', '3.0.1'),
//3.0.3 - 3.0.7 //3.0.3 - 3.0.7
78 => new UpdateMigration('3.0.3', '3.0.2'), 79 => new LegacyUpdateMigration('3.0.3', '3.0.2'),
79 => new UpdateMigration('3.0.4', '3.0.3'), 80 => new LegacyUpdateMigration('3.0.4', '3.0.3'),
80 => new UpdateMigration('3.0.5', '3.0.4'), 81 => new LegacyUpdateMigration('3.0.5', '3.0.4'),
81 => new UpdateMigration('3.0.6', '3.0.5'), 82 => new LegacyUpdateMigration('3.0.6', '3.0.5'),
82 => new UpdateMigration('3.0.7', '3.0.6'), 83 => new LegacyUpdateMigration('3.0.7', '3.0.6'),
//3.1.0 //3.1.0
83 => new \v310\AddStackTraceToLogs(), 84 => new \v310\AddStackTraceToLogs(),
84 => new \v310\AddCustomNavElements(), 85 => new \v310\AddCustomNavElements(),
85 => new \v310\AddMoreColorOptionsToCategories(), 86 => new \v310\AddMoreColorOptionsToCategories(),
86 => new \v310\AddNewLoginSettings(), 87 => new \v310\AddNewLoginSettings(),
87 => new \v310\AddApiUrlRewriteSetting(), 88 => new \v310\AddApiUrlRewriteSetting(),
88 => new \v310\ConvertPresetToIndividualColors(), 89 => new \v310\ConvertPresetToIndividualColors(),
89 => new UpdateMigration('3.1.0', '3.0.7'), 90 => new LegacyUpdateMigration('3.1.0', '3.0.7'),
//3.1.1 //3.1.1
90 => new UpdateMigration('3.1.1', '3.1.0'), 91 => new LegacyUpdateMigration('3.1.1', '3.1.0'),
//3.2.0 //3.2.0
91 => new \v320\AddDescriptionToCategoriesAndCustomFields(), 92 => new \v320\AddDescriptionToCategoriesAndCustomFields(),
92 => new \v320\AddAuditTrail(), 93 => new \v320\AddAuditTrail(),
94 => new \v320\AddMigrationSetting(),
95 => new UpdateMigration('3.2.0', '3.1.1', 95),
); );
} }

@ -46,8 +46,5 @@ class MigrateIpAndEmailBans extends \AbstractMigration {
while ($row = hesk_dbFetchAssoc($ips)) { 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("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`");
} }
} }

@ -19,6 +19,7 @@ class CreatePermissionTemplates extends \AbstractMigration {
} }
function down($hesk_settings) { 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`");
} }
} }

@ -14,7 +14,7 @@ class ConvertPresetToIndividualColors extends \AbstractMigration {
$theme = $theme_preset_row['Value']; $theme = $theme_preset_row['Value'];
} }
$light_theme = preg_match('/.*-light/g', $theme); $light_theme = preg_match_all('/.*-light/', $theme);
$navbar = array( $navbar = array(
'background' => '', 'background' => '',
'text' => '#fff', 'text' => '#fff',

@ -0,0 +1,16 @@
<?php
namespace v320;
class AddMigrationSetting extends \AbstractMigration {
function up($hesk_settings) {
$this->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'");
}
}
Loading…
Cancel
Save