Ektorp
Some assembly required.
Ektorp is a node.js library and command-line utility for building your CouchDB.
Project Status
Ektorp is incomplete but we have a number of tests, and most of them are passing. :-)
Using Ektorp
From the command-line:
-
Install ektorp globally:
$ npm install -g ektorp
-
Run ektorp:
$ ektorp http://localhost:5984/new_db ./migrations
-
Relax!
From your own code:
To integrate ektorp and control more aspects of the migration:
-
Install ektorp (doesn't need to be installed globally if you don't want to use the CLI tool):
$ npm install ektorp
-
Leverage ektorp in your own bootstrap script:
var ektorp = require('ektorp');
//pass the url to the DB you want to upgrade, and the path to migrations:
var migrator = ektorp('http://localhost:5984/new_db', './migrations');
migrator.on('done', function(){ console.log('Migrations are done!'); });
//cause the migrator to start.
migrator.start();
How do I write a migration?
Here's one way that is supported (there are others that will be documented soon):
-
Create a directory:
$ mkdir ./migrations
-
Make a migration:
$ cd ./migrations
$ touch 201401310849_first_migration.json
-
You can put a JSON array or object in 201401310849_first_migration.json
, it will be pushed to the database when you run ektorp
.