To Migrate data from couchDB
- Download the tool couch2pg. You can use the below command to download
git clone https://github.com/medic/medic-couch2pg.git
- Create a postgres database that will act as the staging database for migration to OpenSRP Postgres database
- Change directory to
medic-couch2pg
- Execute the below on the terminal to start the couch2pg tool. Fill the correct params in the placeholders
export POSTGRESQL_URL=postgresql://<postgres_username>:<postgres_password>@localhost:5432/<postgres<couch2pg_postgres_database>
export COUCHDB_URL=http://<couch_username>:<couch_password>@localhost:5984/<couch_database>
export COUCH2PG_SLEEP_MINS=120
export COUCH2PG_DOC_LIMIT=1000
export COUCH2PG_RETRY_COUNT=5
node index.js
- Wait after all the data has been uploaded on the postgres staging database. You should see "Run complete" on the terminal after the data import into postgres is completed. Example of output when tool finishes migrating data is illustrated below
- copy the table couchdb table from the staging postgres database above to the opensrp database. Use the command
pg_dump -t coucdb
<
couch2pg_postgres_database
><postgres_staging_database>
| psql <opensrp_database> Execute the scripts in the folder data_migration_scripts folder. Execute while connected to the postgres database
opensrp_database
opensrp/assets/migrations/data_migration_scripts
- Delete the table couchdb in the OpenSRP database. You can use the below
drop table couchdb
...