Skip to content

Commit

Permalink
Drop database before restore
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagogodinho committed Nov 7, 2012
1 parent d9ecf53 commit 9c9fadc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Improvements

* Drop database before restore

* Accept symbol in dump and restore.

``` ruby
Expand Down
2 changes: 1 addition & 1 deletion lib/mongodb_clone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/mongodb_clone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c9fadc

Please sign in to comment.