← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11322: Capturing Lars' integrity tests in utility tool

 

------------------------------------------------------------
revno: 11322
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-07-03 14:20:36 +0100
message:
  Capturing Lars' integrity tests in utility tool
added:
  tools/dhis2-tools-deb/pkg/usr/bin/dhis2-integrity


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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 <instance name>"
+   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
+