Skip to content
Snippets Groups Projects
Commit 7f9415ff authored by Jared Hancock's avatar Jared Hancock
Browse files

Add PK to %ticket_email_info.`id`

This patch partially reverts the previous database migration patch which
added a primary key to the table on the `thread_id` column. This column
cannot be used, because there may be multiple entries for thread_id = 0.

This also allows ticket_collaborator.isactive to be negative, as well as
adds the database portion of regex support for ticket filters.
parent 8c399826
No related branches found
No related tags found
No related merge requests found
f1ccd3bb620e314b0ae1dbd0a1a99177
f5692e24c7afba7ab6168dde0b3bb3c8
......@@ -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`);
......
/**
* @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`);
/**
* @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';
<?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';
?>
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment