public
Last active

  • Download Gist
couchdb_upgrade.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
require 'rubygems'
require 'couchrest'
 
# this is the CouchDB where all the old databases are
OLD_HOST = "http://127.0.0.1:5984"
 
# this is the CouchDB we want to copy to
NEW_HOST = "http://127.0.0.1:5985"
 
old_couch = CouchRest.new(OLD_HOST)
new_couch = CouchRest.new(NEW_HOST)
 
databases = old_couch.databases
 
databases.each do |dbname|
if new_couch.databases.include?(dbname)
puts "the database '#{dbname}' already exists on the target"
puts "patches welcome for picking this process up in the middle"
puts "for now if it fails in the middle you could just comment out these lines"
puts "but you'll do double work and end up with spurious conflicts"
puts
puts
else
upgrader = CouchRest::Upgrade.new(dbname, old_couch, new_couch)
upgrader.clone!
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.