Kayako logo
Modifications & Addon Releases Modification guides and addons are posted here to share with the community. Do not post requests in here!

Notices

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  (#1) Old
Antonio Offline
New Member
 
Antonio's Avatar
 
Posts: 7
Join Date: Mar 2006
Lightbulb Cleaning esupport database - 29-11-2006, 01:37 PM

Maybe this stuff will be handy.

Code:
/* attachments from tickets with last post > then 3 months */
DELETE FROM swattachments WHERE ticketid IN (
	SELECT ticketid
	FROM (
		SELECT
			t.ticketid
			,MAX(tp.dateline) AS dateline
		FROM swtickets t INNER JOIN swticketposts tp ON t.ticketid=tp.ticketid
		GROUP BY t.ticketid
	) g
	WHERE g.dateline < (UNIX_TIMESTAMP()-7776000)
)

/* now get rid of "hanging" rows in miscelaneous tables */

/* attachments */
DELETE FROM swattachments WHERE ticketid NOT IN (SELECT ticketid FROM swtickets)

/* attachments chunks */
DELETE FROM swattachmentchunks WHERE attachmentid NOT IN (SELECT attachmentid FROM swattachments)

/* tickets posts */
DELETE FROM swticketposts WHERE ticketid NOT IN (SELECT ticketid FROM swtickets)

/* tickets locks */
DELETE FROM swticketlocks WHERE ticketid NOT IN (SELECT ticketid FROM swtickets)

/* ticket message ids */
DELETE FROM swticketmessageids WHERE ticketpostid NOT IN (SELECT ticketpostid FROM swticketposts)

/* ticket posts index */
DELETE FROM swticketpostindex WHERE ticketpostid NOT IN (SELECT ticketpostid FROM swticketposts)

/* ticket words */
DELETE FROM swticketwords WHERE ticketwordid NOT IN (SELECT ticketwordid FROM swticketpostindex)

/* clear parser log */
delete from swparserlogs
delete from swparserlogdata
Let's see Kayako developers comments.
   
Reply With Quote
  (#2) Old
dogslife Offline
New Member
 
Posts: 6
Join Date: Feb 2007
02-02-2007, 01:47 PM

Thanks Antonio!

Is this the only way to delete attachments?

   
Reply With Quote
  (#3) Old
supportskins Offline
Senior Member
 
supportskins's Avatar
 
Posts: 3,692
Join Date: Aug 2006
Location: Mumbai, India
02-02-2007, 03:50 PM

great post!



Professional and Affordable Kayako Skins - Specialists in Kayako Skinning & Customization - Professional Paid Support
Our Skins and Services - http://www.supportskins.com/store/
SupportSkins.com - http://www.supportskins.com/
   
Reply With Quote
  (#4) Old
mopa Offline
Member
 
mopa's Avatar
 
Posts: 138
Join Date: May 2007
Location: Denmark
28-03-2008, 03:16 PM

Did something change since this was written?

I get this error in myphpadmin:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM swattachments WHERE ticketid NOT IN (SELECT ticketid FROM swtickets)' at line 16


Kayako: 3.11.01 | PHP: 5.2.3 | MySQL: 5.0.41 | Windows 2003 Server
   
Reply With Quote
  (#5) Old
Dynadata Offline
Member
 
Posts: 171
Join Date: Feb 2008
Location: Netherlands
28-03-2008, 03:35 PM

You do not have the SupportSuite product and your table prefix should be different then he used.
So change every prefix in front of the table names with your own prefix.
   
Reply With Quote
  (#6) Old
mopa Offline
Member
 
mopa's Avatar
 
Posts: 138
Join Date: May 2007
Location: Denmark
31-03-2008, 07:24 AM

I don't see that I have any other prefix.
My tables are just called swparserlogdata, swsessions etc. without any prefix_swsessions.
Could it be something else?


Kayako: 3.11.01 | PHP: 5.2.3 | MySQL: 5.0.41 | Windows 2003 Server
   
Reply With Quote
  (#7) Old
nolageek Offline
New Member
 
Posts: 24
Join Date: Apr 2008
08-04-2008, 08:37 PM

not working for me either.
   
Reply With Quote
  (#8) Old
mopa Offline
Member
 
mopa's Avatar
 
Posts: 138
Join Date: May 2007
Location: Denmark
09-04-2008, 07:09 AM

Funny. I have tried to run each "line" one at a time like instead of putting all the text into the sql I only run ie. this line:

Quote:
DELETE FROM swattachments WHERE ticketid NOT IN (SELECT ticketid FROM swtickets)
and then afterwards I moved on with another line. It seemed to work.


Kayako: 3.11.01 | PHP: 5.2.3 | MySQL: 5.0.41 | Windows 2003 Server
   
Reply With Quote
  (#9) Old
Matthew Offline
Member
 
Matthew's Avatar
 
Posts: 168
Join Date: Oct 2007
Location: Jakarta, Indonesia
09-04-2008, 07:51 AM

Isn't this now superfluous with the Tickets>Purge Ticket Attachments search criteria now available in the Admin CP?


Matthew Arciniega
The Precision Group

+ Free: Ticket List & Ticket Search Mods

+ Free: (Almost) Perfect Outlook/HTML Tickets
+ Tutorials: SLA System Explained l Using Template Groups
Kayako v3.20.02 & v3.30.02 | PHP: 5.2.6 | MySQL: 5.0.58 | CentOS 4 Server
   
Reply With Quote
Reply

Tags
cleaning, database, esupport

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import eSupport database into SupportSuite one9 SupportSuite, eSupport and LiveResponse 0 02-09-2006 03:32 AM
eSupport v2.2 Stable Released Varun Shoor News and Announcements 3 23-06-2004 11:39 PM
eSupport v2.2 RC2 Released Varun Shoor Technical Chat 1 11-06-2004 10:24 PM
eSupport v2.2 RC1 Available in Members Area Varun Shoor Technical Chat 1 17-05-2004 01:28 PM



Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vBulletin Skin developed by: vBStyles.com


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46