Module CouchRest::Model::Designs::Migrations
In: lib/couchrest/model/designs/migrations.rb

Design Document Migrations Support

A series of methods used inside design documents in order to perform migrations.

Methods

migrate   migrate!  

Public Instance methods

Migrate the design document preventing downtime on a production system. Typically this will be used when auto updates are disabled.

Steps taken are:

 1. Compare the checksum with the current version
 2. If different, create a new design doc with timestamp
 3. Wait until the view returns a result
 4. Copy over the original design doc

If a block is provided, it will be called with the result of the migration:

 * :no_change - Nothing performed as there are no changes.
 * :created   - Add a new design doc as non existed
 * :migrated  - Migrated the existing design doc.

This can be used for progressivly printing the results of the migration.

After completion, either a "cleanup" Proc object will be provided to finalize the process and copy the document into place, or simply nil if no cleanup is required. For example:

    print "Synchronising Cat model designs: "
    callback = Cat.design_doc.migrate do |res|
      puts res.to_s
    end
    if callback
      puts "Cleaning up."
      callback.call
    end

Perform a single migration and inmediatly request a cleanup operation:

    print "Synchronising Cat model designs: "
    Cat.design_doc.migrate! do |res|
      puts res.to_s
    end

[Validate]