Skip to content

venkateshcm/deploy_couch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deploy_couch is db deploy tool for couchdb.

gem install deploy_couch
deploy_couch 'path/to/couchdb.yml' [rollback:(1|2|3|..|all)]
rollback:all

rollbacks all the deltas

deploy_couch/spec/couchdb.yml         for couchdb.yml config file
deploy_couch/spec/integration/deltas     for delta files
  • hostname: <couchdb database server hostname>

  • port: <couchdb server port number , by default 5984>

  • delta_path: < path/to/deltas folder relative to configdb.yml>

  • database: <couchdb database name>

  • doc_type_field: <field name used to identify the document type>

  • type_version_field: <deploy_couch uses this field to maintain type version of the document, you can configure the field name>

<Delta Number>_<Description>.yml
example :-  1_add_address_to_customer.yml
            2_add_phone_to_customer.yml
            11_update_phone_with_std_codes.yml
            12_delete_customer_with_name_equal_to_name_1.yml
            13_copy_and_create_new_customer.yml
  • type: document type, example: customer. By convention deploy_couch assumes there is a type field in each document which stores the type of document.

  • map_function: map function used to modify customer document.

    return value 'create' indicates creating/adding new document
    return value 'update' indicates updating the document with changes
    return value 'delete' indicates deleteing the document
    return value nul indicates ignore the document
  • rollback_function: rollback function used when rolling back applied delta. If there is need to get back to previous version.

type: customer
map_function:
           function map(doc)
           {
              doc.address = "some address";
              return 'update';
            }
rollback_function:
           function map(doc)
           {
              delete doc.address;
              return 'update';
           }
type: customer
map_function:
            function map(doc)
            {
                  doc.phone = '+91' + doc.phone;
                  return 'update';
             }
rollback_function:
             function map(doc)
             {
                doc.phone = doc.phone.substring(3);
                return 'update';
             }
type: customer
map_function:
             function map(doc)
             {
                if(doc.name == 'name_2')
                {
                   delete doc._id;
                   doc.name = 'new name';
                   return 'create';
                 }
                 return null;
              }
rollback_function:
              function map(doc)
              {
                 if(doc.name == 'new name')
                 return 'delete';
                 return null;
              }
type: customer
map_function:
             function map(doc)
             {
                if(doc.name == 'name_1')
                   return 'delete';
                return null;
             }
rollback_function:
             function map(doc)
             {
                if(doc.name == 'name_2')
                {
                     delete doc._id;
                     doc.name = 'name_1';
                     return 'create';
                 }
                 return null;
             }

About

DbDeploy for CouchDB

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages