[Koha-cvs] CVS: koha/updater updatedatabase,1.85,1.86

Paul POULAIN tipaul at users.sourceforge.net
Tue Jun 22 13:31:02 CEST 2004


Update of /cvsroot/koha/koha/updater
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16736/updater

Modified Files:
	updatedatabase 
Log Message:
adding -s (silent) flag, to have a silent install.
only updater will be verbose


Index: updatedatabase
===================================================================
RCS file: /cvsroot/koha/koha/updater/updatedatabase,v
retrieving revision 1.85
retrieving revision 1.86
diff -C2 -r1.85 -r1.86
*** updatedatabase	17 Jun 2004 15:19:44 -0000	1.85
--- updatedatabase	22 Jun 2004 11:30:57 -0000	1.86
***************
*** 18,22 ****
  # CPAN modules
  use DBI;
! 
  # Koha modules
  use C4::Context;
--- 18,22 ----
  # CPAN modules
  use DBI;
! use Getopt::Long;
  # Koha modules
  use C4::Context;
***************
*** 38,43 ****
  );
  
  my $dbh = C4::Context->dbh;
! print "connected to your DB. Checking & modifying it\n";
  
  #-------------------
--- 38,47 ----
  );
  
+ my $silent;
+ GetOptions(
+ 	's' =>\$silent
+ 	);
  my $dbh = C4::Context->dbh;
! print "connected to your DB. Checking & modifying it\n" unless $silent;
  
  #-------------------
***************
*** 757,761 ****
  $mysqlversion = $1;
  if ( $mysqlversion ge '3.23' ) {
!     print "Could convert to MyISAM database tables...\n";
  }
  
--- 761,765 ----
  $mysqlversion = $1;
  if ( $mysqlversion ge '3.23' ) {
!     print "Could convert to MyISAM database tables...\n" unless $silent;
  }
  
***************
*** 774,778 ****
  foreach $table ( keys %requiretables ) {
      unless ( $existingtables{$table} ) {
! 	print "Adding $table table...\n";
          my $sth = $dbh->prepare("create table $table $requiretables{$table}");
          $sth->execute;
--- 778,782 ----
  foreach $table ( keys %requiretables ) {
      unless ( $existingtables{$table} ) {
! 	print "Adding $table table...\n" unless $silent;
          my $sth = $dbh->prepare("create table $table $requiretables{$table}");
          $sth->execute;
***************
*** 787,791 ****
  foreach $table ( keys %dropable_table ) {
  	if ( $existingtables{$table} ) {
! 		print "Dropping unused table $table\n" if $debug;
  		$dbh->do("drop table $table");
  		if ( $dbh->err ) {
--- 791,795 ----
  foreach $table ( keys %dropable_table ) {
  	if ( $existingtables{$table} ) {
! 		print "Dropping unused table $table\n" if $debug and not $silent;
  		$dbh->do("drop table $table");
  		if ( $dbh->err ) {
***************
*** 796,800 ****
  unless ( $existingtables{'z3950servers'} ) {
  	#MJR: added syntax entries to close bug 624
!     print "Adding z3950servers table...\n";
      my $sti = $dbh->prepare( "create table z3950servers (
  										host char(255),
--- 800,804 ----
  unless ( $existingtables{'z3950servers'} ) {
  	#MJR: added syntax entries to close bug 624
!     print "Adding z3950servers table...\n" unless $silent;
      my $sti = $dbh->prepare( "create table z3950servers (
  										host char(255),
***************
*** 822,826 ****
  unless ( $existingtables{'issuingrules'} ) {
  	$dbh->do("alter table categoryitem rename issuingrules");
! 	print "renaming categoryitem\n";
  }
  
--- 826,830 ----
  unless ( $existingtables{'issuingrules'} ) {
  	$dbh->do("alter table categoryitem rename issuingrules");
! 	print "renaming categoryitem\n" unless $silent;
  }
  
***************
*** 830,834 ****
  
  foreach $table ( keys %requirefields ) {
!     print "Check table $table\n" if $debug;
      $sth = $dbh->prepare("show columns from $table");
      $sth->execute();
--- 834,838 ----
  
  foreach $table ( keys %requirefields ) {
!     print "Check table $table\n" if $debug and not $silent;
      $sth = $dbh->prepare("show columns from $table");
      $sth->execute();
***************
*** 839,847 ****
      }    # while
      foreach $column ( keys %{ $requirefields{$table} } ) {
!         print "  Check column $column  [$types{$column}]\n" if $debug;
          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};
--- 843,851 ----
      }    # while
      foreach $column ( keys %{ $requirefields{$table} } ) {
!         print "  Check column $column  [$types{$column}]\n" if $debug and not $silent;
          if ( !$types{$column} ) {
  
              # column doesn't exist
!             print "Adding $column field to $table table...\n" unless $silent;
              $query = "alter table $table
  			add column $column " . $requirefields{$table}->{$column};
***************
*** 911,915 ****
  			}
  			$sth->execute($default);
! 			print "  Alter $field in $table\n";
  		}
  	}
--- 915,919 ----
  			}
  			$sth->execute($default);
! 			print "  Alter $field in $table\n" unless $silent;
  		}
  	}
***************
*** 931,935 ****
      my $oldlength = $1;
      if ( $oldlength < 16 ) {
!         print "Setting maximum cardnumber length to 16 (was $oldlength) and marking unique.\n";
          my $sti =
            $dbh->prepare(
--- 935,939 ----
      my $oldlength = $1;
      if ( $oldlength < 16 ) {
!         print "Setting maximum cardnumber length to 16 (was $oldlength) and marking unique.\n" unless $silent;
          my $sti =
            $dbh->prepare(
***************
*** 963,967 ****
      my $oldlength = $1;
      if ( $oldlength < 20 ) {
!         print "Setting maximum barcode length to 20 (was $oldlength).\n";
          my $sti =
            $dbh->prepare(
--- 967,971 ----
      my $oldlength = $1;
      if ( $oldlength < 20 ) {
!         print "Setting maximum barcode length to 20 (was $oldlength).\n" unless $silent;
          my $sti =
            $dbh->prepare(
***************
*** 978,982 ****
  {
  	if ($key_name eq 'barcode' && $non_unique eq 0) {
! 		print "dropping BARCODE index to enable empty barcodes\n";
  		$dbh->do("ALTER TABLE `items` DROP INDEX `barcode`");
  	}
--- 982,986 ----
  {
  	if ($key_name eq 'barcode' && $non_unique eq 0) {
! 		print "dropping BARCODE index to enable empty barcodes\n" unless $silent;
  		$dbh->do("ALTER TABLE `items` DROP INDEX `barcode`");
  	}
***************
*** 996,1000 ****
  	}
  }
! print "Creating fulltext index on bibliothesaurus\n" unless $exists;
  $dbh->do('create fulltext index category_2 on bibliothesaurus (category,freelib)') unless $exists;
  
--- 1000,1004 ----
  	}
  }
! print "Creating fulltext index on bibliothesaurus\n" unless $exists or $silent;
  $dbh->do('create fulltext index category_2 on bibliothesaurus (category,freelib)') unless $exists;
  
***************
*** 1011,1015 ****
  	}
  }
! print "Creating  index on z3950results\n" unless $exists;
  $dbh->do('create unique index query_server on z3950results (queryid,server)') unless $exists;
  
--- 1015,1019 ----
  	}
  }
! print "Creating  index on z3950results\n" unless $exists or $silent;
  $dbh->do('create unique index query_server on z3950results (queryid,server)') unless $exists;
  
***************
*** 1038,1042 ****
  
  unless ( $branchtransfers{'datesent'} eq 'datetime' ) {
!     print "Setting type of datesent in branchtransfers to datetime.\n";
      my $sti =
        $dbh->prepare(
--- 1042,1046 ----
  
  unless ( $branchtransfers{'datesent'} eq 'datetime' ) {
!     print "Setting type of datesent in branchtransfers to datetime.\n" unless $silent;
      my $sti =
        $dbh->prepare(
***************
*** 1046,1050 ****
  
  unless ( $branchtransfers{'datearrived'} eq 'datetime' ) {
!     print "Setting type of datearrived in branchtransfers to datetime.\n";
      my $sti =
        $dbh->prepare(
--- 1050,1054 ----
  
  unless ( $branchtransfers{'datearrived'} eq 'datetime' ) {
!     print "Setting type of datearrived in branchtransfers to datetime.\n" unless $silent;
      my $sti =
        $dbh->prepare(
***************
*** 1065,1069 ****
  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(
--- 1069,1073 ----
  unless ( $branchcategories{'categorycode'} eq 'varchar(4)' ) {
      print
! "Setting type of categorycode in branchcategories to varchar(4),\n and making the primary key.\n" unless $silent;
      my $sti =
        $dbh->prepare(
***************
*** 1078,1082 ****
  
  unless ( $branchcategories{'categoryname'} eq 'text' ) {
!     print "Changing branchcode in branchcategories to categoryname text.\n";
      my $sth =
        $dbh->prepare(
--- 1082,1086 ----
  
  unless ( $branchcategories{'categoryname'} eq 'text' ) {
!     print "Changing branchcode in branchcategories to categoryname text.\n" unless $silent;
      my $sth =
        $dbh->prepare(
***************
*** 1087,1091 ****
  unless ( $branchcategories{'codedescription'} eq 'text' ) {
      print
! "Replacing branchholding in branchcategories with codedescription text.\n";
      my $sth =
        $dbh->prepare(
--- 1091,1095 ----
  unless ( $branchcategories{'codedescription'} eq 'text' ) {
      print
! "Replacing branchholding in branchcategories with codedescription text.\n" unless $silent;
      my $sth =
        $dbh->prepare(
***************
*** 1106,1110 ****
  
  if ($items{'bulk'} eq "varchar(30)") {
!     print "  Setting callnumber in items table\n";
      my $sti =
        $dbh->prepare("ALTER TABLE `items` CHANGE `bulk` `itemcallnumber` VARCHAR( 30 ) DEFAULT NULL");
--- 1110,1114 ----
  
  if ($items{'bulk'} eq "varchar(30)") {
!     print "  Setting callnumber in items table\n" unless $silent;
      my $sti =
        $dbh->prepare("ALTER TABLE `items` CHANGE `bulk` `itemcallnumber` VARCHAR( 30 ) DEFAULT NULL");
***************
*** 1125,1129 ****
  
  if ($marc_subfield_structure{thesaurus_category}) {
!     print "  changing thesaurus_category in marc_subfield_structure table\n";
      my $sti =
        $dbh->prepare("ALTER TABLE marc_subfield_structure CHANGE `thesaurus_category` `authtypecode` VARCHAR(10 ) DEFAULT NULL");
--- 1129,1133 ----
  
  if ($marc_subfield_structure{thesaurus_category}) {
!     print "  changing thesaurus_category in marc_subfield_structure table\n" unless $silent;
      my $sti =
        $dbh->prepare("ALTER TABLE marc_subfield_structure CHANGE `thesaurus_category` `authtypecode` VARCHAR(10 ) DEFAULT NULL");
***************
*** 1143,1147 ****
  	}
  }
! print "Creating  index on z3950results\n" unless $exists;
  $dbh->do('ALTER TABLE issuingrules ADD PRIMARY KEY ( branchcode, categorycode, itemtype )') unless $exists;
  
--- 1147,1151 ----
  	}
  }
! print "Creating  index on issuing rules\n" unless $exists or $silent;
  $dbh->do('ALTER TABLE issuingrules ADD PRIMARY KEY ( branchcode, categorycode, itemtype )') unless $exists;
  
***************
*** 1164,1168 ****
  if ($marc_word{subfieldid}) {
  	#create field tagsubfield, copy tag+subfieldid, then drop tag and subfieldid
! 	print "Modifying marc_word (concat on tag and subfield for better perfs)\n";
  	$dbh->do("ALTER TABLE `marc_word` ADD `tagsubfield` CHAR( 4 ) NOT NULL AFTER `bibid`");
  	$dbh->do("update marc_word set tagsubfield=concat(tag,subfieldid)");
--- 1168,1172 ----
  if ($marc_word{subfieldid}) {
  	#create field tagsubfield, copy tag+subfieldid, then drop tag and subfieldid
! 	print "Modifying marc_word (concat on tag and subfield for better perfs)\n" unless $silent;
  	$dbh->do("ALTER TABLE `marc_word` ADD `tagsubfield` CHAR( 4 ) NOT NULL AFTER `bibid`");
  	$dbh->do("update marc_word set tagsubfield=concat(tag,subfieldid)");
***************
*** 1174,1178 ****
  
  foreach my $table ( keys %tabledata ) {
!     print "Checking for data required in table $table...\n";
      my $tablerows = $tabledata{$table};
      foreach my $row (@$tablerows) {
--- 1178,1182 ----
  
  foreach my $table ( keys %tabledata ) {
!     print "Checking for data required in table $table...\n" unless $silent;
      my $tablerows = $tabledata{$table};
      foreach my $row (@$tablerows) {
***************
*** 1193,1197 ****
  	    }
  	} else {
!             print "Adding row to $table: ";
              my @values;
              my $fieldlist;
--- 1197,1201 ----
  	    }
  	} else {
!             print "Adding row to $table: " unless $silent;
              my @values;
              my $fieldlist;
***************
*** 1202,1210 ****
                  my $value = $row->{$field};
                  push @values, $value;
!                 print "  $field => $value";
                  $fieldlist .= "$field,";
                  $placeholders .= "?,";
              }
!             print "\n";
              $fieldlist    =~ s/,$//;
              $placeholders =~ s/,$//;
--- 1206,1214 ----
                  my $value = $row->{$field};
                  push @values, $value;
!                 print "  $field => $value" unless $silent;
                  $fieldlist .= "$field,";
                  $placeholders .= "?,";
              }
!             print "\n" unless $silent;
              $fieldlist    =~ s/,$//;
              $placeholders =~ s/,$//;
***************
*** 1222,1225 ****
--- 1226,1233 ----
  
  # $Log$
+ # Revision 1.86  2004/06/22 11:30:57  tipaul
+ # adding -s (silent) flag, to have a silent install.
+ # only updater will be verbose
+ #
  # Revision 1.85  2004/06/17 15:19:44  tipaul
  # missing Marc_Search index on marc_word





More information about the Koha-cvs mailing list