From 23c79b8229ee37978334e9225a33404dfa47c1ac Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Wed, 31 Oct 2007 13:37:58 -0500 Subject: [PATCH] bump to 3.00.00.017 : adding columns to zebraqueue 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 Signed-off-by: Joshua Ferraro --- installer/kohastructure.sql | 9 +++++---- misc/cronjobs/zebraqueue_start.pl | 8 ++++---- updater/updatedatabase | 12 +++++++++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/installer/kohastructure.sql b/installer/kohastructure.sql index 61bb52b152..10128cfb89 100644 --- a/installer/kohastructure.sql +++ b/installer/kohastructure.sql @@ -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; diff --git a/misc/cronjobs/zebraqueue_start.pl b/misc/cronjobs/zebraqueue_start.pl index 6395fbb90e..5d4046324e 100755 --- a/misc/cronjobs/zebraqueue_start.pl +++ b/misc/cronjobs/zebraqueue_start.pl @@ -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); } } diff --git a/updater/updatedatabase b/updater/updatedatabase index 44419e730e..0b5fd6264c 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -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 -- 2.39.5