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>
-- 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;
### 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 =?");
## 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;
}
# 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);
}
}
}
$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");
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