added database patchs to the updater/updatedatabase script
authorfinlayt <finlayt>
Tue, 26 Mar 2002 05:08:52 +0000 (05:08 +0000)
committerfinlayt <finlayt>
Tue, 26 Mar 2002 05:08:52 +0000 (05:08 +0000)
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

index 570d7e2..b0a493a 100755 (executable)
@@ -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;