From 311697693fff05f77cffa5c5d8fb52688613c04a Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 30 Oct 2017 13:02:36 -0400 Subject: [PATCH] Splitting up migrations.... partway done --- install/index.php | 12 +- .../Statuses/AddIntColumnUpDropTableDown.php | 16 +++ .../Pre140/Statuses/CreateStatusesTable.php | 28 +++++ .../Pre140/Statuses/DropOldStatusColumn.php | 21 ++++ .../Pre140/Statuses/InsertStatusRecords.php | 32 +++++ .../Statuses/MoveStatusesToNewColumn.php | 20 +++ .../Pre140/Statuses/RenameTempColumn.php | 15 +++ .../migrations/Pre140/StatusesMigration.php | 72 ----------- install/migrations/core.php | 115 +++++++++++------- .../AddEditInfoToNotes/AddEditDateColumn.php | 14 +++ .../AddNumberOfEditsColumn.php} | 6 +- .../migrations/v200/MigrateIpAndEmailBans.php | 50 -------- .../DropOldEmailBansTable.php | 17 +++ .../DropOldIpBansTable.php | 18 +++ .../MigrateIpAndEmailBans/InsertEmailBans.php | 21 ++++ .../MigrateIpAndEmailBans/InsertIpBans.php | 25 ++++ .../RemoveEditInfoFromNotes/DropEditDate.php | 14 +++ .../DropNumberOfEditsColumn.php} | 6 +- .../ChangeDtColumnType.php | 14 +++ .../FixStageTicketsTable.php | 3 +- .../AddNewColumn.php} | 5 +- .../SetDefaultValue.php | 15 +++ .../AddNewColumn.php} | 5 +- .../SetDefaultValue.php | 14 +++ .../v230/AddCoordinatesToTickets.php | 21 ---- .../AddLatitudeToStageTickets.php | 15 +++ .../AddLatitudeToTickets.php | 15 +++ .../AddLongitudeToStageTickets.php | 15 +++ .../AddLongitudeToTickets.php | 15 +++ .../v230/ConsolidateStatusColumns.php | 21 ---- .../ConsolidateStatusColumns/AddKeyColumn.php | 15 +++ .../DropShortNameColumn.php | 15 +++ .../DropTicketViewContentKeyColumn.php | 15 +++ .../SetNewKeyColumnValue.php | 15 +++ .../v230/CreatePermissionTemplates.php | 25 ---- .../AddPermissionTemplateColumn.php | 15 +++ .../CreatePermissionTemplatesTable.php | 18 +++ .../InsertAdminPermissionTemplate.php | 15 +++ .../InsertStaffPermissionTemplate.php | 15 +++ .../UpdateAdminUsersTemplate.php | 14 +++ .../MovePermissionsToHeskPrivilegesColumn.php | 53 -------- .../CopyCanChangeNotificationSettings.php | 30 +++++ .../CopyCanManSettings.php | 31 +++++ ...ropCanChangeNotificationSettingsColumn.php | 15 +++ .../DropCanManSettingsColumn.php | 15 +++ 45 files changed, 658 insertions(+), 308 deletions(-) create mode 100644 install/migrations/Pre140/Statuses/AddIntColumnUpDropTableDown.php create mode 100644 install/migrations/Pre140/Statuses/CreateStatusesTable.php create mode 100644 install/migrations/Pre140/Statuses/DropOldStatusColumn.php create mode 100644 install/migrations/Pre140/Statuses/InsertStatusRecords.php create mode 100644 install/migrations/Pre140/Statuses/MoveStatusesToNewColumn.php create mode 100644 install/migrations/Pre140/Statuses/RenameTempColumn.php delete mode 100644 install/migrations/Pre140/StatusesMigration.php create mode 100644 install/migrations/v160/AddEditInfoToNotes/AddEditDateColumn.php rename install/migrations/v160/{AddEditInfoToNotes.php => AddEditInfoToNotes/AddNumberOfEditsColumn.php} (53%) delete mode 100644 install/migrations/v200/MigrateIpAndEmailBans.php create mode 100644 install/migrations/v200/MigrateIpAndEmailBans/DropOldEmailBansTable.php create mode 100644 install/migrations/v200/MigrateIpAndEmailBans/DropOldIpBansTable.php create mode 100644 install/migrations/v200/MigrateIpAndEmailBans/InsertEmailBans.php create mode 100644 install/migrations/v200/MigrateIpAndEmailBans/InsertIpBans.php create mode 100644 install/migrations/v200/RemoveEditInfoFromNotes/DropEditDate.php rename install/migrations/v200/{RemoveEditInfoFromNotes.php => RemoveEditInfoFromNotes/DropNumberOfEditsColumn.php} (52%) create mode 100644 install/migrations/v211/FixStageTicketsTable/ChangeDtColumnType.php rename install/migrations/v211/{ => FixStageTicketsTable}/FixStageTicketsTable.php (89%) rename install/migrations/v220/{AddClosableColumnToStatuses.php => AddClosableColumnToStatuses/AddNewColumn.php} (64%) create mode 100644 install/migrations/v220/AddClosableColumnToStatuses/SetDefaultValue.php rename install/migrations/v220/{AddIsAutocloseOptionToStatuses.php => AddIsAutocloseOptionToStatuses/AddNewColumn.php} (61%) create mode 100644 install/migrations/v220/AddIsAutocloseOptionToStatuses/SetDefaultValue.php delete mode 100644 install/migrations/v230/AddCoordinatesToTickets.php create mode 100644 install/migrations/v230/AddCoordinatesToTickets/AddLatitudeToStageTickets.php create mode 100644 install/migrations/v230/AddCoordinatesToTickets/AddLatitudeToTickets.php create mode 100644 install/migrations/v230/AddCoordinatesToTickets/AddLongitudeToStageTickets.php create mode 100644 install/migrations/v230/AddCoordinatesToTickets/AddLongitudeToTickets.php delete mode 100644 install/migrations/v230/ConsolidateStatusColumns.php create mode 100644 install/migrations/v230/ConsolidateStatusColumns/AddKeyColumn.php create mode 100644 install/migrations/v230/ConsolidateStatusColumns/DropShortNameColumn.php create mode 100644 install/migrations/v230/ConsolidateStatusColumns/DropTicketViewContentKeyColumn.php create mode 100644 install/migrations/v230/ConsolidateStatusColumns/SetNewKeyColumnValue.php delete mode 100644 install/migrations/v230/CreatePermissionTemplates.php create mode 100644 install/migrations/v230/CreatePermissionTemplates/AddPermissionTemplateColumn.php create mode 100644 install/migrations/v230/CreatePermissionTemplates/CreatePermissionTemplatesTable.php create mode 100644 install/migrations/v230/CreatePermissionTemplates/InsertAdminPermissionTemplate.php create mode 100644 install/migrations/v230/CreatePermissionTemplates/InsertStaffPermissionTemplate.php create mode 100644 install/migrations/v230/CreatePermissionTemplates/UpdateAdminUsersTemplate.php delete mode 100644 install/migrations/v230/MovePermissionsToHeskPrivilegesColumn.php create mode 100644 install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/CopyCanChangeNotificationSettings.php create mode 100644 install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/CopyCanManSettings.php create mode 100644 install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/DropCanChangeNotificationSettingsColumn.php create mode 100644 install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/DropCanManSettingsColumn.php diff --git a/install/index.php b/install/index.php index 1d826028..b7abdc31 100644 --- a/install/index.php +++ b/install/index.php @@ -28,8 +28,8 @@ if (hesk_dbNumRows($tableSql) > 0) { $migration_map = array( // Pre-1.4.0 to 1.5.0 did not have a settings table - '1.6.0' => 16, '1.6.1' => 17, '1.7.0' => 21, '2.0.0' => 27, '2.0.1' => 28, '2.1.0' => 29, '2.1.1' => 31, - '2.2.0' => 34, '2.2.1' => 35, '2.3.0' => 41, '2.3.1' => 42, '2.3.2' => 43, '2.4.0' => 48, '2.4.1' => 49, + '1.6.0' => 22, '1.6.1' => 23, '1.7.0' => 27, '2.0.0' => 37, '2.0.1' => 38, '2.1.0' => 39, '2.1.1' => 42, + '2.2.0' => 47, '2.2.1' => 48, '2.3.0' => 68, '2.3.1' => 69, '2.3.2' => 70, /*TODO */ '2.4.0' => 48, '2.4.1' => 49, '2.4.2' => 50, '2.5.0' => 54, '2.5.1' => 55, '2.5.2' => 56, '2.5.3' => 57, '2.5.4' => 58, '2.5.5' => 59, '2.6.0' => 66, '2.6.1' => 67, '2.6.2' => 69, '2.6.3' => 70, '2.6.4' => 71, '3.0.0' => 75, '3.0.1' => 76, '3.0.2' => 78, '3.0.3' => 79, '3.0.4' => 80, '3.0.5' => 81, '3.0.6' => 82, '3.0.7' => 83, '3.1.0' => 90, @@ -41,13 +41,13 @@ if (hesk_dbNumRows($tableSql) > 0) { // migration # => sql for checking $versionChecks = array( // 1.5.0 -> users.active - 9 => "SHOW COLUMNS FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` LIKE 'active'", + 14 => "SHOW COLUMNS FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` LIKE 'active'", // 1.4.1 -> denied_emails - 6 => "SHOW TABLES LIKE '" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails'", + 11 => "SHOW TABLES LIKE '" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails'", // 1.4.0 -> denied ips - 4 => "SHOW TABLES LIKE '" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips'", + 9 => "SHOW TABLES LIKE '" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips'", // Pre-1.4.0 but still something -> statuses - 2 => "SHOW TABLES LIKE '" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses'" + 7 => "SHOW TABLES LIKE '" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses'" ); foreach ($versionChecks as $migrationNumber => $sql) { diff --git a/install/migrations/Pre140/Statuses/AddIntColumnUpDropTableDown.php b/install/migrations/Pre140/Statuses/AddIntColumnUpDropTableDown.php new file mode 100644 index 00000000..b6bf841e --- /dev/null +++ b/install/migrations/Pre140/Statuses/AddIntColumnUpDropTableDown.php @@ -0,0 +1,16 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `status_int` INT NOT NULL DEFAULT 0 AFTER `status`;"); + } + + function down($hesk_settings) { + $this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses`"); + } +} \ No newline at end of file diff --git a/install/migrations/Pre140/Statuses/CreateStatusesTable.php b/install/migrations/Pre140/Statuses/CreateStatusesTable.php new file mode 100644 index 00000000..0d7dbef7 --- /dev/null +++ b/install/migrations/Pre140/Statuses/CreateStatusesTable.php @@ -0,0 +1,28 @@ +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`))"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `status_int` INT NOT NULL AFTER `status`;"); + } +} \ No newline at end of file diff --git a/install/migrations/Pre140/Statuses/DropOldStatusColumn.php b/install/migrations/Pre140/Statuses/DropOldStatusColumn.php new file mode 100644 index 00000000..31c91bd7 --- /dev/null +++ b/install/migrations/Pre140/Statuses/DropOldStatusColumn.php @@ -0,0 +1,21 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `status`"); + } + + function down($hesk_settings) { + $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']); + } + } +} \ No newline at end of file diff --git a/install/migrations/Pre140/Statuses/InsertStatusRecords.php b/install/migrations/Pre140/Statuses/InsertStatusRecords.php new file mode 100644 index 00000000..be943f32 --- /dev/null +++ b/install/migrations/Pre140/Statuses/InsertStatusRecords.php @@ -0,0 +1,32 @@ +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);"); + } + + function down($hesk_settings) { + } +} \ No newline at end of file diff --git a/install/migrations/Pre140/Statuses/MoveStatusesToNewColumn.php b/install/migrations/Pre140/Statuses/MoveStatusesToNewColumn.php new file mode 100644 index 00000000..ce64aced --- /dev/null +++ b/install/migrations/Pre140/Statuses/MoveStatusesToNewColumn.php @@ -0,0 +1,20 @@ +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']); + } + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` CHANGE COLUMN `status_int` `status` INT NOT NULL"); + } +} \ No newline at end of file diff --git a/install/migrations/Pre140/Statuses/RenameTempColumn.php b/install/migrations/Pre140/Statuses/RenameTempColumn.php new file mode 100644 index 00000000..d1eec50f --- /dev/null +++ b/install/migrations/Pre140/Statuses/RenameTempColumn.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` CHANGE COLUMN `status_int` `status` INT NOT NULL"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `status`"); + } +} \ No newline at end of file diff --git a/install/migrations/Pre140/StatusesMigration.php b/install/migrations/Pre140/StatusesMigration.php deleted file mode 100644 index cad7d525..00000000 --- a/install/migrations/Pre140/StatusesMigration.php +++ /dev/null @@ -1,72 +0,0 @@ -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($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 8f9fa300..5e98019d 100644 --- a/install/migrations/core.php +++ b/install/migrations/core.php @@ -18,66 +18,93 @@ spl_autoload_register(function ($class) { function getAllMigrations() { return array( - 1 => new \Pre140\StatusesMigration(), + 1 => new \Pre140\Statuses\AddIntColumnUpDropTableDown(), + 2 => new \Pre140\Statuses\MoveStatusesToNewColumn(), + 3 => new \Pre140\Statuses\DropOldStatusColumn(), + 4 => new \Pre140\Statuses\RenameTempColumn(), + 5 => new \Pre140\Statuses\CreateStatusesTable(), + 6 => new \Pre140\Statuses\InsertStatusRecords(), //1.4.0 - 2 => new \v140\AddAutorefreshColumn(), - 3 => new \v140\AddDeniedIpsTable(), + 7 => new \v140\AddAutorefreshColumn(), + 8 => new \v140\AddDeniedIpsTable(), //1.4.1 - 4 => new \v141\AddDeniedEmailsTable(), - 5 => new \v141\AddTicketParentColumn(), + 9 => new \v141\AddDeniedEmailsTable(), + 10 => new \v141\AddTicketParentColumn(), //1.5.0 - 6 => new \v150\AddActiveColumnToUser(), - 7 => new \v150\AddCanManSettingsPermissionToUser(), - 8 => new \v150\AddDefaultNotifyCustomerEmailPreference(), + 11 => new \v150\AddActiveColumnToUser(), + 12 => new \v150\AddCanManSettingsPermissionToUser(), + 13 => 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(), + 14 => new \v160\AddNotifyNoteUnassignedProperty(), + 15 => new \v160\AddCanChangeNotificationSettingsPermission(), + 16 => new \v160\AddEditInfoToNotes\AddEditDateColumn(), + 17 => new \v160\AddEditInfoToNotes\AddNumberOfEditsColumn(), + 18 => new \v160\AddNoteIdToAttachments(), + 19 => new \v160\ModifyTicketIdOnAttachments(), + 20 => new \v160\CreateSettingsTable(), + 21 => new \v160\InsertVersionRecord(), //1.6.1 - 16 => new LegacyUpdateMigration('1.6.1', '1.6.0'), + 22 => 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 LegacyUpdateMigration('1.7.0', '1.6.1'), + 23 => new \v170\CreateVerifiedEmailsTable(), + 24 => new \v170\CreatePendingVerificationEmailsTable(), + 25 => new \v170\CreateStageTicketsTable(), + 26 => 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 LegacyUpdateMigration('2.0.0', '1.7.0'), + 27 => new \v200\RemoveNoteIdFromAttachments(), + 28 => new \v200\RemoveEditInfoFromNotes\DropEditDate(), + 29 => new \v200\RemoveEditInfoFromNotes\DropNumberOfEditsColumn(), + 30 => new \v200\RemoveDefaultNotifyCustomerEmailPreference(), + 31 => new \v200\AddMissingKeyToTickets(), + 32 => new \v200\MigrateIpAndEmailBans\InsertIpBans(), + 33 => new \v200\MigrateIpAndEmailBans\InsertEmailBans(), + 34 => new \v200\MigrateIpAndEmailBans\DropOldEmailBansTable(), + 35 => new \v200\MigrateIpAndEmailBans\DropOldIpBansTable(), + 36 => new LegacyUpdateMigration('2.0.0', '1.7.0'), //2.0.1 - 27 => new LegacyUpdateMigration('2.0.1', '2.0.0'), + 37 => new LegacyUpdateMigration('2.0.1', '2.0.0'), //2.1.0 - 28 => new LegacyUpdateMigration('2.1.0', '2.0.1'), + 38 => new LegacyUpdateMigration('2.1.0', '2.0.1'), //2.1.1 - 29 => new \v211\FixStageTicketsTable(), - 30 => new LegacyUpdateMigration('2.1.1', '2.1.0'), + 39 => new \v211\FixStageTicketsTable\ChangeDtColumnType(), + 40 => new \v211\FixStageTicketsTable\FixStageTicketsTable(), + 41 => new LegacyUpdateMigration('2.1.1', '2.1.0'), //2.2.0 - 31 => new \v220\AddIsAutocloseOptionToStatuses(), - 32 => new \v220\AddClosableColumnToStatuses(), - 33 => new LegacyUpdateMigration('2.2.0', '2.1.1'), + 42 => new \v220\AddIsAutocloseOptionToStatuses\AddNewColumn(), + 43 => new \v220\AddIsAutocloseOptionToStatuses\SetDefaultValue(), + 44 => new \v220\AddClosableColumnToStatuses\AddNewColumn(), + 45 => new \v220\AddClosableColumnToStatuses\SetDefaultValue(), + 46 => new LegacyUpdateMigration('2.2.0', '2.1.1'), //2.2.1 - 34 => new LegacyUpdateMigration('2.2.1', '2.2.0'), + 47 => 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 \v230\CreatePermissionTemplates(), - 41 => new LegacyUpdateMigration('2.3.0', '2.2.1'), + 48 => new \v230\AddIconToServiceMessages(), + 49 => new \v230\ConsolidateStatusColumns\AddKeyColumn(), + 50 => new \v230\ConsolidateStatusColumns\SetNewKeyColumnValue(), + 51 => new \v230\ConsolidateStatusColumns\DropShortNameColumn(), + 52 => new \v230\ConsolidateStatusColumns\DropTicketViewContentKeyColumn(), + 53 => new \v230\AddCoordinatesToTickets\AddLatitudeToTickets(), + 54 => new \v230\AddCoordinatesToTickets\AddLongitudeToTickets(), + 55 => new \v230\AddCoordinatesToTickets\AddLatitudeToStageTickets(), + 56 => new \v230\AddCoordinatesToTickets\AddLongitudeToStageTickets(), + 57 => new \v230\AddCategoryManager(), + 58 => new \v230\CopyCanManSettings(), + 59 => new \v230\CopyCanChangeNotificationSettings(), + 60 => new \v230\DropCanManSettingsColumn(), + 61 => new \v230\DropCanChangeNotificationSettingsColumn(), + 62 => new \v230\CreatePermissionTemplates\AddPermissionTemplateColumn(), + 63 => new \v230\CreatePermissionTemplates\CreatePermissionTemplatesTable(), + 64 => new \v230\CreatePermissionTemplates\InsertAdminPermissionTemplate(), + 65 => new \v230\CreatePermissionTemplates\InsertStaffPermissionTemplate(), + 66 => new \v230\CreatePermissionTemplates\UpdateAdminUsersTemplate(), + 67 => new LegacyUpdateMigration('2.3.0', '2.2.1'), //2.3.1 - 42 => new LegacyUpdateMigration('2.3.1', '2.3.0'), + 68 => new LegacyUpdateMigration('2.3.1', '2.3.0'), //2.3.2 - 43 => new LegacyUpdateMigration('2.3.2', '2.3.1'), + 69 => new LegacyUpdateMigration('2.3.2', '2.3.1'), //2.4.0 - 44 => new \v240\CreateQuickHelpSectionsTable(), + 70 => new \v240\CreateQuickHelpSectionsTable(), + // TODO 45 => new \v240\CreateNewStatusNameTable(), 46 => new \v240\AddDownloadCountToAttachments(), 47 => new \v240\AddHtmlColumnToTickets(), diff --git a/install/migrations/v160/AddEditInfoToNotes/AddEditDateColumn.php b/install/migrations/v160/AddEditInfoToNotes/AddEditDateColumn.php new file mode 100644 index 00000000..d802396a --- /dev/null +++ b/install/migrations/v160/AddEditInfoToNotes/AddEditDateColumn.php @@ -0,0 +1,14 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` ADD COLUMN `edit_date` DATETIME NULL"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` DROP COLUMN `edit_date`"); + } +} \ No newline at end of file diff --git a/install/migrations/v160/AddEditInfoToNotes.php b/install/migrations/v160/AddEditInfoToNotes/AddNumberOfEditsColumn.php similarity index 53% rename from install/migrations/v160/AddEditInfoToNotes.php rename to install/migrations/v160/AddEditInfoToNotes/AddNumberOfEditsColumn.php index 0fc4aa7e..865670dd 100644 --- a/install/migrations/v160/AddEditInfoToNotes.php +++ b/install/migrations/v160/AddEditInfoToNotes/AddNumberOfEditsColumn.php @@ -1,17 +1,15 @@ 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/v200/MigrateIpAndEmailBans.php b/install/migrations/v200/MigrateIpAndEmailBans.php deleted file mode 100644 index 3174fe83..00000000 --- a/install/migrations/v200/MigrateIpAndEmailBans.php +++ /dev/null @@ -1,50 +0,0 @@ -executeQuery("SELECT `Email` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails`"); - while ($row = hesk_dbFetchAssoc($emailBanRS)) { - $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_emails` (`email`, `banned_by`, `dt`) - VALUES ('" . hesk_dbEscape($row['Email']) . "', 1, NOW())"); - } - - // Insert the IP bans - $ipBanRS = $this->executeQuery("SELECT `RangeStart`, `RangeEnd` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips`"); - while ($row = hesk_dbFetchAssoc($ipBanRS)) { - $ipFrom = long2ip($row['RangeStart']); - $ipTo = long2ip($row['RangeEnd']); - $ipDisplay = $ipFrom == $ipTo ? $ipFrom : $ipFrom . ' - ' . $ipTo; - $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_ips` (`ip_from`, `ip_to`, `ip_display`, `banned_by`, `dt`) - VALUES (" . $row['RangeStart'] . ", " . $row['RangeEnd'] . ", '" . $ipDisplay . "', 1, NOW())"); - } - // Migration Complete. Drop Tables. - $this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips`"); - $this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails`"); - } - - function down($hesk_settings) { - $this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips` ( - `ID` INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - `RangeStart` VARCHAR(100) NOT NULL, - `RangeEnd` VARCHAR(100) NOT NULL)"); - - $this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails` ( - ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - Email VARCHAR(100) NOT NULL);"); - - $emails = $this->executeQuery("SELECT `email` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_emails`"); - while ($row = hesk_dbFetchAssoc($emails)) { - $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails` (Email) VALUES ('" . hesk_dbEscape($row['email']) . "')"); - } - - $ips = $this->executeQuery("SELECT `ip_from`, `ip_to` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_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'] . ")"); - } - } -} \ No newline at end of file diff --git a/install/migrations/v200/MigrateIpAndEmailBans/DropOldEmailBansTable.php b/install/migrations/v200/MigrateIpAndEmailBans/DropOldEmailBansTable.php new file mode 100644 index 00000000..b1b43be9 --- /dev/null +++ b/install/migrations/v200/MigrateIpAndEmailBans/DropOldEmailBansTable.php @@ -0,0 +1,17 @@ +executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails`"); + } + + function down($hesk_settings) { + $this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails` ( + ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + Email VARCHAR(100) NOT NULL);"); + } +} \ No newline at end of file diff --git a/install/migrations/v200/MigrateIpAndEmailBans/DropOldIpBansTable.php b/install/migrations/v200/MigrateIpAndEmailBans/DropOldIpBansTable.php new file mode 100644 index 00000000..fa4b3ebf --- /dev/null +++ b/install/migrations/v200/MigrateIpAndEmailBans/DropOldIpBansTable.php @@ -0,0 +1,18 @@ +executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips`"); + } + + function down($hesk_settings) { + $this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips` ( + `ID` INT NOT NULL PRIMARY KEY AUTO_INCREMENT, + `RangeStart` VARCHAR(100) NOT NULL, + `RangeEnd` VARCHAR(100) NOT NULL)"); + } +} \ No newline at end of file diff --git a/install/migrations/v200/MigrateIpAndEmailBans/InsertEmailBans.php b/install/migrations/v200/MigrateIpAndEmailBans/InsertEmailBans.php new file mode 100644 index 00000000..e41840e7 --- /dev/null +++ b/install/migrations/v200/MigrateIpAndEmailBans/InsertEmailBans.php @@ -0,0 +1,21 @@ +executeQuery("SELECT `Email` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails`"); + while ($row = hesk_dbFetchAssoc($emailBanRS)) { + $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_emails` (`email`, `banned_by`, `dt`) + VALUES ('" . hesk_dbEscape($row['Email']) . "', 1, NOW())"); + } + } + + function down($hesk_settings) { + $emails = $this->executeQuery("SELECT `email` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_emails`"); + while ($row = hesk_dbFetchAssoc($emails)) { + $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_emails` (Email) VALUES ('" . hesk_dbEscape($row['email']) . "')"); + } + } +} \ No newline at end of file diff --git a/install/migrations/v200/MigrateIpAndEmailBans/InsertIpBans.php b/install/migrations/v200/MigrateIpAndEmailBans/InsertIpBans.php new file mode 100644 index 00000000..66d76b8c --- /dev/null +++ b/install/migrations/v200/MigrateIpAndEmailBans/InsertIpBans.php @@ -0,0 +1,25 @@ +executeQuery("SELECT `RangeStart`, `RangeEnd` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "denied_ips`"); + while ($row = hesk_dbFetchAssoc($ipBanRS)) { + $ipFrom = long2ip($row['RangeStart']); + $ipTo = long2ip($row['RangeEnd']); + $ipDisplay = $ipFrom == $ipTo ? $ipFrom : $ipFrom . ' - ' . $ipTo; + $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_ips` (`ip_from`, `ip_to`, `ip_display`, `banned_by`, `dt`) + VALUES (" . $row['RangeStart'] . ", " . $row['RangeEnd'] . ", '" . $ipDisplay . "', 1, NOW())"); + } + } + + function down($hesk_settings) { + $ips = $this->executeQuery("SELECT `ip_from`, `ip_to` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "banned_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'] . ")"); + } + } +} \ No newline at end of file diff --git a/install/migrations/v200/RemoveEditInfoFromNotes/DropEditDate.php b/install/migrations/v200/RemoveEditInfoFromNotes/DropEditDate.php new file mode 100644 index 00000000..6ceef94d --- /dev/null +++ b/install/migrations/v200/RemoveEditInfoFromNotes/DropEditDate.php @@ -0,0 +1,14 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` DROP COLUMN `edit_date`"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "notes` ADD COLUMN `edit_date` DATETIME NULL"); + } +} \ No newline at end of file diff --git a/install/migrations/v200/RemoveEditInfoFromNotes.php b/install/migrations/v200/RemoveEditInfoFromNotes/DropNumberOfEditsColumn.php similarity index 52% rename from install/migrations/v200/RemoveEditInfoFromNotes.php rename to install/migrations/v200/RemoveEditInfoFromNotes/DropNumberOfEditsColumn.php index 2793fb14..198a5718 100644 --- a/install/migrations/v200/RemoveEditInfoFromNotes.php +++ b/install/migrations/v200/RemoveEditInfoFromNotes/DropNumberOfEditsColumn.php @@ -1,17 +1,15 @@ 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/v211/FixStageTicketsTable/ChangeDtColumnType.php b/install/migrations/v211/FixStageTicketsTable/ChangeDtColumnType.php new file mode 100644 index 00000000..9f03915f --- /dev/null +++ b/install/migrations/v211/FixStageTicketsTable/ChangeDtColumnType.php @@ -0,0 +1,14 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` CHANGE `dt` `dt` TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00'"); + } + + function down($hesk_settings) { + // NOOP + } +} \ No newline at end of file diff --git a/install/migrations/v211/FixStageTicketsTable.php b/install/migrations/v211/FixStageTicketsTable/FixStageTicketsTable.php similarity index 89% rename from install/migrations/v211/FixStageTicketsTable.php rename to install/migrations/v211/FixStageTicketsTable/FixStageTicketsTable.php index 1019fd64..e581c4eb 100644 --- a/install/migrations/v211/FixStageTicketsTable.php +++ b/install/migrations/v211/FixStageTicketsTable/FixStageTicketsTable.php @@ -1,11 +1,10 @@ executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` CHANGE `dt` `dt` TIMESTAMP NOT NULL DEFAULT '2000-01-01 00:00:00'"); $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` CHANGE `email` `email` VARCHAR( 1000 ) NOT NULL DEFAULT '', CHANGE `ip` `ip` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', diff --git a/install/migrations/v220/AddClosableColumnToStatuses.php b/install/migrations/v220/AddClosableColumnToStatuses/AddNewColumn.php similarity index 64% rename from install/migrations/v220/AddClosableColumnToStatuses.php rename to install/migrations/v220/AddClosableColumnToStatuses/AddNewColumn.php index b60210ae..4fa70f90 100644 --- a/install/migrations/v220/AddClosableColumnToStatuses.php +++ b/install/migrations/v220/AddClosableColumnToStatuses/AddNewColumn.php @@ -1,13 +1,12 @@ executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `Closable` VARCHAR(10) NOT NULL"); - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `Closable` = 'yes'"); } function down($hesk_settings) { diff --git a/install/migrations/v220/AddClosableColumnToStatuses/SetDefaultValue.php b/install/migrations/v220/AddClosableColumnToStatuses/SetDefaultValue.php new file mode 100644 index 00000000..30cf5300 --- /dev/null +++ b/install/migrations/v220/AddClosableColumnToStatuses/SetDefaultValue.php @@ -0,0 +1,15 @@ +executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `Closable` = 'yes'"); + } + + function down($hesk_settings) { + // no-op + } +} \ No newline at end of file diff --git a/install/migrations/v220/AddIsAutocloseOptionToStatuses.php b/install/migrations/v220/AddIsAutocloseOptionToStatuses/AddNewColumn.php similarity index 61% rename from install/migrations/v220/AddIsAutocloseOptionToStatuses.php rename to install/migrations/v220/AddIsAutocloseOptionToStatuses/AddNewColumn.php index f9c1f167..4a0ae9c3 100644 --- a/install/migrations/v220/AddIsAutocloseOptionToStatuses.php +++ b/install/migrations/v220/AddIsAutocloseOptionToStatuses/AddNewColumn.php @@ -1,12 +1,11 @@ executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `IsAutocloseOption` INT NOT NULL DEFAULT 0"); - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `IsAutocloseOption` = 1 WHERE `IsStaffClosedOption` = 1"); } function down($hesk_settings) { diff --git a/install/migrations/v220/AddIsAutocloseOptionToStatuses/SetDefaultValue.php b/install/migrations/v220/AddIsAutocloseOptionToStatuses/SetDefaultValue.php new file mode 100644 index 00000000..62389aac --- /dev/null +++ b/install/migrations/v220/AddIsAutocloseOptionToStatuses/SetDefaultValue.php @@ -0,0 +1,14 @@ +executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `IsAutocloseOption` = 1 WHERE `IsStaffClosedOption` = 1"); + } + + function down($hesk_settings) { + // no-op + } +} \ No newline at end of file diff --git a/install/migrations/v230/AddCoordinatesToTickets.php b/install/migrations/v230/AddCoordinatesToTickets.php deleted file mode 100644 index cb9fae73..00000000 --- a/install/migrations/v230/AddCoordinatesToTickets.php +++ /dev/null @@ -1,21 +0,0 @@ -executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); - } - - function down($hesk_settings) { - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `latitude`"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `longitude`"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` DROP COLUMN `latitude`"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` DROP COLUMN `longitude`"); - } -} \ No newline at end of file diff --git a/install/migrations/v230/AddCoordinatesToTickets/AddLatitudeToStageTickets.php b/install/migrations/v230/AddCoordinatesToTickets/AddLatitudeToStageTickets.php new file mode 100644 index 00000000..5f5ae562 --- /dev/null +++ b/install/migrations/v230/AddCoordinatesToTickets/AddLatitudeToStageTickets.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` DROP COLUMN `latitude`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/AddCoordinatesToTickets/AddLatitudeToTickets.php b/install/migrations/v230/AddCoordinatesToTickets/AddLatitudeToTickets.php new file mode 100644 index 00000000..62c17e03 --- /dev/null +++ b/install/migrations/v230/AddCoordinatesToTickets/AddLatitudeToTickets.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `latitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `latitude`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/AddCoordinatesToTickets/AddLongitudeToStageTickets.php b/install/migrations/v230/AddCoordinatesToTickets/AddLongitudeToStageTickets.php new file mode 100644 index 00000000..e89c1b5b --- /dev/null +++ b/install/migrations/v230/AddCoordinatesToTickets/AddLongitudeToStageTickets.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets` DROP COLUMN `longitude`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/AddCoordinatesToTickets/AddLongitudeToTickets.php b/install/migrations/v230/AddCoordinatesToTickets/AddLongitudeToTickets.php new file mode 100644 index 00000000..7ccd743f --- /dev/null +++ b/install/migrations/v230/AddCoordinatesToTickets/AddLongitudeToTickets.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `longitude` VARCHAR(100) NOT NULL DEFAULT 'E-0'"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `longitude`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/ConsolidateStatusColumns.php b/install/migrations/v230/ConsolidateStatusColumns.php deleted file mode 100644 index 675d0e8d..00000000 --- a/install/migrations/v230/ConsolidateStatusColumns.php +++ /dev/null @@ -1,21 +0,0 @@ -executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `Key` TEXT"); - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `Key` = `ShortNameContentKey`"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `ShortNameContentKey`"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `TicketViewContentKey`"); - } - - function down($hesk_settings) { - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `TicketViewContentKey` TEXT"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `ShortNameContentKey` TEXT"); - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `TicketViewContentKey` = `Key`, `ShortNameContentKey` = `Key`"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `Key`"); - } -} \ No newline at end of file diff --git a/install/migrations/v230/ConsolidateStatusColumns/AddKeyColumn.php b/install/migrations/v230/ConsolidateStatusColumns/AddKeyColumn.php new file mode 100644 index 00000000..5d264114 --- /dev/null +++ b/install/migrations/v230/ConsolidateStatusColumns/AddKeyColumn.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `Key` TEXT"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `Key`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/ConsolidateStatusColumns/DropShortNameColumn.php b/install/migrations/v230/ConsolidateStatusColumns/DropShortNameColumn.php new file mode 100644 index 00000000..40fb00c2 --- /dev/null +++ b/install/migrations/v230/ConsolidateStatusColumns/DropShortNameColumn.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `ShortNameContentKey`"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `ShortNameContentKey` TEXT"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/ConsolidateStatusColumns/DropTicketViewContentKeyColumn.php b/install/migrations/v230/ConsolidateStatusColumns/DropTicketViewContentKeyColumn.php new file mode 100644 index 00000000..85353c04 --- /dev/null +++ b/install/migrations/v230/ConsolidateStatusColumns/DropTicketViewContentKeyColumn.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `TicketViewContentKey`"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ADD COLUMN `TicketViewContentKey` TEXT"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/ConsolidateStatusColumns/SetNewKeyColumnValue.php b/install/migrations/v230/ConsolidateStatusColumns/SetNewKeyColumnValue.php new file mode 100644 index 00000000..8c69d486 --- /dev/null +++ b/install/migrations/v230/ConsolidateStatusColumns/SetNewKeyColumnValue.php @@ -0,0 +1,15 @@ +executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `Key` = `ShortNameContentKey`"); + } + + function down($hesk_settings) { + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `TicketViewContentKey` = `Key`, `ShortNameContentKey` = `Key`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/CreatePermissionTemplates.php b/install/migrations/v230/CreatePermissionTemplates.php deleted file mode 100644 index fad3cff9..00000000 --- a/install/migrations/v230/CreatePermissionTemplates.php +++ /dev/null @@ -1,25 +0,0 @@ -executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `permission_template` INT"); - $this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `name` VARCHAR(255) NOT NULL, - `heskprivileges` VARCHAR(1000), - `categories` VARCHAR(500))"); - $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`name`, `heskprivileges`, `categories`) - VALUES ('Administrator', 'ALL', 'ALL')"); - $this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`name`, `heskprivileges`, `categories`) - VALUES ('Staff', 'can_view_tickets,can_reply_tickets,can_change_cat,can_assign_self,can_view_unassigned,can_view_online', '1')"); - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `permission_template` = 1 WHERE `isadmin` = '1'"); - } - - function down($hesk_settings) { - $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/v230/CreatePermissionTemplates/AddPermissionTemplateColumn.php b/install/migrations/v230/CreatePermissionTemplates/AddPermissionTemplateColumn.php new file mode 100644 index 00000000..4463e88f --- /dev/null +++ b/install/migrations/v230/CreatePermissionTemplates/AddPermissionTemplateColumn.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `permission_template` INT"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `permission_template`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/CreatePermissionTemplates/CreatePermissionTemplatesTable.php b/install/migrations/v230/CreatePermissionTemplates/CreatePermissionTemplatesTable.php new file mode 100644 index 00000000..e8b19aed --- /dev/null +++ b/install/migrations/v230/CreatePermissionTemplates/CreatePermissionTemplatesTable.php @@ -0,0 +1,18 @@ +executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `heskprivileges` VARCHAR(1000), + `categories` VARCHAR(500))"); + } + + function down($hesk_settings) { + $this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates`"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/CreatePermissionTemplates/InsertAdminPermissionTemplate.php b/install/migrations/v230/CreatePermissionTemplates/InsertAdminPermissionTemplate.php new file mode 100644 index 00000000..39a563c9 --- /dev/null +++ b/install/migrations/v230/CreatePermissionTemplates/InsertAdminPermissionTemplate.php @@ -0,0 +1,15 @@ +executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`name`, `heskprivileges`, `categories`) + VALUES ('Administrator', 'ALL', 'ALL')"); + } + + function down($hesk_settings) { + } +} \ No newline at end of file diff --git a/install/migrations/v230/CreatePermissionTemplates/InsertStaffPermissionTemplate.php b/install/migrations/v230/CreatePermissionTemplates/InsertStaffPermissionTemplate.php new file mode 100644 index 00000000..031ea394 --- /dev/null +++ b/install/migrations/v230/CreatePermissionTemplates/InsertStaffPermissionTemplate.php @@ -0,0 +1,15 @@ +executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`name`, `heskprivileges`, `categories`) + VALUES ('Staff', 'can_view_tickets,can_reply_tickets,can_change_cat,can_assign_self,can_view_unassigned,can_view_online', '1')"); + } + + function down($hesk_settings) { + } +} \ No newline at end of file diff --git a/install/migrations/v230/CreatePermissionTemplates/UpdateAdminUsersTemplate.php b/install/migrations/v230/CreatePermissionTemplates/UpdateAdminUsersTemplate.php new file mode 100644 index 00000000..60743f3e --- /dev/null +++ b/install/migrations/v230/CreatePermissionTemplates/UpdateAdminUsersTemplate.php @@ -0,0 +1,14 @@ +executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `permission_template` = 1 WHERE `isadmin` = '1'"); + } + + function down($hesk_settings) { + } +} \ No newline at end of file diff --git a/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn.php b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn.php deleted file mode 100644 index f4a5a5b4..00000000 --- a/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn.php +++ /dev/null @@ -1,53 +0,0 @@ -executeQuery("SELECT `id`, `heskprivileges` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `isadmin` = '0' - AND `can_manage_settings` = '1'"); - while ($row = hesk_dbFetchAssoc($res)) { - if ($row['heskprivileges'] != '') { - $currentPrivileges = explode(',', $row['heskprivileges']); - array_push($currentPrivileges, 'can_man_settings'); - $newPrivileges = implode(',', $currentPrivileges); - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = '" . hesk_dbEscape($newPrivileges) . "' - WHERE `id` = " . intval($row['id'])); - } else { - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = 'can_man_settings' - WHERE `id` = " . intval($row['id'])); - } - } - $res = $this->executeQuery("SELECT `id`, `heskprivileges` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `isadmin` = '0' - AND `can_change_notification_settings` = '1'"); - while ($row = hesk_dbFetchAssoc($res)) { - if ($row['heskprivileges'] != '') { - $currentPrivileges = explode(',', $row['heskprivileges']); - array_push($currentPrivileges, 'can_change_notification_settings'); - $newPrivileges = implode(',', $currentPrivileges); - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = '" . hesk_dbEscape($newPrivileges) . "' - WHERE `id` = " . intval($row['id'])); - } else { - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = 'can_change_notification_settings' - WHERE `id` = " . intval($row['id'])); - } - } - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `can_manage_settings`"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `can_change_notification_settings`"); - } - - function down($hesk_settings) { - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_change_notification_settings` ENUM('0', '1') NOT NULL DEFAULT '1'"); - $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_manage_settings` ENUM ('0', '1') NOT NULL DEFAULT '1'"); - - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` - SET `can_manage_settings` = '0' - WHERE `heskprivileges` NOT LIKE '%can_man_settings%'"); - $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` - SET `can_change_notification_settings` = '0' - WHERE `heskprivileges` NOT LIKE '%can_change_notification_settings%'"); - } -} \ No newline at end of file diff --git a/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/CopyCanChangeNotificationSettings.php b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/CopyCanChangeNotificationSettings.php new file mode 100644 index 00000000..fc340fed --- /dev/null +++ b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/CopyCanChangeNotificationSettings.php @@ -0,0 +1,30 @@ +executeQuery("SELECT `id`, `heskprivileges` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `isadmin` = '0' + AND `can_change_notification_settings` = '1'"); + while ($row = hesk_dbFetchAssoc($res)) { + if ($row['heskprivileges'] != '') { + $currentPrivileges = explode(',', $row['heskprivileges']); + array_push($currentPrivileges, 'can_change_notification_settings'); + $newPrivileges = implode(',', $currentPrivileges); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = '" . hesk_dbEscape($newPrivileges) . "' + WHERE `id` = " . intval($row['id'])); + } else { + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = 'can_change_notification_settings' + WHERE `id` = " . intval($row['id'])); + } + } + } + + function down($hesk_settings) { + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` + SET `can_change_notification_settings` = '0' + WHERE `heskprivileges` NOT LIKE '%can_change_notification_settings%'"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/CopyCanManSettings.php b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/CopyCanManSettings.php new file mode 100644 index 00000000..65cc8bdd --- /dev/null +++ b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/CopyCanManSettings.php @@ -0,0 +1,31 @@ +executeQuery("SELECT `id`, `heskprivileges` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `isadmin` = '0' + AND `can_manage_settings` = '1'"); + while ($row = hesk_dbFetchAssoc($res)) { + if ($row['heskprivileges'] != '') { + $currentPrivileges = explode(',', $row['heskprivileges']); + array_push($currentPrivileges, 'can_man_settings'); + $newPrivileges = implode(',', $currentPrivileges); + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = '" . hesk_dbEscape($newPrivileges) . "' + WHERE `id` = " . intval($row['id'])); + } else { + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `heskprivileges` = 'can_man_settings' + WHERE `id` = " . intval($row['id'])); + } + } + } + + function down($hesk_settings) { + $this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` + SET `can_manage_settings` = '0' + WHERE `heskprivileges` NOT LIKE '%can_man_settings%'"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/DropCanChangeNotificationSettingsColumn.php b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/DropCanChangeNotificationSettingsColumn.php new file mode 100644 index 00000000..f7251354 --- /dev/null +++ b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/DropCanChangeNotificationSettingsColumn.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `can_change_notification_settings`"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_change_notification_settings` ENUM('0', '1') NOT NULL DEFAULT '1'"); + } +} \ No newline at end of file diff --git a/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/DropCanManSettingsColumn.php b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/DropCanManSettingsColumn.php new file mode 100644 index 00000000..f3379eb9 --- /dev/null +++ b/install/migrations/v230/MovePermissionsToHeskPrivilegesColumn/DropCanManSettingsColumn.php @@ -0,0 +1,15 @@ +executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` DROP COLUMN `can_manage_settings`"); + } + + function down($hesk_settings) { + $this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ADD COLUMN `can_manage_settings` ENUM ('0', '1') NOT NULL DEFAULT '1'"); + } +} \ No newline at end of file