Versions Compared

Key

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

This page documents how to hash data while its already into postgres.

Hashing data from couchDB

...

Refer to the page Data migration from CouchDb for details on how to import data from couchDB into postgres.

Note: Skip step 7 and 8 on that page since we want to hash the data before migrating to the postgres model.
Enable the package uuid-ossp on postgres to enable random uuid generation on postgres. Run the below command on psql prompt

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

Run the below script to Create create a function for generating a random number within a range

Code Block
languagesql
titlerandom_between
CREATE FUNCTION random_between(low integer, high integer)
  RETURNS integer
STRICT
LANGUAGE plpgsql
AS $$
BEGIN
   RETURN floor(random()* (high-low + 1) + low);
END;
$$;


Hashing data from couchDB


Use the couch2pg tool to import couchDb data into a postgres as a single table.

Refer to the page Data migration from CouchDb for details on how to import data from couchDB into postgres.

Note: Skip step 7 and 8 on that page since we want to hash the data before migrating to the postgres model.

To hash the data use the below steps in sequential order. You must be having the couchdb table in the OpenSRP postgres database that will store the hashed data before starting

...