Recreate ETL schema for an implementation

Clearing ETL schema and rows corresponding to it in the database. The next run of the ETL process will recreate the schema and database.

New (Webapp Based) Method

Enabling Analytics via Admin view in Webapp

ETL enabling and disabling for an organisation has now been changed to function via APIs called from the webapp. The act of enabling analytics for an org via the webapp admin view also creates the required job and schedules it to run immediately and every hour from then on (on a best effort basis*).

Ad hoc runs

If there is a need to run ETL for an organisation in an ad hoc fashion (to check if fixes to broken ETL for an org are working for example), you can disable and then enable analytics for that org. This will remove the previously existing job for the org and create a new one that will run immediately (within a minute on a best effort basis*).

Best effort basis

Subject to available resources on the server and currently running jobs if any.

Legacy Method

Ensure that the ETL process is not running

This you can do by disabling the cron job by commenting the job using the# and saving. Also, check that the ETL job is not running already by checking the java process.

sudo su openchs
# disable by commenting
crontab -e

For standalone organizations

select delete_etl_metadata_for_schema('$impl_schema', '$impl_db_user', '$impl_db_owner');
set role $impl_schema;  
drop schema $impl_schema cascade;

delete from entity_sync_status where db_user = '$impl_db_user';

delete from index_metadata where table_metadata_id 
	in (select id from table_metadata where schema_name = '$impl_schema');

delete from column_metadata where table_id 
	in (select id from table_metadata where schema_name = '$impl_schema');

delete from table_metadata  
		where schema_name = '$impl_schema';

For organization groups

select delete_etl_metadata_for_org('$impl_schema', '$impl_db_user');
set role openchs;  
drop schema $impl_schema cascade;

delete from entity_sync_status where schema_name = '$impl_schema';

delete from index_metadata where table_metadata_id 
	in (select id from table_metadata where schema_name = '$impl_schema');

delete from column_metadata where table_id 
	in (select id from table_metadata where schema_name = '$impl_schema');

delete from table_metadata where schema_name = '$impl_schema';

Run ETL process for an organization/group or for all the organization/groups.

sudo su openchs;
cd /opt/avni-etl/

### Check for one schema (organisation or organisation group)
./start.sh $schema_name

### Check for all organisations
./start.sh

Enable the cron

Uncomment the commented cron job.