Index: trunk/ippToPsps/perl/ippToPsps/IppToPspsDb.pm
===================================================================
--- trunk/ippToPsps/perl/ippToPsps/IppToPspsDb.pm	(revision 28759)
+++ trunk/ippToPsps/perl/ippToPsps/IppToPspsDb.pm	(revision 28813)
@@ -59,6 +59,4 @@
     my ($self, $batchId, $expId, $processed, $published, $totalDetections) = @_;
 
-print "HJHJH '$batchId', '$expId', '$processed', '$published', '$totalDetections'\n";
-
 if (!$totalDetections) {$totalDetections = -1;}
 
@@ -118,5 +116,5 @@
     $batchId++;
 
-    my $query = $self->{_db}->prepare(<<SQL);
+    $query = $self->{_db}->prepare(<<SQL);
     INSERT INTO batches
         (batch_id, exp_id, survey_id, batch_type)
@@ -142,5 +140,5 @@
 
     my $currentRevision = -1;
-    my $latestRevision = 4;
+    my $latestRevision = 5;
 
     while ($currentRevision != $latestRevision) {
@@ -153,4 +151,5 @@
         elsif ($currentRevision == 2) {$self->createRevision_3();}
         elsif ($currentRevision == 3) {$self->createRevision_4();}
+        elsif ($currentRevision == 4) {$self->createRevision_5();}
     }
 }
@@ -164,5 +163,5 @@
     my ($self) = @_;
 
-    print "* Creating revision 1 of '$dbname'\n";
+    print "* Creating revision 1 of '$self->{_dbName}'\n";
 
     my $query = $self->{_db}->prepare(<<SQL);
@@ -175,5 +174,5 @@
         $query->execute;
 
-    my $query = $self->{_db}->prepare(<<SQL);
+    $query = $self->{_db}->prepare(<<SQL);
     CREATE TABLE batches (
             batch_id BIGINT NOT NULL, 
@@ -192,5 +191,5 @@
         $query->execute;
 
-    setRevision(1);
+    $self->setRevision(1);
 }
 
@@ -203,5 +202,5 @@
     my ($self) = @_;
 
-    print "* Creating revision 2 of '$dbname'\n";
+    print "* Creating revision 2 of '$self->{_dbName}'\n";
 
     my $query = $self->{_db}->prepare(<<SQL);
@@ -211,5 +210,5 @@
         $query->execute;
 
-    setRevision(2);
+    $self->setRevision(2);
 }
 
@@ -222,5 +221,5 @@
     my ($self) = @_;
 
-    print "* Creating revision 3 of '$dbname'\n";
+    print "* Creating revision 3 of '$self->{_dbName}'\n";
 
     my $query = $self->{_db}->prepare(<<SQL);
@@ -230,5 +229,5 @@
         $query->execute;
 
-    setRevision(3);
+    $self->setRevision(3);
 }
 
@@ -241,5 +240,5 @@
     my ($self) = @_;
 
-    print "* Creating revision 4 of '$dbname'\n";
+    print "* Creating revision 4 of '$self->{_dbName}'\n";
 
     my $query = $self->{_db}->prepare(<<SQL);
@@ -249,5 +248,23 @@
         $query->execute;
 
-    setRevision(4);
+    $self->setRevision(4);
+}
+
+#######################################################################################
+# 
+# Create revision 5 of the database 
+#
+#######################################################################################
+sub createRevision_5 {
+    my ($self) = @_;
+
+    print "* Creating revision 5 of '$self->{_dbName}'\n";
+
+    my $query = $self->{_db}->prepare(<<SQL);
+         CREATE INDEX batchesIndex ON batches (batch_id);
+SQL
+    $query->execute;
+
+    $self->setRevision(5);
 }
 
