Promoting view between environments
I wanted to find out what is the best practice/recommended way/tool to manage views across clusters.
For example I create a view in the admin tool in Dev and test it out. Then how do I export/import it to say Staging and then Production?
Any pointers would be much appreciated.
Here a small script that you can use as a starting point:
#!/bin/bash content=$(curl -X GET -H 'Content-Type: application/json' $1) curl -X PUT -H 'Content-Type: application/json' $2 -d "$content"
To execute it you can do
copy-view.sh "source" "destination"
For example:
./copy-view.sh "http://server1:8092/beer-sample/_design/beer" "http://server2:8092/new-bucket/_design/dev_beer"
I will encourage you to always put the destination in "developer" mode to test it before.
Thanks Tug. I've done something similar, and I'm actually maintaining the views as a JSON text file in the source control. I have a small program that loads those files and does a PUT on whichever couch URL I point it to. Seems to work so far, different developers on the team are also using it and can then work with source control and use the tool to sync up their local instances too.
Hello Rahulaga,
As far as I know this does not exist in Couchbase, but it should be easy to do it since you can retrieve and create Design View using simple REST call
You can find information about REST API here: http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-designdoc-api.html
So you can create a script or a program that uses this URL to get the view from one environment and push it into another one.
Let me know if you need more information.
Regards
Tug
Tug
@tgrall