Splitting up migrations.... partway done
parent
bc752ff2c3
commit
311697693f
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Pre140\Statuses;
|
||||
|
||||
use AbstractMigration;
|
||||
|
||||
class AddIntColumnUpDropTableDown extends AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Pre140\Statuses;
|
||||
|
||||
|
||||
class CreateStatusesTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$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`))");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` ADD COLUMN `status_int` INT NOT NULL AFTER `status`;");
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Pre140\Statuses;
|
||||
|
||||
|
||||
use AbstractMigration;
|
||||
|
||||
class DropOldStatusColumn extends AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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']);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Pre140\Statuses;
|
||||
|
||||
|
||||
class InsertStatusRecords extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$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);");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Pre140\Statuses;
|
||||
|
||||
use AbstractMigration;
|
||||
|
||||
class MoveStatusesToNewColumn extends AbstractMigration {
|
||||
|
||||
function up($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` = " . $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");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Pre140\Statuses;
|
||||
|
||||
|
||||
class RenameTempColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Pre140;
|
||||
|
||||
use AbstractMigration;
|
||||
|
||||
class StatusesMigration extends AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace v160\AddEditInfoToNotes;
|
||||
|
||||
class AddEditDateColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -1,17 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v160;
|
||||
namespace v160\AddEditInfoToNotes;
|
||||
|
||||
|
||||
class AddEditInfoToNotes extends \AbstractMigration {
|
||||
class AddNumberOfEditsColumn extends \AbstractMigration {
|
||||
|
||||
function up($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");
|
||||
}
|
||||
|
||||
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`");
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace v200;
|
||||
|
||||
|
||||
class MigrateIpAndEmailBans extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
// Insert the email bans
|
||||
$emailBanRS = $this->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'] . ")");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace v200\MigrateIpAndEmailBans;
|
||||
|
||||
|
||||
class DropOldEmailBansTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$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_emails` (
|
||||
ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
Email VARCHAR(100) NOT NULL);");
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace v200\MigrateIpAndEmailBans;
|
||||
|
||||
|
||||
class DropOldIpBansTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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)");
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace v200\MigrateIpAndEmailBans;
|
||||
|
||||
class InsertEmailBans extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$emailBanRS = $this->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']) . "')");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace v200\MigrateIpAndEmailBans;
|
||||
|
||||
|
||||
class InsertIpBans extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$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())");
|
||||
}
|
||||
}
|
||||
|
||||
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'] . ")");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace v200\RemoveEditInfoFromNotes;
|
||||
|
||||
class DropEditDate extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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");
|
||||
}
|
||||
}
|
@ -1,17 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v200;
|
||||
namespace v200\RemoveEditInfoFromNotes;
|
||||
|
||||
|
||||
class RemoveEditInfoFromNotes extends \AbstractMigration {
|
||||
class DropNumberOfEditsColumn extends \AbstractMigration {
|
||||
|
||||
function up($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`");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace v211\FixStageTicketsTable;
|
||||
|
||||
class ChangeDtColumnType 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'");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
// NOOP
|
||||
}
|
||||
}
|
@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace v211;
|
||||
namespace v211\FixStageTicketsTable;
|
||||
|
||||
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 '',
|
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace v220;
|
||||
namespace v220\AddClosableColumnToStatuses;
|
||||
|
||||
|
||||
class AddClosableColumnToStatuses extends \AbstractMigration {
|
||||
class AddNewColumn 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) {
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v220\AddClosableColumnToStatuses;
|
||||
|
||||
|
||||
class SetDefaultValue extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `Closable` = 'yes'");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
// no-op
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace v220;
|
||||
namespace v220\AddIsAutocloseOptionToStatuses;
|
||||
|
||||
class AddIsAutocloseOptionToStatuses extends \AbstractMigration {
|
||||
class AddNewColumn 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) {
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace v220\AddIsAutocloseOptionToStatuses;
|
||||
|
||||
class SetDefaultValue extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` SET `IsAutocloseOption` = 1 WHERE `IsStaffClosedOption` = 1");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
// no-op
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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\AddCoordinatesToTickets;
|
||||
|
||||
|
||||
class AddLatitudeToStageTickets extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\AddCoordinatesToTickets;
|
||||
|
||||
|
||||
class AddLatitudeToTickets 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'");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("ALTER TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` DROP COLUMN `latitude`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\AddCoordinatesToTickets;
|
||||
|
||||
|
||||
class AddLongitudeToStageTickets extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$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']) . "stage_tickets` DROP COLUMN `longitude`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\AddCoordinatesToTickets;
|
||||
|
||||
|
||||
class AddLongitudeToTickets extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\ConsolidateStatusColumns;
|
||||
|
||||
|
||||
class AddKeyColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\ConsolidateStatusColumns;
|
||||
|
||||
|
||||
class DropShortNameColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\ConsolidateStatusColumns;
|
||||
|
||||
|
||||
class DropTicketViewContentKeyColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$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");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\ConsolidateStatusColumns;
|
||||
|
||||
|
||||
class SetNewKeyColumnValue extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?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) {
|
||||
$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`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\CreatePermissionTemplates;
|
||||
|
||||
|
||||
class AddPermissionTemplateColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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`");
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace v230\CreatePermissionTemplates;
|
||||
|
||||
|
||||
class CreatePermissionTemplatesTable extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$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))");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
$this->executeQuery("DROP TABLE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates`");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\CreatePermissionTemplates;
|
||||
|
||||
|
||||
class InsertAdminPermissionTemplate extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("INSERT INTO `" . hesk_dbEscape($hesk_settings['db_pfix']) . "permission_templates` (`name`, `heskprivileges`, `categories`)
|
||||
VALUES ('Administrator', 'ALL', 'ALL')");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230\CreatePermissionTemplates;
|
||||
|
||||
|
||||
class InsertStaffPermissionTemplate extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$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')");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace v230\CreatePermissionTemplates;
|
||||
|
||||
|
||||
class UpdateAdminUsersTemplate extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->executeQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` SET `permission_template` = 1 WHERE `isadmin` = '1'");
|
||||
}
|
||||
|
||||
function down($hesk_settings) {
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?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_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%'");
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class CopyCanChangeNotificationSettings extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$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']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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%'");
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class CopyCanManSettings 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']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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%'");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class DropCanChangeNotificationSettingsColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_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'");
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace v230;
|
||||
|
||||
|
||||
class DropCanManSettingsColumn extends \AbstractMigration {
|
||||
|
||||
function up($hesk_settings) {
|
||||
$this->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'");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue