[Koha-cvs] koha/updater updatedatabase [rel_3_0]

paul poulain paul at koha-fr.org
Thu Nov 23 10:05:33 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	paul poulain <tipaul>	06/11/23 09:05:33

Modified files:
	updater        : updatedatabase 

Log message:
	reintroducing move to innoDB (as only innoDB supports extended features like foreign keys)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/updater/updatedatabase?cvsroot=koha&only_with_tag=rel_3_0&r1=1.157.2.24&r2=1.157.2.25

Patches:
Index: updatedatabase
===================================================================
RCS file: /sources/koha/koha/updater/updatedatabase,v
retrieving revision 1.157.2.24
retrieving revision 1.157.2.25
diff -u -b -r1.157.2.24 -r1.157.2.25
--- updatedatabase	21 Nov 2006 09:15:23 -0000	1.157.2.24
+++ updatedatabase	23 Nov 2006 09:05:33 -0000	1.157.2.25
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: updatedatabase,v 1.157.2.24 2006/11/21 09:15:23 toins Exp $
+# $Id: updatedatabase,v 1.157.2.25 2006/11/23 09:05:33 tipaul Exp $
 
 # Database Updater
 # This script checks for required updates to the database.
@@ -218,11 +218,10 @@
 	auth_subfield_structure =>{ 'hidden' => 'TINYINT(3) NOT NULL default 0', 'kohafield' => 'VARCHAR(45) NOT NULL', 'linkid' =>  'TINYINT(1) NOT NULL default 0', 'isurl' => 'TINYINT(1)', 'frameworkcode'=>'VARCHAR(8) NOT  NULL'},
 	serial =>{ 'publisheddate' => 'date', 'itemnumber'=>'text NULL','routingnotes'=>'text NULL',},
     statistics => { 'associatedborrower' => 'integer'},
-    z3950servers =>{  `name` =>`text`,  `description` => `text NOT NULL`,
-    `position` =>`enum('primary','secondary','') NOT NULL default 'primary'`,  `icon` =>`text`,
-    `type` =>`enum('zed','opensearch') NOT NULL default 'zed'`,
+    z3950servers =>{  "name" =>"text",  "description" => "text NOT NULL",
+                    "position" =>"enum('primary','secondary','') NOT NULL default 'primary'",  "icon" =>"text",
+                    "type" =>"enum('zed','opensearch') NOT NULL default 'zed'",
   },
-    	 	
 #    tablename        => { 'field' => 'fieldtype' },
 );
 
@@ -759,6 +758,13 @@
             extra   => ''
         },
     ],
+    shelfcontents => [
+        {
+            field => 'dateadded',
+            type => 'timestamp',
+            null    => 'NULL',
+        },
+    ],
     systempreferences =>  [
 		{
 			field	=> 'value',
@@ -1295,6 +1301,29 @@
 			],
 		);
 		
+
+# MOVE all tables TO UTF-8 and innoDB
+$sth = $dbh->prepare("show table status");
+$sth->execute;
+while ( my $table = $sth->fetchrow_hashref ) {
+	if ($table->{Engine} ne 'InnoDB') {
+		$dbh->do("ALTER TABLE $table->{Name} TYPE = innodb");
+		print "moving $table->{Name} to InnoDB\n";
+	}
+    next if $table->{Name} eq 'marc_word';
+    next if $table->{Name} eq 'marc_subfield_table';
+    next if $table->{Name} eq 'auth_word';
+    next if $table->{Name} eq 'auth_subfield_table';
+	unless ($table->{Collation} =~ /^utf8/) {
+ 		print "moving $table->{Name} to utf8\n";
+		$dbh->do("ALTER TABLE $table->{Name} CONVERT TO CHARACTER SET utf8");
+		$dbh->do("ALTER TABLE $table->{Name} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
+		# FIXME : maybe a ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 would be better, def char set seems to work fine. If any problem encountered, let's try with convert !
+	} else {
+	}
+}
+
+
 foreach my $table (keys %column_change) {
 	$sth = $dbh->prepare("show columns from $table");
 	$sth->execute();
@@ -1495,10 +1524,18 @@
 # if it's a primary key, drop the previous pk, before altering the table
 			my $sth;
 			if ($key ne 'PRIMARY KEY') {
+# 				warn "alter table $table $action $field $type $null $key $extra default $default $after";
 				$sth =$dbh->prepare("alter table $table $action $field $type $null $key $extra default ? $after");
 			} else {
+# 			warn "alter table $table drop primary key, $action $field $type $null $key $extra default $default $after";
+			     # something strange : for indexes UNIQUE, they are reported as primary key here.
+			     # but if you try to run with drop primary key, it fails.
+			     # thus, we run the query twice, one will fail, one will succeed.
+			     # strange...
 				$sth =$dbh->prepare("alter table $table drop primary key, $action $field $type $null $key $extra default ? $after");
+				$sth =$dbh->prepare("alter table $table $action $field $type $null $key $extra default ? $after");
 			}
+# ALTER TABLE `borrowers` CHANGE `branchcode` `branchcode` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL 
 			$sth->execute($default);
 			print "  alter or create $field in $table\n" unless $silent;
 		}
@@ -1769,27 +1806,6 @@
 
 
 
-# MOVE all tables TO UTF-8 and innoDB
-$sth = $dbh->prepare("show table status");
-$sth->execute;
-while ( my $table = $sth->fetchrow_hashref ) {
-# 	if ($table->{Engine} ne 'InnoDB') {
-# 		$dbh->do("ALTER TABLE $table->{Name} TYPE = innodb");
-# 		print "moving $table->{Name} to InnoDB\n";
-# 	}
-    next if $table->{Name} eq 'marc_word';
-    next if $table->{Name} eq 'marc_subfield_table';
-    next if $table->{Name} eq 'auth_word';
-    next if $table->{Name} eq 'auth_subfield_table';
-	unless ($table->{Collation} =~ /^utf8/) {
- 		print "moving $table->{Name} to utf8\n";
-		$dbh->do("ALTER TABLE $table->{Name} CONVERT TO CHARACTER SET utf8");
-		$dbh->do("ALTER TABLE $table->{Name} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
-		# FIXME : maybe a ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 would be better, def char set seems to work fine. If any problem encountered, let's try with convert !
-	} else {
-	}
-}
-
 $sth->finish;
 
 #
@@ -1959,6 +1975,9 @@
 exit;
 
 # $Log: updatedatabase,v $
+# Revision 1.157.2.25  2006/11/23 09:05:33  tipaul
+# reintroducing move to innoDB (as only innoDB supports extended features like foreign keys)
+#
 # Revision 1.157.2.24  2006/11/21 09:15:23  toins
 # better userflag description
 #





More information about the Koha-cvs mailing list