From 2983976716c1f6979feea238ccee4364abc726a3 Mon Sep 17 00:00:00 2001 From: slef Date: Wed, 12 Nov 2003 16:14:42 +0000 Subject: [PATCH] lengthen cardnumber to 16 and make it unique --- updater/updatedatabase | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/updater/updatedatabase b/updater/updatedatabase index 06a6e96654..e868b16b40 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -762,9 +762,41 @@ foreach $table ( keys %fielddefinitions ) { } } -# Get list of columns from items table +# Get list of columns from borrowers table my %itemtypes; my %nullenabled; +$sth = $dbh->prepare("show columns from borrowers"); +$sth->execute; +while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ) +{ + $itemtypes{$column} = $type; + $nullenabled{$column} = $null; +} + +unless ( $itemtypes{'cardnumber'} eq 'varchar(20)' ) { + $itemtypes{'cardnumber'} =~ /varchar\((\d+)\)/; + my $oldlength = $1; + if ( $oldlength < 16 ) { + print "Setting maximum cardnumber length to 16 (was $oldlength) and marking unique.\n"; + my $sti = + $dbh->prepare( + "alter table borrowers change cardnumber cardnumber varchar(16)"); + $sti->execute; + $sti->finish; + $sti = + $dbh->prepare( + "alter table borrowers drop index cardnumber"); + $sti->execute; + $sti->finish; + $sti = + $dbh->prepare( + "alter table borrowers add unique(cardnumber)"); + $sti->execute; + $sti->finish; + } +} +# +# Get list of columns from items table $sth = $dbh->prepare("show columns from items"); $sth->execute; while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ) @@ -923,6 +955,9 @@ $sth->finish; exit; # $Log$ +# Revision 1.66 2003/11/12 16:14:42 slef +# lengthen cardnumber to 16 and make it unique +# # Revision 1.65 2003/11/06 15:07:11 tipaul # adding marc fields in deletedbiblio & deleteditems # -- 2.39.5