← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2002: Minor fix

 

------------------------------------------------------------
revno: 2002
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Mon 2010-08-30 06:55:00 +0200
message:
  Minor fix
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java


--
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
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2010-08-27 10:58:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2010-08-30 04:55:00 +0000
@@ -68,21 +68,34 @@
     @Transactional
     public void execute()
     {
-        executeSql( "drop table categoryoptioncomboname" );
-        executeSql( "drop table orgunitgroupsetstructure" );
-        executeSql( "drop table orgunitstructure" );
-        executeSql( "drop table orgunithierarchystructure" );
-        executeSql( "drop table orgunithierarchy" );
-        executeSql( "drop table datavalueaudit" );
-        executeSql( "drop table columnorder" );
-        executeSql( "drop table roworder" );
-        executeSql( "alter table dataelementcategoryoption drop column categoryid" );
-        // new is dimension_type
-        executeSql( "alter table reporttable drop column dimensiontype" ); 
+        // ---------------------------------------------------------------------
+        // Drop outdated tables
+        // ---------------------------------------------------------------------
+
+        executeSql( "DROP TABLE categoryoptioncomboname" );
+        executeSql( "DROP TABLE orgunitgroupsetstructure" );
+        executeSql( "DROP TABLE orgunitstructure" );
+        executeSql( "DROP TABLE orgunithierarchystructure" );
+        executeSql( "DROP TABLE orgunithierarchy" );
+        executeSql( "DROP TABLE datavalueaudit" );
+        executeSql( "DROP TABLE columnorder" );
+        executeSql( "DROP TABLE roworder" );
+        executeSql( "DROP TABLE sectionmembers" );
+        executeSql( "DROP TABLE reporttable_categoryoptioncombos" );
+        executeSql( "ALTER TABLE dataelementcategoryoption drop column categoryid" );
+        executeSql( "ALTER TABLE reporttable DROP column dimensiontype" );
+        executeSql( "ALTER TABLE categoryoptioncombo DROP COLUMN displayorder" );
+        executeSql( "ALTER TABLE dataelementcategoryoption DROP COLUMN shortname" );
+        executeSql( "ALTER TABLE section DROP COLUMN label" );
+        executeSql( "ALTER TABLE organisationunit DROP COLUMN polygoncoordinates" );
 
         // remove relative period type
-        executeSql( "delete from period where periodtypeid=(select periodtypeid from periodtype where name='Relative')" );
-        executeSql( "delete from periodtype where name='Relative'" );
+        executeSql( "DELETE FROM period WHERE periodtypeid=(select periodtypeid from periodtype where name='Relative')" );
+        executeSql( "DELETE FROM periodtype WHERE name='Relative'" );
+
+        // ---------------------------------------------------------------------
+        // Update tables for dimensional model
+        // ---------------------------------------------------------------------
         
         // categories_categoryoptions
         // set to 0 temporarily
@@ -109,9 +122,6 @@
         executeSql( "ALTER TABLE categorycombos_optioncombos ADD CONSTRAINT categorycombos_optioncombos_pkey PRIMARY KEY (categoryoptioncomboid)" );
         executeSql( "ALTER TABLE categorycombos_optioncombos DROP CONSTRAINT fk4bae70f697e49675" );
 
-        // categoryoptioncombo
-        executeSql( "ALTER TABLE categoryoptioncombo DROP COLUMN displayorder" );
-
         // categoryoptioncombos_categoryoptions
         // set to 0 temporarily
         int c3 = executeSql( "update categoryoptioncombos_categoryoptions SET sort_order=0 where sort_order is NULL OR sort_order=0" ); 
@@ -123,7 +133,6 @@
         executeSql( "ALTER TABLE categoryoptioncombos_categoryoptions ADD CONSTRAINT categoryoptioncombos_categoryoptions_pkey PRIMARY KEY (categoryoptioncomboid, sort_order)" );
 
         // dataelementcategoryoption
-        executeSql( "ALTER TABLE dataelementcategoryoption DROP COLUMN shortname" );
         executeSql( "ALTER TABLE dataelementcategoryoption DROP CONSTRAINT fk_dataelement_categoryid" );
         // executeSql( "ALTER TABLE dataelementcategoryoption DROP CONSTRAINT dataelementcategoryoption_name_key" ); will be maintained in transition period
         executeSql( "ALTER TABLE dataelementcategoryoption DROP CONSTRAINT dataelementcategoryoption_shortname_key" );
@@ -143,15 +152,8 @@
         }
         
         // update periodType field to ValidationRule
-        executeSql( "UPDATE validationrule SET periodtypeid = ( SELECT periodtypeid FROM periodtype WHERE name='Monthly')" );
-
-        //drop table reporttable_categoryoptioncombos
-        executeSql( "DROP table reporttable_categoryoptioncombos" );
-        
-        // drop unused label column from section table
-        executeSql( "ALTER TABLE section DROP COLUMN label" );
-        executeSql( "DROP TABLE sectionmembers" );
-        
+        executeSql( "UPDATE validationrule SET periodtypeid = (SELECT periodtypeid FROM periodtype WHERE name='Monthly')" );
+                
         // set varchar to text
         executeSql( "ALTER TABLE dataelement ALTER description TYPE text" );
         executeSql( "ALTER TABLE indicator ALTER description TYPE text" );
@@ -160,9 +162,6 @@
         executeSql( "ALTER TABLE expression ALTER expression TYPE text" );
         executeSql( "ALTER TABLE translation ALTER value TYPE text" );
         
-        //orgunit coord
-        executeSql( "ALTER TABLE organisationunit DROP COLUMN polygoncoordinates" );
-        
         //orgunit shortname uniqueness
         executeSql( "ALTER TABLE organisationunit DROP CONSTRAINT organisationunit_shortname_key" );
         
@@ -269,7 +268,7 @@
         }
         catch ( Exception ex )
         {
-            log.debug( ex );
+            log.info( ex );
 
             return -1;
         }