Skip to content
Snippets Groups Projects
Commit 7770208a authored by Peter Rotich's avatar Peter Rotich Committed by Peter Rotich
Browse files

Add patch for various db issues and enhancements

Conflicts:

	include/upgrader/streams/core.sig
parent c93f5e74
No related branches found
No related tags found
No related merge requests found
...@@ -181,7 +181,7 @@ class Thread { ...@@ -181,7 +181,7 @@ class Thread {
/* XXX: Leave this out until TICKET_EMAIL_INFO_TABLE has a primary /* XXX: Leave this out until TICKET_EMAIL_INFO_TABLE has a primary
* key * key
$sql = 'DELETE mid.* FROM '.TICKET_EMAIL_INFO_TABLE.' mid $sql = 'DELETE mid.* FROM '.TICKET_EMAIL_INFO_TABLE.' mid
INNER JOIN '.TICKET_THREAD_TABLE.' thread ON (thread.id = mid.message_id) INNER JOIN '.TICKET_THREAD_TABLE.' thread ON (thread.id = mid.thread_id)
WHERE thread.ticket_id = '.db_input($this->getTicketId()); WHERE thread.ticket_id = '.db_input($this->getTicketId());
db_query($sql); db_query($sql);
*/ */
...@@ -244,7 +244,7 @@ Class ThreadEntry { ...@@ -244,7 +244,7 @@ Class ThreadEntry {
.' ,count(DISTINCT attach.attach_id) as attachments ' .' ,count(DISTINCT attach.attach_id) as attachments '
.' FROM '.TICKET_THREAD_TABLE.' thread ' .' FROM '.TICKET_THREAD_TABLE.' thread '
.' LEFT JOIN '.TICKET_EMAIL_INFO_TABLE.' info .' LEFT JOIN '.TICKET_EMAIL_INFO_TABLE.' info
ON (thread.id=info.message_id) ' ON (thread.id=info.thread_id) '
.' LEFT JOIN '.TICKET_ATTACHMENT_TABLE.' attach .' LEFT JOIN '.TICKET_ATTACHMENT_TABLE.' attach
ON (thread.ticket_id=attach.ticket_id ON (thread.ticket_id=attach.ticket_id
AND thread.id=attach.ref_id AND thread.id=attach.ref_id
...@@ -337,7 +337,7 @@ Class ThreadEntry { ...@@ -337,7 +337,7 @@ Class ThreadEntry {
require_once(INCLUDE_DIR.'class.mailparse.php'); require_once(INCLUDE_DIR.'class.mailparse.php');
$sql = 'SELECT headers FROM '.TICKET_EMAIL_INFO_TABLE $sql = 'SELECT headers FROM '.TICKET_EMAIL_INFO_TABLE
.' WHERE message_id='.$this->getId(); .' WHERE thread_id='.$this->getId();
$headers = db_result(db_query($sql)); $headers = db_result(db_query($sql));
return Mail_Parse::splitHeaders($headers); return Mail_Parse::splitHeaders($headers);
} }
...@@ -643,7 +643,7 @@ Class ThreadEntry { ...@@ -643,7 +643,7 @@ Class ThreadEntry {
/* static */ /* static */
function logEmailHeaders($id, $mid, $header=false) { function logEmailHeaders($id, $mid, $header=false) {
$sql='INSERT INTO '.TICKET_EMAIL_INFO_TABLE $sql='INSERT INTO '.TICKET_EMAIL_INFO_TABLE
.' SET message_id='.db_input($id) //TODO: change it to thread_id .' SET thread_id='.db_input($id)
.', email_mid='.db_input($mid); //TODO: change it to message_id. .', email_mid='.db_input($mid); //TODO: change it to message_id.
if ($header) if ($header)
$sql .= ', headers='.db_input($header); $sql .= ', headers='.db_input($header);
...@@ -708,8 +708,8 @@ Class ThreadEntry { ...@@ -708,8 +708,8 @@ Class ThreadEntry {
function lookupByEmailHeaders($mailinfo, &$seen=false) { function lookupByEmailHeaders($mailinfo, &$seen=false) {
// Search for messages using the References header, then the // Search for messages using the References header, then the
// in-reply-to header // in-reply-to header
$search = 'SELECT message_id, email_mid FROM '.TICKET_EMAIL_INFO_TABLE $search = 'SELECT thread_id, email_mid FROM '.TICKET_EMAIL_INFO_TABLE
. ' WHERE email_mid=%s ORDER BY message_id DESC'; . ' WHERE email_mid=%s ORDER BY thread_id DESC';
if (list($id, $mid) = db_fetch_row(db_query( if (list($id, $mid) = db_fetch_row(db_query(
sprintf($search, db_input($mailinfo['mid']))))) { sprintf($search, db_input($mailinfo['mid']))))) {
......
ed60ba203a473f4f32ac49eb45db16c7 8473721890e9eddb6417076c96b715a1
/**
* @version v1.8.1
* @signature 8473721890e9eddb6417076c96b715a1
* @title Various schema improvements and bug fixes
*
*/
-- [#317](https://github.com/osTicket/osTicket-1.8/issues/317)
ALTER TABLE `%TABLE_PREFIX%faq`
CHANGE `created` `created` datetime NOT NULL,
CHANGE `updated` `updated` datetime NOT NULL;
-- [#328](https://github.com/osTicket/osTicket-1.8/issues/328)
UPDATE `%TABLE_PREFIX%filter_rule`
SET `how` = 'equal' WHERE `how` IS NULL;
-- [#331](https://github.com/osTicket/osTicket-1.8/issues/331)
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`);
-- [#386](https://github.com/osTicket/osTicket-1.8/issues/386)
UPDATE `%TABLE_PREFIX%email_template`
SET `body` = REPLACE(`body`, '%{recipient}', '%{recipient.name}');
-- Change EndUser link to be recipient specific
UPDATE `%TABLE_PREFIX%email_template`
SET `body` = REPLACE(`body`, '%{ticket.client_link}', '%{recipient.ticket_link}');
-- Add inline flag and drop ref_type
ALTER TABLE `%TABLE_PREFIX%ticket_attachment`
ADD `inline` tinyint(1) NOT NULL default 0 AFTER `ref_id`,
DROP `ref_type`;
ALTER TABLE `%TABLE_PREFIX%ticket_thread`
ADD `user_id` int(11) unsigned not null default 0 AFTER `staff_id`;
ALTER TABLE `%TABLE_PREFIX%ticket`
ADD `email_id` int(11) unsigned not null default 0 AFTER `team_id`,
CHANGE `ticketID` `number` varchar(20);
ALTER TABLE `%TABLE_PREFIX%ticket_collaborator`
ADD`created` datetime NOT NULL AFTER `role`;
-- Finished with patch
UPDATE `%TABLE_PREFIX%config`
SET `value` = '8473721890e9eddb6417076c96b715a1'
WHERE `key` = 'schema_signature' AND `namespace` = 'core';
...@@ -33,8 +33,8 @@ CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%faq` ( ...@@ -33,8 +33,8 @@ CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%faq` (
`answer` text NOT NULL, `answer` text NOT NULL,
`keywords` tinytext, `keywords` tinytext,
`notes` text, `notes` text,
`created` date NOT NULL, `created` datetime NOT NULL,
`updated` date NOT NULL, `updated` datetime NOT NULL,
PRIMARY KEY (`faq_id`), PRIMARY KEY (`faq_id`),
UNIQUE KEY `question` (`question`), UNIQUE KEY `question` (`question`),
KEY `category_id` (`category_id`), KEY `category_id` (`category_id`),
...@@ -506,7 +506,7 @@ CREATE TABLE `%TABLE_PREFIX%team_member` ( ...@@ -506,7 +506,7 @@ CREATE TABLE `%TABLE_PREFIX%team_member` (
DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket`; DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket`;
CREATE TABLE `%TABLE_PREFIX%ticket` ( CREATE TABLE `%TABLE_PREFIX%ticket` (
`ticket_id` int(11) unsigned NOT NULL auto_increment, `ticket_id` int(11) unsigned NOT NULL auto_increment,
`ticketID` int(11) unsigned NOT NULL default '0', `number` varchar(20),
`user_id` int(11) unsigned NOT NULL default '0', `user_id` int(11) unsigned NOT NULL default '0',
`user_email_id` int(11) unsigned NOT NULL default '0', `user_email_id` int(11) unsigned NOT NULL default '0',
`dept_id` int(10) unsigned NOT NULL default '0', `dept_id` int(10) unsigned NOT NULL default '0',
...@@ -514,6 +514,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket` ( ...@@ -514,6 +514,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket` (
`topic_id` int(10) unsigned NOT NULL default '0', `topic_id` int(10) unsigned NOT NULL default '0',
`staff_id` int(10) unsigned NOT NULL default '0', `staff_id` int(10) unsigned NOT NULL default '0',
`team_id` int(10) unsigned NOT NULL default '0', `team_id` int(10) unsigned NOT NULL default '0',
`email_id` int(11) unsigned NOT NULL default '0',
`ip_address` varchar(64) NOT NULL default '', `ip_address` varchar(64) NOT NULL default '',
`status` enum('open','closed') NOT NULL default 'open', `status` enum('open','closed') NOT NULL default 'open',
`source` enum('Web','Email','Phone','API','Other') NOT NULL default 'Other', `source` enum('Web','Email','Phone','API','Other') NOT NULL default 'Other',
...@@ -544,11 +545,10 @@ CREATE TABLE `%TABLE_PREFIX%ticket_attachment` ( ...@@ -544,11 +545,10 @@ CREATE TABLE `%TABLE_PREFIX%ticket_attachment` (
`ticket_id` int(11) unsigned NOT NULL default '0', `ticket_id` int(11) unsigned NOT NULL default '0',
`file_id` int(10) unsigned NOT NULL default '0', `file_id` int(10) unsigned NOT NULL default '0',
`ref_id` int(11) unsigned NOT NULL default '0', `ref_id` int(11) unsigned NOT NULL default '0',
`ref_type` enum('M','R','N') NOT NULL default 'M', `inline` tinyint(1) NOT NULL default '0',
`created` datetime NOT NULL, `created` datetime NOT NULL,
PRIMARY KEY (`attach_id`), PRIMARY KEY (`attach_id`),
KEY `ticket_id` (`ticket_id`), KEY `ticket_id` (`ticket_id`),
KEY `ref_type` (`ref_type`),
KEY `ref_id` (`ref_id`), KEY `ref_id` (`ref_id`),
KEY `file_id` (`file_id`) KEY `file_id` (`file_id`)
) DEFAULT CHARSET=utf8; ) DEFAULT CHARSET=utf8;
...@@ -567,10 +567,11 @@ CREATE TABLE `%TABLE_PREFIX%ticket_lock` ( ...@@ -567,10 +567,11 @@ CREATE TABLE `%TABLE_PREFIX%ticket_lock` (
DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket_email_info`; DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket_email_info`;
CREATE TABLE `%TABLE_PREFIX%ticket_email_info` ( CREATE TABLE `%TABLE_PREFIX%ticket_email_info` (
`message_id` int(11) unsigned NOT NULL, `thread_id` int(11) unsigned NOT NULL,
`email_mid` varchar(255) NOT NULL, `email_mid` varchar(255) NOT NULL,
`headers` text, `headers` text,
KEY `message_id` (`email_mid`) PRIMARY KEY (`thread_id`),
KEY `email_mid` (`email_mid`)
) DEFAULT CHARSET=utf8; ) DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket_event`; DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket_event`;
...@@ -629,6 +630,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_collaborator` ( ...@@ -629,6 +630,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_collaborator` (
`user_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 -- M => (message) clients, N => (note) 3rd-Party, R => (reply) external authority
`role` char(1) NOT NULL DEFAULT 'M', `role` char(1) NOT NULL DEFAULT 'M',
`created` datetime NOT NULL,
`updated` datetime NOT NULL, `updated` datetime NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `collab` (`ticket_id`,`user_id`) UNIQUE KEY `collab` (`ticket_id`,`user_id`)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment