Class: CouchRest::Upgrade

Inherits:
Object show all
Defined in:
lib/couchrest/helper/upgrade.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dbname, old_couch, new_couch) ⇒ Upgrade

Returns a new instance of Upgrade.



4
5
6
7
8
9
# File 'lib/couchrest/helper/upgrade.rb', line 4

def initialize dbname, old_couch, new_couch
  @dbname = dbname
  @olddb = old_couch.database dbname
  @newdb = new_couch.database!(dbname)
  @bulk_docs = []
end

Instance Attribute Details

#dbnameObject

Returns the value of attribute dbname.



3
4
5
# File 'lib/couchrest/helper/upgrade.rb', line 3

def dbname
  @dbname
end

#newdbObject

Returns the value of attribute newdb.



3
4
5
# File 'lib/couchrest/helper/upgrade.rb', line 3

def newdb
  @newdb
end

#olddbObject

Returns the value of attribute olddb.



3
4
5
# File 'lib/couchrest/helper/upgrade.rb', line 3

def olddb
  @olddb
end

Instance Method Details

#clone!Object



10
11
12
13
14
15
16
17
18
# File 'lib/couchrest/helper/upgrade.rb', line 10

def clone!
  puts "#{dbname} - #{olddb.info['doc_count']} docs"
  streamer  = CouchRest::Streamer.new(olddb)
  streamer.view("_all_docs_by_seq") do |row|
    load_row_docs(row) if row
    maybe_flush_bulks
  end
  flush_bulks!
end