lib/tasks/naf_tasks.rake in naf-1.1.4 vs lib/tasks/naf_tasks.rake in naf-2.0.0

- old
+ new

@@ -61,9 +61,27 @@ ::Naf::HistoricalJobAffinityTab.name] ::Logical::Naf::CreateInfrastructure.new(model_names).work end end + namespace :logs do + desc "Archive logs (moves logs to a different directory)" + task archive: :environment do + # When installing Naf, check the filesystem for existence of naflogs. + # If so, archive the logs before you start using the system. + if File.directory?(Naf::LOGGING_ROOT_DIRECTORY + "/naf") + # Each archive will have a unique path based on the time archived + time = Time.zone.now.to_s + FileUtils.mkdir_p(Naf::LOGGING_ROOT_DIRECTORY + Naf::LOGGING_ARCHIVE_DIRECTORY + "/#{time}") + + puts "Moving naf logs into archive directory: #{Naf::LOGGING_ROOT_DIRECTORY + Naf::LOGGING_ARCHIVE_DIRECTORY}/#{time.gsub(' ', '\ ')}" + # Move the naf logs into the archive directory + system "mv #{Naf::LOGGING_ROOT_DIRECTORY}/naf " + + "#{Naf::LOGGING_ROOT_DIRECTORY + Naf::LOGGING_ARCHIVE_DIRECTORY}/#{time.gsub(' ', '\ ')}" + end + end + end + namespace :db do desc "Custom migrate task, connects to correct database, migrations found in db/naf/migrate" task migrate: :environment do if using_another_database? and naf_migrations.size > 0 puts "Running naf migrations with database configuration: #{naf_environment}"