Converted several other migrations
parent
f54c9bbd03
commit
c99f75c908
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
abstract class AbstractUpdateMigration extends AbstractMigration {
|
||||
abstract function getUpVersion();
|
||||
|
||||
abstract function getDownVersion();
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->updateVersion($this->getUpVersion(), $hesk_settings);
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->updateVersion($this->getDownVersion(), $hesk_settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v201;
|
||||
|
||||
|
||||
class UpdateVersion extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->updateVersion('2.0.1', $hesk_settings);
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->updateVersion('2.0.0', $hesk_settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v210;
|
||||
|
||||
|
||||
class UpdateVersion extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->updateVersion('2.1.0', $hesk_settings);
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->updateVersion('2.0.1', $hesk_settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace v211;
|
||||
|
||||
class FixStageTicketsTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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 '',
|
||||
ADD `firstreply` TIMESTAMP NULL DEFAULT NULL AFTER `lastchange`,
|
||||
ADD `closedat` TIMESTAMP NULL DEFAULT NULL AFTER `firstreply`,
|
||||
ADD `articles` VARCHAR(255) NULL DEFAULT NULL AFTER `closedat`,
|
||||
ADD `openedby` MEDIUMINT(8) DEFAULT '0' AFTER `status`,
|
||||
ADD `firstreplyby` SMALLINT(5) UNSIGNED NULL DEFAULT NULL AFTER `openedby`,
|
||||
ADD `closedby` MEDIUMINT(8) NULL DEFAULT NULL AFTER `firstreplyby`,
|
||||
ADD `replies` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' AFTER `closedby`,
|
||||
ADD `staffreplies` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `replies`,
|
||||
ADD INDEX ( `openedby` , `firstreplyby` , `closedby` ),
|
||||
ADD INDEX(`dt`)");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets`
|
||||
CHANGE `email` `email` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
CHANGE `ip` `ip` VARCHAR(46) NOT NULL DEFAULT '',
|
||||
DROP `firstreply`,
|
||||
DROP `closedat`,
|
||||
DROP `articles`,
|
||||
DROP `firstreplyby`,
|
||||
DROP `closedby`,
|
||||
DROP `replies`,
|
||||
DROP `staffreplies`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v211;
|
||||
|
||||
|
||||
class UpdateVersion extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->updateVersion('2.1.1', $hesk_settings);
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->updateVersion('2.1.0', $hesk_settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace v220;
|
||||
|
||||
|
||||
class AddClosableColumnToStatuses extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `Closable`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v220;
|
||||
|
||||
class AddIsAutocloseOptionToStatuses extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` DROP COLUMN `IsAutocloseOption`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v220;
|
||||
|
||||
|
||||
class UpdateVersion extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->updateVersion('2.2.0', $hesk_settings);
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->updateVersion('2.1.1', $hesk_settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v221;
|
||||
|
||||
|
||||
class UpdateVersion extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->updateVersion('2.2.1', $hesk_settings);
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->updateVersion('2.2.0', $hesk_settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class AddCategoryManager extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ADD COLUMN `manager` INT NOT NULL DEFAULT 0");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` DROP COLUMN `manager`");
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class AddCoordinatesToTickets extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class AddIconToServiceMessages extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` ADD COLUMN `icon` VARCHAR(150)");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "service_messages` DROP COLUMN `icon`");
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class ConsolidateStatusColumns extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class CreatePermissionTemplates extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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) {
|
||||
// TODO: Implement down() method.
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class MovePermissionsToHeskPrivilegesColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
// Move can_manage_settings and can_change_notification_settings into the heskprivileges list
|
||||
$res = $this->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_change_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%'");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class UpdateVersion extends \AbstractUpdateMigration {
|
||||
|
||||
function getUpVersion() {
|
||||
return '2.3.0';
|
||||
}
|
||||
|
||||
function getDownVersion() {
|
||||
return '2.2.1';
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v231;
|
||||
|
||||
|
||||
class UpdateVersion extends \AbstractUpdateMigration {
|
||||
|
||||
function getUpVersion() {
|
||||
return '2.3.1';
|
||||
}
|
||||
|
||||
function getDownVersion() {
|
||||
return '2.3.0';
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v232;
|
||||
|
||||
|
||||
class UpdateVersion extends \AbstractUpdateMigration {
|
||||
|
||||
function getUpVersion() {
|
||||
return '2.3.2';
|
||||
}
|
||||
|
||||
function getDownVersion() {
|
||||
return '2.3.1';
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace v240;
|
||||
|
||||
|
||||
class CreateQuickHelpSectionsTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("CREATE TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`location` VARCHAR(100) NOT NULL,
|
||||
`show` ENUM('0','1') NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
|
||||
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`)
|
||||
VALUES ('create_ticket', '1')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`)
|
||||
VALUES ('view_ticket_form', '1')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`)
|
||||
VALUES ('view_ticket', '1')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`)
|
||||
VALUES ('knowledgebase', '1')");
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` (`location`, `show`)
|
||||
VALUES ('staff_create_ticket', '1')");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections`");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue