← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9120: Added missing primary keys on certain resource tables

 

------------------------------------------------------------
revno: 9120
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-11-25 22:24:19 +0100
message:
  Added missing primary keys on certain resource tables
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.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-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java	2012-11-25 20:54:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/resourcetable/ResourceTableStore.java	2012-11-25 21:24:19 +0000
@@ -45,7 +45,7 @@
     final String TABLE_NAME_ORGANISATION_UNIT_STRUCTURE = "_orgunitstructure";
     final String TABLE_NAME_DATA_ELEMENT_STRUCTURE = "_dataelementstructure";
     final String TABLE_NAME_PERIOD_STRUCTURE = "_periodstructure";
-    final String TABLE_NAME_PERIOD_NO_DISAGGREGATION_STRUCTURE = "_period_no_disaggregation_structure";
+    final String TABLE_NAME_PERIOD_NO_DISAGGREGATION_STRUCTURE = "_period_no_disagg_structure";
     
     // -------------------------------------------------------------------------
     // OrganisationUnitStructure

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java	2012-11-25 20:54:29 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/jdbc/JdbcResourceTableStore.java	2012-11-25 21:24:19 +0000
@@ -82,16 +82,15 @@
         StringBuilder sql = new StringBuilder();
         
         sql.append( "CREATE TABLE " ).append( TABLE_NAME_ORGANISATION_UNIT_STRUCTURE ).
-            append( " ( organisationunitid INTEGER NOT NULL, level INTEGER, " );
+            append( " ( organisationunitid INTEGER NOT NULL PRIMARY KEY, level INTEGER" );
         
         for ( int k = 1 ; k <= maxLevel; k++ )
         {
             String levelName = "idlevel" + String.valueOf( k );
-            sql.append ( levelName );
-            sql.append (" INTEGER, ");
+            sql.append( ", " ).append ( levelName ).append (" INTEGER");
         }
         
-        sql.append( "PRIMARY KEY ( organisationunitid ) );" );
+        sql.append( ");" );
         
         log.info( "Create organisation unit structure table SQL: " + sql );
         
@@ -114,7 +113,7 @@
         }
         
         final String sql = "CREATE TABLE " + TABLE_NAME_CATEGORY_OPTION_COMBO_NAME + 
-            " ( categoryoptioncomboid INTEGER NOT NULL, categoryoptioncomboname VARCHAR(250) )";
+            " ( categoryoptioncomboid INTEGER NOT NULL PRIMARY KEY, categoryoptioncomboname VARCHAR(250) )";
         
         log.info( "Create category option combo name table SQL: " + sql );
         
@@ -217,7 +216,7 @@
         }
         
         final String sql = "CREATE TABLE " + TABLE_NAME_DATA_ELEMENT_STRUCTURE + 
-            " ( dataelementid INTEGER NOT NULL, dataelementname VARCHAR(250), periodtypeid INTEGER, periodtypename VARCHAR(250) )";
+            " ( dataelementid INTEGER NOT NULL PRIMARY KEY, dataelementname VARCHAR(250), periodtypeid INTEGER, periodtypename VARCHAR(250) )";
         
         log.info( "Create data element structure SQL: " + sql );
         
@@ -241,7 +240,7 @@
             // Do nothing, table does not exist
         }
         
-        String sql = "CREATE TABLE " + tableName + " (periodid INTEGER NOT NULL";
+        String sql = "CREATE TABLE " + tableName + " (periodid INTEGER NOT NULL PRIMARY KEY";
         
         for ( PeriodType periodType : PeriodType.PERIOD_TYPES )
         {