0.0
No commit activity in last 3 years
No release in over 3 years
dbDeploy for couchdb
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.6.0

Runtime

>= 1.3.1
>= 1.3.1
>= 1.3.1
 Project Readme

deploy_mongo¶ ↑

deploy_mongo is db deploy tool for mongodb.

How to install¶ ↑

gem install deploy_mongo

Usage¶ ↑

deploy_mongo 'path/to/mongodb.yml' [rollback:(1|2|3|..|all)]
rollback:all

rollbacks all the deltas

Example¶ ↑

  • deploy_mongo/spec/mongodb.yml for mongodb.yml config file

  • deploy_mongo/spec/integration/deltas for delta files

Config Parameters¶ ↑

  • hostname: mongodb database server hostname>

  • port: mongodb server port number , by default 27017

  • delta_path: path/to/deltas folder relative to mongodb.yml

  • database: <couchdb database name>

  • mongo_shell_path: full path to mongo shell (can be found in mongodb install folder/bin

Delta File name format¶ ↑

<Delta Number>_<Description>.js
example :-  1_add_address_to_customer.js
            2_add_phone_to_customer.js
            11_update_phone_with_std_codes.js
            12_delete_customer_with_name_equal_to_name_1.js
            13_copy_and_create_new_customer.js

Delta File content format ¶ ↑

<java script command used to modify database>
//@undo
<java script rollback command used when rolling back applied delta.>

Delta File examples¶ ↑

Example for adding address field to all customers (1_add_address_to_customer.js)¶ ↑

db.customer.update({},{$set: {"address": "some address" } } , false , true );

//@undo

db.customer.update({},{$unset: {"address": 1}},false,true);

Example for modifying phone number of all customers (2_add_phone_to_customer.js)¶ ↑

db.customer.update({},{$set: {"phone": "897907979" } } , false , true )

//@undo

db.customer.update({},{$unset: {"phone": 1}},false,true)

Example for creating new document after copying details from another customer (13_copy_and_create_new_customer.js)¶ ↑

db.customer.find({ "name" : "name_2" }).forEach(create_customer); 
function create_customer(doc){
         delete doc._id;
         doc.name = "new name"; 
         db.customer.save(doc);
 }

 //@undo

 db.customer.remove({"name" : "new name"})

Example for deleteing a document (12_delete_customer_with_name_equal_to_name_1.js)¶ ↑

db.customer.remove({ "name" : "name_1" });

//@undo

db.customer.save({"name" : "name_1", "address" : "some address" , "phone" : "+9168687868" });