Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To Migrate data from couchDB

  1.  Download the tool couch2pg. You can use the below command to download
    git clone https://github.com/medic/medic-couch2pg.git
  2. Create a postgres database that will act as the staging database for migration to OpenSRP Postgres database
  3. Change directory to medic-couch2pg
  4.  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

  5. 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
  6. 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>
  7. 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
  8. Delete the table couchdb in the OpenSRP database. You can use the below
       drop table couchdb

...