Class: CouchRest::Upgrade

Inherits:
Object
  • 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.



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

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.



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

def dbname
  @dbname
end

#newdbObject

Returns the value of attribute newdb.



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

def newdb
  @newdb
end

#olddbObject

Returns the value of attribute olddb.



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

def olddb
  @olddb
end

Instance Method Details

#clone!Object



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

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