At Thursday 6/14/2007 07:42 AM, Tim Hill wrote:
Hi,

I have a member of staff who has decided to attach docuements to his tickets in bitmap format, unfortunately these bitmap images are between 4 and 8 MB in size and they have taken up more space in a day of doing this than the rest of the RT system has taken up in almost a year of operation.

I don't mind if the tickets have to be deleted, they can be recreated easily enough. How can I get rid of these attachments from the RT database? Where are the attachments stored and what are my options for getting rid of them?

I am using the following:
RT version 3.4.4 from an ubuntu package.
Server version of dapper drake 6.06 LTS (webmin shows this as 6.06.1)
Webmin version 1.320
PostgreSQL version 7.4.12 (With schemas)

Please let me know if you require any other information.

Thanks in advance,
Tim

Tim,

As always I'd recommend using a Perl script rather than monkey with the database - you can delete a transaction through the RT API:

Here's the script I use. It needs RT_HOME set as an environment variable, and RT_HOME/lib directory should be on Perl's search path.

#!/bin/perl
#
# Deletes a transaction from the database.
#
use lib $ENV{RT_HOME}."/etc";

use RT::Interface::CLI qw (CleanEnv GetCurrentUser);
use RT::User;
use RT::Ticket;

die "Usage: $0 ticket_number transaction_number" if scalar (@ARGV) != 2;
my $tktno = shift @ARGV;
my $transno = shift @ARGV;

CleanEnv();
RT::LoadConfig();
RT::Init();

my $CurrentUser = GetCurrentUser();

my $Ticket = new RT::Ticket($CurrentUser);
$Ticket->Load($tktno);

die "Unknown ticket $tktno" if ! $Ticket->id;

my $Transaction = new RT::Transaction($CurrentUser);
$Transaction->Load($transno);

die "No such transaction $transno" if ! $Transaction->id;

die "Wrong ticket number" unless $Transaction->ObjectType eq 'RT::Ticket' && $Transaction->ObjectId == $tktno;

print "Transaction Found:\n";
print "  ID: ".$Transaction->Id."\n";
print "  Type: ".$Transaction->Type."\n";
print "  Created: ".$Transaction->Created."\n";

print "Do you really want to delete the transaction? [N] ";
$| = 1;
$_ = <STDIN>;

chomp;

if ($_ && uc($_) eq 'Y') {
    $Transaction->Delete();
    print "Transaction Deleted\n";
} else {
    print "OK - Not Deleting\n";
}


_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. Buy a copy at http://rtbook.bestpractical.com

Reply via email to