diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a8f433..66b5db0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Improvements +* Drop database before restore + * Accept symbol in dump and restore. ``` ruby diff --git a/lib/mongodb_clone.rb b/lib/mongodb_clone.rb index 2cd78fc..92487b6 100644 --- a/lib/mongodb_clone.rb +++ b/lib/mongodb_clone.rb @@ -44,7 +44,7 @@ def restore(environment = 'development', session = 'default') a = params.collect { |key, value| "-#{ key } #{ value }" if value }.compact.join(' ') - command = "mongorestore #{ a } #{ @path }" + command = "mongorestore --drop #{ a } #{ @path }" execute(command) end diff --git a/spec/mongodb_clone_spec.rb b/spec/mongodb_clone_spec.rb index 4419417..8bf7772 100644 --- a/spec/mongodb_clone_spec.rb +++ b/spec/mongodb_clone_spec.rb @@ -28,7 +28,7 @@ subject.id = '201210231843100200' subject.path = '/tmp/mongodb_clone_production/201210231843100200/mongodb_clone_production' subject.should_receive(:execute).with('mongodump -h mongodb_clone.example.com:27017 -d mongodb_clone_production -u mongodb_clone -p 12345678 -o /tmp/mongodb_clone_production/201210231843100200') - subject.should_receive(:execute).with('mongorestore -h localhost:27017 -d mongodb_clone_development /tmp/mongodb_clone_production/201210231843100200/mongodb_clone_production') + subject.should_receive(:execute).with('mongorestore --drop -h localhost:27017 -d mongodb_clone_development /tmp/mongodb_clone_production/201210231843100200/mongodb_clone_production') subject.dump.restore end