-
Notifications
You must be signed in to change notification settings - Fork 3
Add a rake task to clean expired access tokens #114
Copy link
Copy link
Open
Labels
Description
Why
- We're using Heroku Postgres - Mini which has the limitation of 10k records
- Recently, the records have increased so quickly
- We should add a task to clean the token table and run it everyday
namespace :token do
desc "Clean expired tokens"
task clean: :environment do
delete_before = 1.days.ago
expire = [
"(revoked_at IS NOT NULL AND revoked_at < :delete_before) OR " +
"(expires_in IS NOT NULL AND (created_at + expires_in * INTERVAL '1 second') < :delete_before)",
{ delete_before: delete_before }
]
Doorkeeper::AccessToken.where(expire).delete_all
end
endWho Benefits?
Maintainers
Reactions are currently unavailable