lib/tasks/db-sync.rake in db-sync-0.0.4 vs lib/tasks/db-sync.rake in db-sync-0.0.5
- old
+ new
@@ -1,13 +1,25 @@
namespace :db do
namespace :sync do
desc 'Download data from the databse into files.'
task down: :environment do
- Db::Sync.sync_down
+ synchronizer = Db::Sync.new
+ synchronizer.sync_down
end
desc 'Upload data from the files into the database.'
task up: :environment do
- Db::Sync.sync_up
+ commit = ENV['commit'] == 'true'
+ synchronizer = Db::Sync.new
+ sync_up_and_print(synchronizer, commit)
+ if !commit && synchronizer.log.present?
+ print "Commit Changes? [y/n]\n"
+ sync_up_and_print(synchronizer, true) if STDIN.gets.chomp == 'y'
+ end
end
end
+end
+
+def self.sync_up_and_print(synchronizer, commit)
+ synchronizer.sync_up(commit)
+ print synchronizer.log.join("\n") + "\n"
end