instiki/lib/tasks/upgrade_instiki.rake
Jacques Distler 888e93a7fd Streamline Rake Task
Refactor the upgrade_instiki rake task.
Based on the (very nice) JHerdman's
  64d305f2a8
but defaults to 'production' environment, instead.
Instiki users don't know about production/development/test.
Instiki defaults to 'production'. So should its associated rake tasks.
2009-08-29 23:31:39 -05:00

18 lines
543 B
Ruby

task :upgrade_instiki => :environment do
RAILS_ENV = 'production' unless ENV['RAILS_ENV']
puts "Upgrading Instiki in #{RAILS_ENV} environment."
Web.all.each do |web|
public_path = Rails.root.join("public", web.address)
if public_path.exist?
webs_path = Rails.root.join("webs", web.address)
if webs_path.exist?
puts "Warning! The directory #{webs_path} already exists. Skipping."
else
public_path.rename(webs_path)
puts "Moved #{public_path} to #{webs_path}"
end
end
end
end