bump to 3.00.00.017 : adding columns to zebraqueue
authorPaul POULAIN <paul@koha-fr.org>
Wed, 31 Oct 2007 18:37:58 +0000 (13:37 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 1 Nov 2007 00:43:00 +0000 (19:43 -0500)
The zebraque_start scripts works, but it not friendly when you try to track what he did
as records are deleted after done.
This commit changes the behaviour : 2 columns are added done & timestamp.
done is set to 1 when a line have been done. And the timestamp contains the timestamp of the last action (either line creation if done=0 or operation if done=1)

should be helpfull to track problem.

the table will grow, but i'll add soon a DELETE FROM zebraqueue WHERE timestamp > 30 days or something like that

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
installer/kohastructure.sql
misc/cronjobs/zebraqueue_start.pl
updater/updatedatabase

index 61bb52b..10128cf 100644 (file)
@@ -1700,12 +1700,13 @@ CREATE TABLE `z3950servers` (
 -- Table structure for table `zebraqueue`
 --
 
-DROP TABLE IF EXISTS `zebraqueue`;
 CREATE TABLE `zebraqueue` (
   `id` int(11) NOT NULL auto_increment,
-  `biblio_auth_number` int(11) NOT NULL default 0,
-  `operation` varchar(20) NOT NULL default '',
-  `server` varchar(20) NOT NULL default '',
+  `biblio_auth_number` int(11) NOT NULL default '0',
+  `operation` char(20) NOT NULL default '',
+  `server` char(20) NOT NULL default '',
+  `done` int(11) NOT NULL default '0',
+  `time` timestamp NOT NULL default CURRENT_TIMESTAMP,
   PRIMARY KEY  (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
index 6395fbb..5d40463 100755 (executable)
@@ -13,7 +13,7 @@ use utf8;
 ### ZEBRA SERVER UPDATER
 ##Uses its own database handle
 my $dbh=C4::Context->dbh;
-my $readsth=$dbh->prepare("select id,biblio_auth_number,operation,server from zebraqueue");
+my $readsth=$dbh->prepare("SELECT id,biblio_auth_number,operation,server FROM zebraqueue WHERE done=0");
 #my $delsth=$dbh->prepare("delete from zebraqueue where id =?");
 
 
@@ -64,7 +64,7 @@ while (($id,$biblionumber,$operation,$server)=$readsth->fetchrow){
             ## it's Broken XML-- Should not reach here-- but if it does -lets protect ZEBRA
             if ($@){
                 warn $@;
-                my $delsth=$dbh->prepare("delete from zebraqueue where id =?");
+                my $delsth=$dbh->prepare("UPDATE zebraqueue SET done=1 WHERE id =?");
                 $delsth->execute($id);
                 next;
             }
@@ -82,14 +82,14 @@ while (($id,$biblionumber,$operation,$server)=$readsth->fetchrow){
         # so, delete everything for this biblionumber
         if ($operation eq 'delete_record') {
             print "deleting biblio deletion $biblionumber\n" if $verbose;
-            $delsth =$dbh->prepare("delete from zebraqueue where biblio_auth_number =?");
+            $delsth =$dbh->prepare("UPDATE zebraqueue SET done=1 WHERE biblio_auth_number =?");
             $delsth->execute($biblionumber);
         # if it's not a deletion, delete every pending specialUpdate for this biblionumber
         # in case the user add biblio, then X items, before this script runs
         # this avoid indexing X+1 times where just 1 is enough.
         } else {
             print "deleting special date for $biblionumber\n" if $verbose;
-            $delsth =$dbh->prepare("delete from zebraqueue where biblio_auth_number =? and operation='specialUpdate'");
+            $delsth =$dbh->prepare("UPDATE zebraqueue SET done=1 WHERE biblio_auth_number =? and operation='specialUpdate'");
             $delsth->execute($biblionumber);
         }
     }
index 44419e7..0b5fd62 100755 (executable)
@@ -505,7 +505,7 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
 }      
 
 $DBversion = "3.00.00.017";
-if (C4::Context->preference("Version") < TransformToNum($DBversion)) {                                                                                    
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     $dbh->do("ALTER TABLE action_logs DROP PRIMARY KEY");
        $dbh->do("ALTER TABLE action_logs ADD KEY  timestamp (timestamp,user)");
        $dbh->do("ALTER TABLE action_logs ADD action_id INT(11) NOT NULL FIRST");
@@ -515,6 +515,16 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
        SetVersion ($DBversion);
 }
 
+$DBversion = "3.00.00.018";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do("ALTER TABLE `zebraqueue` 
+                    ADD `done` INT NOT NULL DEFAULT '0',
+                    ADD `time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ; 
+            ");
+    print "Upgrade to $DBversion done (adding timestamp and done columns to zebraque table to improve problem tracking) added)\n";
+    SetVersion ($DBversion);
+}      
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table