moving readingrec to members directory
[koha-ffzg.git] / updater / updatedatabase
index 2325c3a..3add675 100755 (executable)
@@ -97,7 +97,7 @@ my %requiretables = (
 );
 
 my %requirefields = (
-       subscription => { 'letter' => 'char(20) NULL'},
+       subscription => { 'letter' => 'char(20) NULL', 'distributedto' => 'text NULL'},
        itemtypes => { 'imageurl' => 'char(200) NULL'},
 #    tablename        => { 'field' => 'fieldtype' },
 );
@@ -269,6 +269,24 @@ my %tabledata = (
             explanation         => 'hide marc specific datas like subfield code & indicators to library',
             type                => 'YesNo',
         },
+        {
+            uniquefieldrequired => 'variable',
+            variable            => 'NotifyBorrowerDeparture',
+            value               => '0',
+            forceupdate         => { 'explanation' => 1,
+                                     'type' => 1},
+            explanation         => 'Delay before expiry where a notice is sent when issuing',
+            type                => 'Integer',
+        },
+        {
+            uniquefieldrequired => 'variable',
+            variable            => 'OpacPasswordChange',
+            value               => '1',
+            forceupdate         => { 'explanation' => 1,
+                                     'type' => 1},
+            explanation         => 'Enable/Disable password change in OPAC (disable it when using LDAP auth)',
+            type                => 'YesNo',
+        },
     ],
 
 );
@@ -437,6 +455,37 @@ foreach $table ( keys %fielddefinitions ) {
 
 
 # Populate tables with required data
+
+
+# synch table and deletedtable.
+foreach my $table (('borrowers','items','biblio','biblioitems')) {
+       my %deletedborrowers;
+       print "synch'ing $table\n";
+       $sth = $dbh->prepare("show columns from deleted$table");
+       $sth->execute;
+       while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ) {
+               $deletedborrowers{$column}=1;
+       }
+       $sth = $dbh->prepare("show columns from $table");
+       $sth->execute;
+       my $previous;
+       while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ) {
+               unless ($deletedborrowers{$column}) {
+                       my $newcol="alter table deleted$table add $column $type";
+                       if ($null eq 'YES') {
+                               $newcol .= " NULL ";
+                       } else {
+                               $newcol .= " NOT NULL ";
+                       }
+                       $newcol .= "default $default" if $default;
+                       $newcol .= " after $previous" if $previous;
+                       $previous=$column;
+                       print "creating column $column\n";
+                       $dbh->do($newcol);
+               }
+       }
+}
+
 foreach my $table ( keys %tabledata ) {
     print "Checking for data required in table $table...\n" unless $silent;
     my $tablerows = $tabledata{$table};
@@ -545,6 +594,22 @@ unless ($marcdone) {
        print "\rdone\n";
 }
 
+# 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";
+       }
+       unless ($table->{Collation} =~ /^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 !
+               print "moving $table->{Name} to utf8\n";
+       } else {
+       }
+}
+
 # at last, remove useless fields
 foreach $table ( keys %uselessfields ) {
        my @fields = split /,/,$uselessfields{$table};
@@ -737,6 +802,26 @@ sub MARCgetitem {
 exit;
 
 # $Log$
+# Revision 1.126  2006/01/06 16:39:42  tipaul
+# synch'ing head and rel_2_2 (from 2.2.5, including npl templates)
+# Seems not to break too many things, but i'm probably wrong here.
+# at least, new features/bugfixes from 2.2.5 are here (tested on some features on my head local copy)
+#
+# - removing useless directories (koha-html and koha-plucene)
+#
+# Revision 1.125  2006/01/04 15:54:55  tipaul
+# utf8 is a : go for beta test in HEAD.
+# some explanations :
+# - updater/updatedatabase => will transform all tables in innoDB (not related to utf8, just to warn you) AND collate them in utf8 / utf8_general_ci. The SQL command is : ALTER TABLE tablename DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci.
+# - *-top.inc will show the pages in utf8
+# - THE HARD THING : for me, mysql-client and mysql-server were set up to communicate in iso8859-1, whatever the mysql collation ! Thus, pages were improperly shown, as datas were transmitted in iso8859-1 format ! After a full day of investigation, someone on usenet pointed "set NAMES 'utf8'" to explain that I wanted utf8. I could put this in my.cnf, but if I do that, ALL databases will "speak" in utf8, that's not what we want. Thus, I added a line in Context.pm : everytime a DB handle is opened, the communication is set to utf8.
+# - using marcxml field and no more the iso2709 raw marc biblioitems.marc field.
+#
+# Revision 1.124  2005/10/27 12:09:05  tipaul
+# new features for serial module :
+# - the last 5 issues are now shown, and their status can be changed (but not reverted to "waited", as there can be only one "waited")
+# - the library can create a "distribution list". this paper contains a list of borrowers (selected from the borrower list, or manually entered), and print it for a given issue. once printed, the sheet can be put on the issue and distributed to every reader on the list (one by one).
+#
 # Revision 1.123  2005/10/26 09:13:37  tipaul
 # big commit, still breaking things...
 #