From 8c792b79175162a142b3ffa4651331b157072a3d Mon Sep 17 00:00:00 2001 From: finlayt Date: Tue, 26 Mar 2002 05:08:52 +0000 Subject: [PATCH] added database patchs to the updater/updatedatabase script changes the type of the datesent and datearrived fields in the branchtransfers table from date to datetime. completely re-organises the branchcategories table. As this has previously been unused it shouldnt effect anyone. --- updater/updatedatabase | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/updater/updatedatabase b/updater/updatedatabase index 570d7e2d17..b0a493ae76 100755 --- a/updater/updatedatabase +++ b/updater/updatedatabase @@ -104,6 +104,55 @@ unless ($itemtypes{'barcode'} eq 'varchar(20)') { } } +# extending the timestamp in branchtransfers... +my %branchtransfers; + +my $sth=$dbh->prepare("show columns from branchtransfers"); +$sth->execute; +while (my ($column, $type, $null, $key, $default, $extra) = $sth->fetchrow) { + $branchtransfers{$column}=$type; +} + +unless ($branchtransfers{'datesent'} eq 'datetime') { + print "Setting type of datesent in branchtransfers to datetime.\n"; + my $sti=$dbh->prepare("alter table branchtransfers change datesent datesent datetime"); + $sti->execute; +} + +unless ($branchtransfers{'datearrived'} eq 'datetime') { + print "Setting type of datearrived in branchtransfers to datetime.\n"; + my $sti=$dbh->prepare("alter table branchtransfers change datearrived datearrived datetime"); + $sti->execute; +} + +# changing the branchcategories table around... +my %branchcategories; + +my $sth=$dbh->prepare("show columns from branchcategories"); +$sth->execute; +while (my ($column, $type, $null, $key, $default, $extra) = $sth->fetchrow) { + $branchcategories{$column}=$type; +} + +unless ($branchcategories{'categorycode'} eq 'varchar(4)') { + print "Setting type of categorycode in branchcategories to varchar(4),\n and making the primary key.\n"; + my $sti=$dbh->prepare("alter table branchcategories change categorycode categorycode varchar(4) not null"); + $sti->execute; + $sti=$dbh->prepare("alter table branchcategories add primary key (categorycode)"); + $sti->execute; +} + +unless ($branchcategories{'branchcode'} eq 'varchar(4)') { + print "Setting type of branchcode in branchcategories to varchar(4).\n"; + my $sti=$dbh->prepare("alter table branchcategories change branchcode branchcode varchar(4)"); + $sti->execute; +} + +unless ($branchcategories{'codedescription'} eq 'text') { + print "Replacing branchholding in branchcategories with codedescription text.\n"; + my $sti=$dbh->prepare("alter table branchcategories change branchholding codedescription text"); + $sti->execute; +} $sth->finish; $dbh->disconnect; -- 2.39.2