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
namespace :optimization do | |
desc "Provide DB vacuum for production environment" | |
task :vacuum => :environment do | |
begin | |
tables = ActiveRecord::Base.connection.tables | |
tables.each do |table| | |
ActiveRecord::Base.connection.execute("VACUUM FULL ANALYZE #{table};") | |
end | |
rescue Exception => exc | |
Rails.logger.error("Database VACUUM error: #{exc.message}") |