From 7790f976ca9361d653dd9dbbf210ad5261f5b86a Mon Sep 17 00:00:00 2001 From: tgarip1957 Date: Sat, 20 May 2006 00:03:14 +0000 Subject: [PATCH] Alter auth_subfield_structure table as well incase somebody uses thisprior to updating database --- misc/marc_into_authority.pl | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/misc/marc_into_authority.pl b/misc/marc_into_authority.pl index 1df7f36377..08a2e4d130 100644 --- a/misc/marc_into_authority.pl +++ b/misc/marc_into_authority.pl @@ -24,7 +24,7 @@ $columns{$cols}=1; } ##Update the database if missing fields; - $dbh->do("LOCK TABLES auth_header WRITE auth_subfield_table READ"); + $dbh->do("LOCK TABLES auth_header WRITE, auth_subfield_structure WRITE , auth_subfield_table READ"); unless ($columns{'linkid'}){ my $sth=$dbh->prepare("ALTER TABLE auth_header ADD COLUMN `linkid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 "); $sth->execute(); @@ -33,7 +33,31 @@ unless ($columns{'marc'}){ my $sth=$dbh->prepare("ALTER TABLE auth_header ADD COLUMN `marc` BLOB NOT NULL DEFAULT 0 "); $sth->execute(); } - +###Chechk auth_subfield_structure as well. User may have forgotten to update database +my $sthcols=$dbh->prepare("show columns from auth_subfield_structure"); +$sthcols->execute(); +my %columns; +while (( my $cols)=$sthcols->fetchrow){ +$columns{$cols}=1; +} +##Update the database if missing fields; + $dbh->do("LOCK TABLES auth_header WRITE, auth_subfield_structure WRITE , auth_subfield_table READ"); +unless ($columns{'link'}){ +my $sth=$dbh->prepare("ALTER TABLE auth_subfield_structure ADD COLUMN `link` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 "); +$sth->execute(); +} +unless ($columns{'isurl'}){ +my $sth=$dbh->prepare("ALTER TABLE auth_subfield_structure ADD COLUMN `isurl` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 "); +$sth->execute(); +} +unless ($columns{'hidden'}){ +my $sth=$dbh->prepare("ALTER TABLE auth_subfield_structure ADD COLUMN `hidden` TINYINT(3) UNSIGNED NOT NULL ZEROFILL DEFAULT 000 "); +$sth->execute(); +} +unless ($columns{'kohafield'}){ +my $sth=$dbh->prepare("ALTER TABLE auth_subfield_structure ADD COLUMN `kohafield` VARCHAR(45) NOT NULL "); +$sth->execute(); +} my $sth=$dbh->prepare("select authid,authtypecode from auth_header "); $sth->execute(); -- 2.39.5