From c0aef1c7564d75f45811af1e90d8f25abdfc0b09 Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Tue, 6 Aug 2019 10:17:17 +0200 Subject: [PATCH] TT#64406 fix changing epoch/date column mode for 'cleanup' Change-Id: Ie38c70d765efaa2e24b4394b7b1d4ef13c6a02d6 --- lib/NGCP/Cleanup.pm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/NGCP/Cleanup.pm b/lib/NGCP/Cleanup.pm index 1400ebb..412cbcd 100644 --- a/lib/NGCP/Cleanup.pm +++ b/lib/NGCP/Cleanup.pm @@ -160,7 +160,13 @@ sub init_cmds { my ($self, $table) = @_; $table or die "No table name provided in the 'cleanup' command"; $self->env('dbh') or die "Not connected to a DB in the 'cleanup' command"; - foreach my $v (qw(time-column cleanup-days)) { + if ($self->env('timestamp-column')) { + $self->env('time-column-mode' => 'timestamp'); + $self->env('time-column' => $self->env('timestamp-column')); + } elsif ($self->env('time-column')) { + $self->env('time-column-mode' => 'time'); + } + foreach my $v (qw(time-column time-column-mode cleanup-days)) { $self->env($v) or die "Variable '$v' is not set in the 'cleanup' command"; } @@ -197,6 +203,11 @@ sub init_config { last; } $env{$1} = $2; + if ($1 eq "time-column") { + $env{"timestamp-column"} = undef; + } elsif ($1 eq "timestamp-column") { + $env{"time-column"} = undef; + } next; } @@ -623,14 +634,22 @@ sub cleanup_table { my $batch = $self->env('batch') // 0; my $limit = $batch ? "limit $batch" : ''; my $col = $self->env('time-column'); + my $col_mode = $self->env('time-column-mode'); my $dbh = $self->env('dbh'); my $cleanup_days = $self->env('cleanup-days'); my $deleted_rows = 0; while (1) { - my $aff = $dbh->do(<do(<do(< 0; }