Created
July 13, 2010 11:12
-
-
Save willnet/473736 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# ActiveRecordで管理している古いsessionを削除するスクリプト | |
# デフォルトで14日以上前のレコードを削除 | |
ENV["RAILS_ENV"] ||= "production" | |
require File.dirname(__FILE__) + '/../config/boot' | |
require File.dirname(__FILE__) + '/../config/environment' | |
num = ARGV.shift || 14 | |
num = num.to_i | |
# puts RAILS_ENV | |
# puts "DELETE FROM sessions where #{num.days.ago.to_s(:db)} > created_at;" | |
ActiveRecord::Base.connection.execute "DELETE FROM sessions where '#{num.days.ago.to_s(:db)}' > updated_at;" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment