[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/updater updatedatabase,1.4.2.1,1.4.2.2
From: |
Alan Millar |
Subject: |
[Koha-cvs] CVS: koha/updater updatedatabase,1.4.2.1,1.4.2.2 |
Date: |
Thu, 06 Jun 2002 12:51:24 -0700 |
Update of /cvsroot/koha/koha/updater
In directory usw-pr-cvs1:/tmp/cvs-serv28320
Modified Files:
Tag: rel-1-2
updatedatabase
Log Message:
Changed field additions to data-driven structure. Add abstract
column to biblio. Make deletedbiblio and deletedbiblioitems
consistent with biblio and biblioitems
Index: updatedatabase
===================================================================
RCS file: /cvsroot/koha/koha/updater/updatedatabase,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -C2 -r1.4.2.1 -r1.4.2.2
*** updatedatabase 29 May 2002 15:14:09 -0000 1.4.2.1
--- updatedatabase 6 Jun 2002 19:51:22 -0000 1.4.2.2
***************
*** 18,24 ****
use C4::Database;
! my %existingtables; # tables already in database
! my %types;
! my $table;
#-------------------
--- 18,32 ----
use C4::Database;
! my $debug=1;
!
! my (
! $sth,
! $query,
! %existingtables, # tables already in database
! %types,
! $table,
! $column,
! $type, $null, $key, $default, $extra,
! );
#-------------------
***************
*** 56,59 ****
--- 64,77 ----
);
+ my %requirefields=(
+ biblio=>{ 'abstract' => 'text' },
+ deletedbiblio=>{ 'abstract' => 'text' },
+ biblioitems=>{ 'lccn' => 'char(25)',
+ 'marc' => 'text' },
+ deletedbiblioitems=>{ 'lccn' => 'char(25)',
+ 'marc' => 'text' },
+ branchtransfers=>{ 'datearrived' => 'datetime' },
+ );
+
#-------------------
# Initialize
***************
*** 74,78 ****
# Collect all tables into a list
! my $sth=$dbh->prepare("show tables");
$sth->execute;
while (my ($table) = $sth->fetchrow) {
--- 92,96 ----
# Collect all tables into a list
! $sth=$dbh->prepare("show tables");
$sth->execute;
while (my ($table) = $sth->fetchrow) {
***************
*** 82,85 ****
--- 100,104 ----
# Now add any missing tables
foreach $table ( keys %requiretables ) {
+ print "Checking $table table...\n" if $debug;;
unless ($existingtables{$table} ) {
print "Adding $table table...\n";
***************
*** 93,97 ****
} # unless exists
} # foreach
- exit;
unless ($existingtables{'z3950servers'}) {
--- 112,115 ----
***************
*** 121,148 ****
# Columns
! # Get list of columns from biblioitems table
!
! my $sth=$dbh->prepare("show columns from biblioitems");
! $sth->execute;
! while (my ($column, $type, $null, $key, $default, $extra) = $sth->fetchrow) {
! $types{$column}=$type;
! }
! unless ($types{'lccn'}) {
! # Add LCCN field to biblioitems db
! print "Adding lccn field to biblioitems table...\n";
! my $sti=$dbh->prepare("alter table biblioitems
! add column lccn char(25)");
! $sti->execute;
! }
! unless ($types{'marc'}) {
! # Add MARC field to biblioitems db (not used anymore)
! print "Adding marc field to biblioitems table...\n";
! my $sti=$dbh->prepare("alter table biblioitems
! add column marc text");
! $sti->execute;
! }
!
! # Get list of columns from biblioitems table
my %itemtypes;
--- 139,170 ----
# Columns
+ foreach $table ( keys %requirefields ) {
+ print "Check table $table\n";
+ $sth=$dbh->prepare("show columns from $table");
+ $sth->execute();
+ undef %types;
+ while ( ($column, $type, $null, $key, $default, $extra)
+ = $sth->fetchrow) {
+ $types{$column}=$type;
+ } # while
+ foreach $column ( keys %{ $requirefields{$table} } ) {
+ print " Check column $column\n";
+ if ( ! $types{$column} ) {
+ # column doesn't exist
+ print "Adding $column field to $table table...\n";
+ $query="alter table $table
+ add column $column " . $requirefields{$table}->{$column} ;
+ print "Execute: $query\n" if $debug;
+ my $sti=$dbh->prepare($query);
+ $sti->execute;
+ if ($sti->err) {
+ print "**Error : $sti->errstr \n";
+ $sti->finish;
+ } # if error
+ } # if column
+ } # foreach column
+ } # foreach table
! # Get list of columns from items table
my %itemtypes;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/updater updatedatabase,1.4.2.1,1.4.2.2,
Alan Millar <=