3 # This script will check for required updates to the database. Would also be a
4 # good idea to offer to do a backup at this time...
17 my $sth=$dbh->prepare("show tables");
19 while (my ($table) = $sth->fetchrow) {
24 # Add tables for virtual bookshelf management
26 unless ($tables{'shelfcontents'}) {
27 print "Adding shelfcontents table...\n";
28 my $sti=$dbh->prepare("create table shelfcontents (shelfnumber int not null, itemnumber int not null, flags int)");
31 unless ($tables{'bookshelf'}) {
32 print "Adding bookshelf table...\n";
33 my $sti=$dbh->prepare("create table bookshelf (shelfnumber int auto_increment primary key, shelfname char(255))");
37 # Add tables required by Z-3950 scripts
39 unless ($tables{'z3950queue'}) {
40 print "Adding z3950queue table...\n";
41 my $sti=$dbh->prepare("create table z3950queue (id int auto_increment primary key, term text, type char(10), startdate int, enddate int, done smallint, results longblob, numercords int, servers text, identifier char(30))");
45 unless ($tables{'z3950results'}) {
46 print "Adding z3950results table...\n";
47 my $sti=$dbh->prepare("create table z3950results (id int auto_increment primary key, queryid int, server char(255), startdate int, enddate int, results longblob, numrecords int, numdownloaded int, highestseen int, active smallint)");
50 unless ($tables{'z3950servers'}) {
51 print "Adding z3950servers table...\n";
52 my $sti=$dbh->prepare("create table z3950servers (host char(255), port int, db char(255), userid char(255), password char(255), name text, id int, checked smallint, rank int)");
54 $sti=$dbh->prepare("insert into z3950servers values ('z3950.loc.gov', 7090, 'voyager', '', '', 'Library of Congress', 1, 1, 1)");
60 # Get list of columns from biblioitems table
62 my $sth=$dbh->prepare("show columns from biblioitems");
64 while (my ($column, $type, $null, $key, $default, $extra) = $sth->fetchrow) {
65 $types{$column}=$type;
67 unless ($types{'lccn'}) {
68 # Add LCCN field to biblioitems db
69 print "Adding lccn field to biblioitems table...\n";
70 my $sti=$dbh->prepare("alter table biblioitems add column lccn char(25)");
73 unless ($types{'marc'}) {
74 # Add MARC field to biblioitems db (not used anymore)
75 print "Adding marc field to biblioitems table...\n";
76 my $sti=$dbh->prepare("alter table biblioitems add column marc text");
80 # Get list of columns from biblioitems table
83 my $sth=$dbh->prepare("show columns from items");
85 while (my ($column, $type, $null, $key, $default, $extra) = $sth->fetchrow) {
86 $itemtypes{$column}=$type;
89 unless ($itemtypes{'barcode'} eq 'varchar(20)') {
90 $itemtypes{'barcode'}=~/varchar\((\d+)\)/;
93 print "Setting maximum barcode length to 20 (was $oldlength).\n";
94 my $sti=$dbh->prepare("alter table items change barcode barcode varchar(20) not null");