4 use FS::UID qw(adminsuidsetup dbh);
5 use FS::Record; #why is this necessary
7 #WARNING: not all tables are safe to remove history!
8 # these are, and seem to take the most space in a typical install with queued
10 my @tables = qw( h_queue h_queue_arg );
13 my $seconds = $years * 31556926; #60*60*24*365.2422 is close enough
14 my $before = int( time - $seconds );
16 adminsuidsetup shift or die "usage: del-old-history user\n";
18 foreach my $table ( @tables ) {
20 unless ( $table =~ /^h_/ ) {
21 warn "$table is not a history table, skipping\n";
25 my $sql = "DELETE FROM $table WHERE history_date < $before";
27 my $sth = dbh->prepare($sql) or die dbh->errstr;
28 $sth->execute or die $sth->errstr;