Library and cli for one-way replicating CouchDB databases to PostgreSQL 9.4+.
Required database setup
couch2pg supports PostgreSQL 9.4 and greater. The user passed in the postgres url needs to have full creation rights on the given database.
Example cli usage
npm install -g couch2pg` couch2pg --help
Example library usage
npm install --save couch2pg
var PG_URL = 'postgres://localhost:5432/db-name'COUCHDB_URL = '';var couchdb = COUCHDB_URLdb = PG_URL;var couch2pg =migrator = couch2pgimporter = couch2pg;return;
migrator ensures that the named DB is ready to use,
importAll imports all docs from CouchDB into the postgres. If it's been run before against this DB it will pick up from where it left off last time.
Enjoy your tests with:
Some environment variables that may be required for the integration tests to run correctly:
INT_PG_HOST: postgres host, defaults to
INT_PG_PORT: postgres port, defaults to
INT_PG_USER: postgres user, defaults to none (system default). This user must be able to create databases on the given host.
INT_PG_PASS: user's password, defaults to none (system default)
INT_PG_DB: test databse to use, defaults to
INT_COUCHDB_URL: url to test couchdb, defaults to
http://admin:pass@localhost:5894/medic-analytics-test. The user must have the ability to destory and create databases on that host.
You may be able to get away with not setting any of these, or only needing to set some of these depending on your development environment.
NB: the integration tests destroy and re-create the given databases each time they are run. Use test databases.