OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/lib/tasks/database.rake

12 lines
510 B

namespace 'db:sessions' do
desc 'Expire old sessions from the sessions table'
task :expire, [:days_ago] => [:environment, 'db:load_config'] do |_task, args|
# sessions expire after 30 days of inactivity by default
days_ago = Integer(args[:days_ago] || 30)
expiration_time = Date.today - days_ago.days
sessions_table = ActiveRecord::SessionStore::Session.table_name
ActiveRecord::Base.connection.execute "DELETE FROM #{sessions_table} WHERE updated_at < '#{expiration_time}'"
end
end