You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2011/10/20 17:12:29 UTC

[Couchdb Wiki] Update of "How_to_deploy_view_changes_in_a_live_environment" by NilsBreunese

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "How_to_deploy_view_changes_in_a_live_environment" page has been changed by NilsBreunese:
http://wiki.apache.org/couchdb/How_to_deploy_view_changes_in_a_live_environment?action=diff&rev1=1&rev2=2

Comment:
Added info on creating a backup before the switchover and some general cleanup

- When needing to upload changes to existing design docs, to avoid having everything hang for potentially hours while generating the views - follow the descriptions below:
+ When needing to upload changes to an existing design document, to avoid having everything hang for potentially hours while generating the views - follow the descriptions below:
  
  == Background information: ==
+ 
- CouchDb places view generated data in files named based on the design docs contents (not name, id, revision). This means that 2 design docs with identical contents will share view files.
+ CouchDB places view indexes in files named based on the design docs contents (not name, id, revision). This means that 2 design docs with identical view code will share view index files.
  
  == Approach: ==
  
  '''Example:'''
- http://localhost:5984/mydb/_design/users needs to be updated with a new view
+ http://localhost:5984/datanase/_design/ddoc needs to be updated
  
  So the simple approach is:
-  1. Upload the updated design doc to _design/users_tmp
+  1. Upload the updated design doc to _design/ddoc-new
-  2. query the new views (to trigger generation)
+  2. Query a view in _design/ddoc-new to trigger view index generation
-  3. when generation is complete - copy _design/users_tmp to _design/users. This will cause the already built index to be shared by the 2 views.
+  3. When view index generation is complete - copy _design/ddoc-new to _design/ddoc. This will cause the already built indexes to be shared by both design documents.
-  4. delete _design/users_tmp at your discretion (or keep it in place for the next release)
+  4. Delete _design/ddoc-new at your discretion (or keep it in place for the next release)
+ 
+ If you copy _design/ddoc to _design/ddoc-old before copying _design/ddoc-new to _design/ddoc you can also easily roll back to the previous design document in case the update causes any trouble.
  
  To copy a document use:
-  curl -X COPY <url to source> -H "Destination: <url to dest>"
+  curl -X COPY <URL of source design document> -H "Destination: <ID of destination design document>"
  
- So for our example it would be
-  curl -X COPY http://localhost:5984/mydb/_design/users_tmp -H "Destination: http://localhost:5984/mydb/_design/users"
+ To copy http://localhost:5984/database/_design/ddoc-new to http://localhost:5984/database/_design/ddoc:
+  curl -X COPY http://localhost:5984/database/_design/ddoc-new -H "Destination: _design/ddoc"
  
  '''Note: This approach will work for normal couch views, couchdb-lucene views (fulltext), and should also work for bigcouch clusters - to my understanding'''