Browse Source

Add script to delete secrets older than 7 days

add-test-db-and-override
Blaine Motsinger 1 year ago
parent
commit
a1950fbd68
  1. 23
      bin/delete_expired_secrets.pl

23
bin/delete_expired_secrets.pl

@ -0,0 +1,23 @@
use strictures version => 2;
use Time::Piece;
use Try::Tiny;
use Pasteburn::DB ();
my $time = localtime;
my $now = $time->epoch;
my $dbh = Pasteburn::DB::connect_db();
my $sql = qq{
DELETE FROM secrets
WHERE created_at + (86400 * 7) <= $now
};
my $result = try {
return $dbh->do( $sql );
}
catch {
my $exception = $_;
die "delete secrets failed: $exception";
};
Loading…
Cancel
Save