jchris (owner)

Revisions

gist: 79269 Download_button fork
public
Public Clone URL: git://gist.github.com/79269.git
Embed All Files: show embed
couchdb_upgrade.rb #
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
28
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