diff --git a/include/upgrader/streams/core.sig b/include/upgrader/streams/core.sig index 6dad7bd6c28059aac49c966dd472d51ddcf6e66a..3ac67bf82846c663c880c6fc441e5e108e310989 100644 --- a/include/upgrader/streams/core.sig +++ b/include/upgrader/streams/core.sig @@ -1 +1 @@ -f1ccd3bb620e314b0ae1dbd0a1a99177 +f5692e24c7afba7ab6168dde0b3bb3c8 diff --git a/include/upgrader/streams/core/ed60ba20-934954de.patch.sql b/include/upgrader/streams/core/ed60ba20-934954de.patch.sql index a9b2ec364841d77ef62fe4f13b01367796d5da0f..39c210f4d1d7d9ffa65150243cb4cf81db96d552 100644 --- a/include/upgrader/streams/core/ed60ba20-934954de.patch.sql +++ b/include/upgrader/streams/core/ed60ba20-934954de.patch.sql @@ -17,11 +17,8 @@ UPDATE `%TABLE_PREFIX%filter_rule` -- [#331](https://github.com/osTicket/osTicket-1.8/issues/331) -- Previously there was no primary key on the %ticket_email_info table, so -- clean up any junk records before adding one -DELETE FROM `%TABLE_PREFIX%ticket_email_info` WHERE - `message_id` = 0 OR `message_id` IS NULL; ALTER TABLE `%TABLE_PREFIX%ticket_email_info` CHANGE `message_id` `thread_id` int(11) unsigned NOT NULL, - ADD PRIMARY KEY (`thread_id`), DROP INDEX `message_id`, ADD INDEX `email_mid` (`email_mid`); diff --git a/include/upgrader/streams/core/f1ccd3bb-f5692e24.cleanup.sql b/include/upgrader/streams/core/f1ccd3bb-f5692e24.cleanup.sql new file mode 100644 index 0000000000000000000000000000000000000000..109cf6c02c663533571b1e15c28086e213ddbcae --- /dev/null +++ b/include/upgrader/streams/core/f1ccd3bb-f5692e24.cleanup.sql @@ -0,0 +1,18 @@ +/** + * @version v1.8.1 + * @signature f5692e24c7afba7ab6168dde0b3bb3c8 + * @title Add regex field to ticket filters + * + * This fixes a glitch introduced @934954de8914d9bd2bb8343e805340ae where + * a primary key was added to the %ticket_email_info table so that deleting + * can be supported in a clustered environment. The patch added the + * `thread_id` column as the primary key, which was incorrect, because the + * `thread_id` may be null when rejected emails are recorded so they are + * never considered again if found in the inbox. + */ + +-- Add the primary key. The PK on `thread_id` would have been removed in the +-- task if it existed +ALTER TABLE `%TABLE_PREFIX%ticket_email_info` + ADD `id` int(11) unsigned not null auto_increment FIRST, + ADD PRIMARY KEY (`id`); diff --git a/include/upgrader/streams/core/f1ccd3bb-f5692e24.patch.sql b/include/upgrader/streams/core/f1ccd3bb-f5692e24.patch.sql new file mode 100644 index 0000000000000000000000000000000000000000..ddf764696d9b25c17607bd3dd5fdb91968eee5f8 --- /dev/null +++ b/include/upgrader/streams/core/f1ccd3bb-f5692e24.patch.sql @@ -0,0 +1,28 @@ +/** + * @version v1.8.1 + * @signature f5692e24c7afba7ab6168dde0b3bb3c8 + * @title Add regex field to ticket filters + * + * This fixes a glitch introduced @934954de8914d9bd2bb8343e805340ae where + * a primary key was added to the %ticket_email_info table so that deleting + * can be supported in a clustered environment. The patch added the + * `thread_id` column as the primary key, which was incorrect, because the + * `thread_id` may be null when rejected emails are recorded so they are + * never considered again if found in the inbox. + */ + +-- [#479](https://github.com/osTicket/osTicket-1.8/issues/479) +-- Add (not)_match to the filter_rule `how` +ALTER TABLE `%TABLE_PREFIX%filter_rule` + CHANGE `how` `how` enum('equal','not_equal','contains','dn_contain','starts','ends','match','not_match') + NOT NULL; + +-- Allow `isactive` to be `-1` for collaborators, which might indicate +-- something like 'unsubscribed' +ALTER TABLE `%TABLE_PREFIX%ticket_collaborator` + CHANGE `isactive` `isactive` tinyint(1) NOT NULL DEFAULT '1'; + +-- Finished with patch +UPDATE `%TABLE_PREFIX%config` + SET `value` = 'f5692e24c7afba7ab6168dde0b3bb3c8' + WHERE `key` = 'schema_signature' AND `namespace` = 'core'; diff --git a/include/upgrader/streams/core/f1ccd3bb-f5692e24.task.php b/include/upgrader/streams/core/f1ccd3bb-f5692e24.task.php new file mode 100644 index 0000000000000000000000000000000000000000..fd58fe77064f1a81e41e6dc7a31ba0daac3a1de9 --- /dev/null +++ b/include/upgrader/streams/core/f1ccd3bb-f5692e24.task.php @@ -0,0 +1,27 @@ +<?php + +/* + * Drops the `thread_id` primary key on the ticket_email_info table if it + * exists + */ + +class DropTicketEmailInfoPk extends MigrationTask { + var $description = "Reticulating splines"; + + function run($max_time) { + $sql = 'SELECT `INDEX_NAME` FROM information_schema.statistics + WHERE table_schema = '.db_input(DBNAME) + .' AND table_name = '.db_input(TICKET_EMAIL_INFO_TABLE) + .' AND column_name = '.db_input('thread_id'); + if ($name = db_result(db_query($sql))) { + if ($name == 'PRIMARY') { + db_query('ALTER TABLE `'.TICKET_EMAIL_INFO_TABLE + .'` DROP PRIMARY KEY'); + } + } + } +} + +return 'DropTicketEmailInfoPk'; + +?> diff --git a/setup/inc/streams/core/install-mysql.sql b/setup/inc/streams/core/install-mysql.sql index 4b51a63c9410e742ac716eb759a61670ef968799..85f06999698f21093930575429e967ff7e28ab29 100644 --- a/setup/inc/streams/core/install-mysql.sql +++ b/setup/inc/streams/core/install-mysql.sql @@ -276,7 +276,7 @@ CREATE TABLE `%TABLE_PREFIX%filter_rule` ( `id` int(11) unsigned NOT NULL auto_increment, `filter_id` int(10) unsigned NOT NULL default '0', `what` varchar(32) NOT NULL, - `how` enum('equal','not_equal','contains','dn_contain','starts','ends') NOT NULL, + `how` enum('equal','not_equal','contains','dn_contain','starts','ends','match','not_match') NOT NULL, `val` varchar(255) NOT NULL, `isactive` tinyint(1) unsigned NOT NULL DEFAULT '1', `notes` tinytext NOT NULL, @@ -572,10 +572,11 @@ CREATE TABLE `%TABLE_PREFIX%ticket_lock` ( DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket_email_info`; CREATE TABLE `%TABLE_PREFIX%ticket_email_info` ( + `id` int(11) unsigned NOT NULL auto_increment, `thread_id` int(11) unsigned NOT NULL, `email_mid` varchar(255) NOT NULL, `headers` text, - PRIMARY KEY (`thread_id`), + PRIMARY KEY (`id`), KEY `email_mid` (`email_mid`) ) DEFAULT CHARSET=utf8; @@ -631,7 +632,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_thread` ( CREATE TABLE `%TABLE_PREFIX%ticket_collaborator` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `isactive` tinyint(1) unsigned NOT NULL DEFAULT '1', + `isactive` tinyint(1) NOT NULL DEFAULT '1', `ticket_id` int(11) unsigned NOT NULL DEFAULT '0', `user_id` int(11) unsigned NOT NULL DEFAULT '0', -- M => (message) clients, N => (note) 3rd-Party, R => (reply) external authority