If you try to delete a significant amount of tickets, empty trash with thousands of records or cleanup spam you suddenly got attacked with, your database will probably time-out. Instead, you can use the following solution:
- Download the script attached to this article.
- You will need to edit it, and fill in the server name, database name, username and password for your MySQL server.
- Backup your database. PLEASE MAKE SURE YOU HAVE A VALID, LATEST BACKUP OF YOUR DATABASE BEFORE USING THIS SOLUTION!
- Edit the script according to your needs and run it.
You can edit the following line to match your needs (it currently removes tickets that were created before certain date):
$result = mysql_query("select ticketid from swtickets where date(from_unixtime(dateline)) < '2011-12-31'");
for example if you need to delete all tickets from one user:
$result = mysql_query("select ticketid from swtickets where userid='ID OF YOUR USER'");
If you need to remove all tickets from trash:
$result = mysql_query("select ticketid from swtickets where departmentid=0");