This page illustrates how to migrate data from OpenMRS to OpenSRP and Keycloak.
From version 2.2.x and above OpenSRP does not have any direct dependency on OpenMRS. Locations, team, team members were moved to OpenSRP while Users were moved to Keycloak
Location Tags
Get the location tags from OpenMRS and import to OpenSRP
TODO add steps
Locations
Get the secure directory that mysql permits to export data. Otherwise when the response returned by the following command is NULL
create the directory and set the secure_file_priv = /var/lib/mysql-files/
property in your mysql.conf
or mariadb.conf
file.
mysql> SELECT @@global.secure_file_priv; +---------------------------+ | @@global.secure_file_priv | +---------------------------+ | /var/lib/mysql-files/ | +---------------------------+
Setting secure_file_priv
Run the following commands to create the directory used for importing and exporting data to and from mysql.
cd /var/lib/ mkdir /var/lib/mysql-files/ chown mysql:mysql mysql-files chmod 750 mysql-files
Exporting locations
Export locations from OpenMRS to csv format by executing the below query
select 'id','name','parentId','status','version','geographicLevel','id','name' union all select l.uuid id ,l.name,p.uuid parentId,'Active' status ,0 version,0 geographicLevel,t.location_tag_id id, t.name as name from location l left join location p on p.location_id=l.parent_location left join location_tag_map tm on l.location_id=tm.location_id left join location_tag t on t.location_tag_id=tm.location_tag_id where l.retired=0 INTO OUTFILE '/var/lib/mysql-files/locations.csv' FIELDS ENCLOSED BY '"' TERMINATED BY ',' LINES TERMINATED BY '\r\n';
Use the generated csv and format to get the Location JSON that can be posted to the location endpoint
Use the below JSON template on https://www.convertcsv.com/csv-to-json.htm. Select the option Step 4: Create Custom Output via Template
{lb} "{h1}":"{f1}" , "type" :"Feature" , "properties": { "{h2}":"{f2}", "{h3}":"{(f3)==""?"null":f3}", "{h4}":"{f4}", "{h5}":{(f5)==""?"null":f5}, "{h6}":{(f6)==""?"null":f6} }, "locationTags":[ { "{h7}":"{f7}" , "{h8}":"{(f8)==""?"null":f8}" }] {rb}
Download the JSON and POST to the location batch save endpoint `rest/location/add?is_jurisdiction=true`. The body should be JSON array of locations
Teams
Team Members
Users
TODO add steps