summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Command
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travelynx/Command')
-rw-r--r--lib/Travelynx/Command/database.pm12
-rw-r--r--lib/Travelynx/Command/maintenance.pm7
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/database.pm b/lib/Travelynx/Command/database.pm
index be5db72..05b43d6 100644
--- a/lib/Travelynx/Command/database.pm
+++ b/lib/Travelynx/Command/database.pm
@@ -412,6 +412,18 @@ my @migrations = (
}
);
},
+
+ # v8 -> v9
+ sub {
+ my ($db) = @_;
+ $db->query(
+ qq{
+ alter table users rename column last_login to last_seen;
+ drop table user_actions;
+ update schema_version set version = 9;
+ }
+ );
+ },
);
sub setup_db {
diff --git a/lib/Travelynx/Command/maintenance.pm b/lib/Travelynx/Command/maintenance.pm
index 2030705..8c07728 100644
--- a/lib/Travelynx/Command/maintenance.pm
+++ b/lib/Travelynx/Command/maintenance.pm
@@ -13,6 +13,7 @@ sub run {
my $now = DateTime->now( time_zone => 'Europe/Berlin' );
my $verification_deadline = $now->clone->subtract( hours => 48 );
my $deletion_deadline = $now->clone->subtract( hours => 72 );
+ my $old_deadline = $now->clone->subtract( years => 1 );
my $db = $self->app->pg->db;
my $tx = $db->begin;
@@ -80,6 +81,12 @@ sub run {
{ deletion_requested => { '<', $deletion_deadline } } );
my @uids_to_delete = $to_delete->arrays->map( sub { shift->[0] } )->each;
+ $to_delete
+ = $db->select( 'users', ['id'], { last_seen => { '<', $old_deadline } } );
+
+ push( @uids_to_delete,
+ $to_delete->arrays->map( sub { shift->[0] } )->each );
+
if ( @uids_to_delete > 10 ) {
printf STDERR (
"About to delete %d accounts, which is quite a lot.\n",