Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glynnbird/couchmigrate
CouchDB command-line design document migration tool
https://github.com/glynnbird/couchmigrate
cli cloudant couchdb nodejs
Last synced: 24 days ago
JSON representation
CouchDB command-line design document migration tool
- Host: GitHub
- URL: https://github.com/glynnbird/couchmigrate
- Owner: glynnbird
- License: apache-2.0
- Created: 2015-02-25T09:31:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-20T12:51:06.000Z (3 months ago)
- Last Synced: 2024-10-12T22:12:53.665Z (about 1 month ago)
- Topics: cli, cloudant, couchdb, nodejs
- Language: JavaScript
- Size: 240 KB
- Stars: 13
- Watchers: 3
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# couchmigrate
A command-line tool to assist with the migration of CouchDB Design Documnents
## Installation
npm install -g couchmigrate
## UsageCreate a JSON file with your design document in e.g. dd.json
{
"_id": "_design/fetch",
"views": {
"byx": {
"map": "function (doc) {\n emit(doc.x, doc.y);\n }",
"reduce": "_stats"
}
},
"language": "javascript"
}or a JavaScript file that exports a design document object e.g.
```js
var map = function(doc) {
emit(doc.name, null);
};module.exports = {
_id: "_design/testy",
views: {
test1: {
map: map.toString(),
reduce: "_count"
}
}
};
```Then setup environment variables to point to your instance of CouchDB
export COUCH_URL=http://127.0.0.1:5984
orexport COUCH_URL=https://myusername:[email protected]
Then run `couchmigrate`:
couchmigrate --dd dd.json --db mydatabase
* dd - the path to the file containing the design documnet
* db - the name of the database(if the file extension of `dd` is '.json', it is expected to be a JSON document, if it ends in '.js' it is expected to be a JavaScript file that can be `require`d in)
If the design document is already present and is identical to the one in the file, no migration will occur, otherwise
* copy old design document to _OLD
* import new design document to _NEW
* trigger the view to make sure it builds
* poll the view to see if it has finished building
* copy _NEW to the real design document name
* delete _NEW
* delete _OLD
* exitIn other words, couchmigrate will only return when the design document has been uploaded, built and has been moved into place.
## IAM Auth
Alternatively, if you are using IAM authentication with IBM Cloudant, then supply two environment variables:
- `COUCH_URL` - the URL of your Cloudant host e.g. `https://myhost.cloudant.com` (note absence of username and password in URL).
- `IAM_API_KEY` - the IAM API KEY e.g. `ABC123515-151215`.