=== added file 'tools/dhis2-tools-deb/pkg/usr/bin/dhis2-integrity' --- tools/dhis2-tools-deb/pkg/usr/bin/dhis2-integrity 1970-01-01 00:00:00 +0000 +++ tools/dhis2-tools-deb/pkg/usr/bin/dhis2-integrity 2013-07-03 13:20:36 +0000 @@ -0,0 +1,55 @@ +#!/bin/bash +# ____ __ ______________ +# / __ \/ / / / _/ ___/__ \ +# / / / / /_/ // / \__ \__/ / +# / /_/ / __ // / ___/ / __/ +# /_____/_/ /_/___//____/____/ +# +# DHIS2 instance startup script + +if [ "$#" -ne 1 ]; then + echo "usage: dhis2-integrity " + exit 1 +fi + + DBNAME=$1 + +TEXT[1]="Get category option combos without category options" +TEST[1]="select * from categoryoptioncombo where categoryoptioncomboid not in + (select distinct categoryoptioncomboid from categoryoptioncombos_categoryoptions);" + +TEXT[2]="Get category option combos without category combo" +TEST[2]="select * from categoryoptioncombo where categoryoptioncomboid not in + (select distinct categoryoptioncomboid from categorycombos_optioncombos);" + +TEXT[3]="Get category options without category option combos" +TEST[3]="select * from dataelementcategoryoption where categoryoptionid not in + (select distinct categoryoptionid from categoryoptioncombos_categoryoptions);" + +TEXT[4]="Get catetegory options without categories" +TEST[4]="select * from dataelementcategoryoption where categoryoptionid not in + (select distinct categoryoptionid from categories_categoryoptions);" + +TEXT[5]="Get categories without category options" +TEST[5]="select * from dataelementcategory where categoryid not in + (select distinct categoryid from categories_categoryoptions);" + +TEXT[6]="Get categories without category combos (not an error but could be removed)" +TEST[6]="select * from dataelementcategory where categoryid not in + (select distinct categoryid from categorycombos_categories);" + +TEXT[7]="Get category combos without categories" +TEST[7]="select * from categorycombo where categorycomboid not in + (select distinct categorycomboid from categorycombos_categories);" + +n=${#TEXT[@]} + +for ((i=1;i<=$n;i++)); +do + echo ====================================================================================================== + echo == "performing test: ${TEXT[$i]}" + echo == "sql: ${TEST[$i]}" + echo ====================================================================================================== + psql -c "${TEST[$i]}" $1 +done +