6 # This script checks for required updates to the database.
8 # Part of the Koha Library Software www.koha.org
9 # Licensed under the GPL.
12 # - Would also be a good idea to offer to do a backup at this time...
14 # NOTE: If you do something more than once in here, make it table driven.
24 use MARC::File::XML ( BinaryEncoding => 'utf8' );
26 # FIXME - The user might be installing a new database, so can't rely
27 # on /etc/koha.conf anyway.
34 %existingtables, # tables already in database
38 $type, $null, $key, $default, $extra,
39 $prefitem, # preference item in systempreferences table
46 my $dbh = C4::Context->dbh;
47 print "connected to your DB. Checking & modifying it\n" unless $silent;
48 $|=1; # flushes output
53 # Tables to add if they don't exist
55 categorytable => "(categorycode char(5) NOT NULL default '',
56 description text default '',
57 itemtypecodes text default '',
58 PRIMARY KEY (categorycode)
60 subcategorytable => "(subcategorycode char(5) NOT NULL default '',
61 description text default '',
62 itemtypecodes text default '',
63 PRIMARY KEY (subcategorycode)
65 mediatypetable => "(mediatypecode char(5) NOT NULL default '',
66 description text default '',
67 itemtypecodes text default '',
68 PRIMARY KEY (mediatypecode)
71 `timestamp` TIMESTAMP NOT NULL ,
72 `user` INT( 11 ) NOT NULL ,
73 `module` TEXT default '',
74 `action` TEXT default '' ,
75 `object` INT(11) default '' ,
76 `info` TEXT default '' ,
77 PRIMARY KEY ( `timestamp` , `user` )
80 module varchar(20) NOT NULL default '',
81 code varchar(20) NOT NULL default '',
82 name varchar(100) NOT NULL default '',
83 title varchar(200) NOT NULL default '',
85 PRIMARY KEY (module,code)
88 alertid int(11) NOT NULL auto_increment,
89 borrowernumber int(11) NOT NULL default '0',
90 type varchar(10) NOT NULL default '',
91 externalid varchar(20) NOT NULL default '',
92 PRIMARY KEY (alertid),
93 KEY borrowernumber (borrowernumber),
94 KEY type (type,externalid)
97 `idnew` int(10) unsigned NOT NULL auto_increment,
98 `title` varchar(250) NOT NULL default '',
100 `lang` varchar(4) NOT NULL default '',
101 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
102 PRIMARY KEY (`idnew`)
104 repeatable_holidays => "(
105 `id` int(11) NOT NULL auto_increment,
106 `branchcode` varchar(4) NOT NULL default '',
107 `weekday` smallint(6) default NULL,
108 `day` smallint(6) default NULL,
109 `month` smallint(6) default NULL,
110 `title` varchar(50) NOT NULL default '',
111 `description` text NOT NULL,
114 special_holidays => "(
115 `id` int(11) NOT NULL auto_increment,
116 `branchcode` varchar(4) NOT NULL default '',
117 `day` smallint(6) NOT NULL default '0',
118 `month` smallint(6) NOT NULL default '0',
119 `year` smallint(6) NOT NULL default '0',
120 `isexception` smallint(1) NOT NULL default '1',
121 `title` varchar(50) NOT NULL default '',
122 `description` text NOT NULL,
125 overduerules =>"(`branchcode` varchar(255) NOT NULL default '',
126 `categorycode` char(2) NOT NULL default '',
127 `delay1` int(4) default '0',
128 `letter1` varchar(20) default NULL,
129 `debarred1` char(1) default '0',
130 `delay2` int(4) default '0',
131 `debarred2` char(1) default '0',
132 `letter2` varchar(20) default NULL,
133 `delay3` int(4) default '0',
134 `letter3` varchar(20) default NULL,
135 `debarred3` int(1) default '0',
136 PRIMARY KEY (`branchcode`,`categorycode`)
138 cities => "(`cityid` int auto_increment,
139 `city_name` char(100) NOT NULL,
140 `city_zipcode` char(20),
141 PRIMARY KEY (`cityid`)
143 roadtype => "(`roadtypeid` int auto_increment,
144 `road_type` char(100) NOT NULL,
145 PRIMARY KEY (`roadtypeid`)
149 labelid int(11) NOT NULL auto_increment,
150 itemnumber varchar(100) NOT NULL default '',
151 timestamp timestamp(14) NOT NULL,
152 PRIMARY KEY (labelid)
156 id int(4) NOT NULL auto_increment,
157 barcodetype char(100) default '',
158 title tinyint(1) default '0',
159 isbn tinyint(1) default '0',
160 itemtype tinyint(1) default '0',
161 barcode tinyint(1) default '0',
162 dewey tinyint(1) default '0',
163 class tinyint(1) default '0',
164 author tinyint(1) default '0',
165 papertype char(100) default '',
166 startrow int(2) default NULL,
170 borrowernumber integer,
171 biblionumber integer,
174 datereviewed datetime
179 my %requirefields = (
180 subscription => { 'letter' => 'char(20) NULL', 'distributedto' => 'text NULL'},
181 itemtypes => { 'imageurl' => 'char(200) NULL'},
182 aqbookfund => { 'branchcode' => 'varchar(4) NULL'},
183 aqbudget => { 'branchcode' => 'varchar(4) NULL'},
184 auth_header => { 'marc' => 'BLOB NOT NULL', 'linkid' => 'BIGINT(20) NULL'},
185 auth_subfield_structure =>{ 'hidden' => 'TINYINT(3) NOT NULL UNSIGNED ZEROFILL', 'kohafield' => 'VARCHAR(45) NOT NULL', 'linkid' => 'TINYINT(1) NOT NULL UNSIGNED', 'isurl' => 'TINYINT(1) UNSIGNED'},
186 statistics => { 'associatedborrower' => 'integer'},
187 # tablename => { 'field' => 'fieldtype' },
190 my %dropable_table = (
191 sessionqueries => 'sessionqueries',
192 marcrecorddone => 'marcrecorddone',
194 itemsprices => 'itemsprices',
195 biblioanalysis => 'biblioanalysis',
197 # tablename => 'tablename',
200 my %uselessfields = (
201 # tablename => "field1,field2",
202 borrowers => "suburb,altstreetaddress,altsuburb,altcity,studentnumber,school,area,preferredcont,altcp",
203 deletedborrowers=> "suburb,altstreetaddress,altsuburb,altcity,studentnumber,school,area,preferredcont,altcp",
205 # the other hash contains other actions that can't be done elsewhere. they are done
206 # either BEFORE of AFTER everything else, depending on "when" entry (default => AFTER)
208 # The tabledata hash contains data that should be in the tables.
209 # The uniquefieldrequired hash entry is used to determine which (if any) fields
210 # must not exist in the table for this row to be inserted. If the
211 # uniquefieldrequired entry is already in the table, the existing data is not
212 # modified, unless the forceupdate hash entry is also set. Fields in the
213 # anonymous "forceupdate" hash will be forced to be updated to the default
214 # values given in the %tabledata hash.
218 # { uniquefielrequired => 'fieldname', # the primary key in the table
219 # fieldname => fieldvalue,
220 # fieldname2 => fieldvalue2,
223 systempreferences => [
225 uniquefieldrequired => 'variable',
226 variable => 'Activate_Log',
228 forceupdate => { 'explanation' => 1,
230 explanation => 'Turn Log Actions on DB On an Off',
234 uniquefieldrequired => 'variable',
235 variable => 'IndependantBranches',
237 forceupdate => { 'explanation' => 1,
239 explanation => 'Turn Branch independancy management On an Off',
243 uniquefieldrequired => 'variable',
244 variable => 'ReturnBeforeExpiry',
246 forceupdate => { 'explanation' => 1,
248 explanation => 'If Yes, Returndate on issuing can\'t be after borrower card expiry',
252 uniquefieldrequired => 'variable',
253 variable => 'opacstylesheet',
255 forceupdate => { 'explanation' => 1,
257 explanation => 'Enter a complete URL to use an alternate stylesheet in OPAC',
261 uniquefieldrequired => 'variable',
262 variable => 'opacsmallimage',
264 forceupdate => { 'explanation' => 1,
266 explanation => 'Enter a complete URL to an image, will be on top/left instead of the Koha logo',
270 uniquefieldrequired => 'variable',
271 variable => 'opaclargeimage',
273 forceupdate => { 'explanation' => 1,
275 explanation => 'Enter a complete URL to an image, will be on the main page, instead of the Koha logo',
279 uniquefieldrequired => 'variable',
280 variable => 'delimiter',
282 forceupdate => { 'explanation' => 1,
284 explanation => 'separator for reports exported to spreadsheet',
288 uniquefieldrequired => 'variable',
290 value => 'OPENOFFICE.ORG',
291 forceupdate => { 'explanation' => 1,
294 explanation => 'Define the default application for report exportations into files',
296 options => 'EXCEL|OPENOFFICE.ORG'
299 uniquefieldrequired => 'variable',
300 variable => 'Delimiter',
302 forceupdate => { 'explanation' => 1,
305 explanation => 'Define the default separator character for report exportations into files',
307 options => ';|tabulation|,|/|\|#'
310 uniquefieldrequired => 'variable',
311 variable => 'SubscriptionHistory',
313 forceupdate => { 'explanation' => 1,
316 explanation => 'Define the information level for serials history in OPAC',
318 options => 'simplified|full'
321 uniquefieldrequired => 'variable',
322 variable => 'hidelostitems',
324 forceupdate => { 'explanation' => 1,
326 explanation => 'show or hide "lost" items in OPAC.',
330 uniquefieldrequired => 'variable',
331 variable => 'IndependantBranches',
333 forceupdate => { 'explanation' => 1,
335 explanation => 'Turn Branch independancy management On an Off',
339 uniquefieldrequired => 'variable',
340 variable => 'ReturnBeforeExpiry',
342 forceupdate => { 'explanation' => 1,
344 explanation => 'If Yes, Returndate on issuing can\'t be after borrower card expiry',
348 uniquefieldrequired => 'variable',
349 variable => 'Disable_Dictionary',
351 forceupdate => { 'explanation' => 1,
353 explanation => 'Disables Dictionary buttons if set to yes',
357 uniquefieldrequired => 'variable',
358 variable => 'hide_marc',
360 forceupdate => { 'explanation' => 1,
362 explanation => 'hide marc specific datas like subfield code & indicators to library',
366 uniquefieldrequired => 'variable',
367 variable => 'NotifyBorrowerDeparture',
369 forceupdate => { 'explanation' => 1,
371 explanation => 'Delay before expiry where a notice is sent when issuing',
375 uniquefieldrequired => 'variable',
376 variable => 'OpacPasswordChange',
378 forceupdate => { 'explanation' => 1,
380 explanation => 'Enable/Disable password change in OPAC (disable it when using LDAP auth)',
384 uniquefieldrequired => 'variable',
385 variable => 'useDaysMode',
387 forceupdate => { 'explanation' => 1,
389 explanation => 'How to calculate return dates : Calendar means holidays will be controled, Days means the return date don\'t depend on holidays',
391 options => 'Calendar|Days'
394 uniquefieldrequired => 'variable',
395 variable => 'borrowerMandatoryField',
396 value => 'zipcode|surname',
397 forceupdate => { 'explanation' => 1,
399 explanation => 'List all mandatory fields for borrowers',
403 uniquefieldrequired => 'variable',
404 variable => 'borrowerRelationship',
405 value => 'father|mother,grand-mother',
406 forceupdate => { 'explanation' => 1,
408 explanation => 'The relationships between a guarantor & a guarantee (separated by | or ,)',
412 uniquefieldrequired => 'variable',
413 variable => 'ReservesMaxPickUpDelay',
415 forceupdate => { 'explanation' => 1,
417 explanation => 'Maximum delay to pick up a reserved document',
421 uniquefieldrequired => 'variable',
422 variable => 'TransfersMaxDaysWarning',
424 forceupdate => { 'explanation' => 1,
426 explanation => 'Max delay before considering the transfer has potentialy a problem',
430 uniquefieldrequired => 'variable',
431 variable => 'memberofinstitution',
433 forceupdate => { 'explanation' => 1,
435 explanation => 'Are your patrons members of institutions',
439 uniquefieldrequired => 'variable',
440 variable => 'ReadingHistory',
442 forceupdate => { 'explanation' => 1,
444 explanation => 'Allow reading record info retrievable from issues and oldissues tables',
448 uniquefieldrequired => 'variable',
449 variable => 'IssuingInProcess',
451 forceupdate => { 'explanation' => 1,
453 explanation => 'Allow no debt alert if the patron is issuing item that accumulate debt',
457 uniquefieldrequired => 'variable',
458 variable => 'AutomaticItemReturn',
460 forceupdate => { 'explanation' => 1,
462 explanation => 'This Variable allow or not to return automaticly to his homebranch',
466 uniquefieldrequired => 'variable',
467 variable => 'reviewson',
469 forceupdate => { 'explanation' => 1,
471 explanation => 'Allows patrons to submit reviews from the opac',
478 my %fielddefinitions = (
480 # { field => 'fieldname',
481 # type => 'fieldtype',
499 field => 'booksellerid',
509 field => 'listprice',
510 type => 'varchar(10)',
517 field => 'invoiceprice',
518 type => 'varchar(10)',
527 field => 'borrowernumber',
529 null => 'NULL', # can be null when a borrower is deleted and the foreign key rule executed
535 field => 'itemnumber',
537 null => 'NULL', # can be null when a borrower is deleted and the foreign key rule executed
544 { field => 'B_email',
547 after => 'B_zipcode',
550 field => 'streetnumber', # street number (hidden if streettable table is empty)
556 field => 'streettype', # street table, list builded from a system table
559 after => 'streetnumber',
562 field => 'B_streetnumber', # street number (hidden if streettable table is empty)
568 field => 'B_streettype', # street table, list builded from a system table
571 after => 'B_streetnumber',
580 field => 'address2', # complement address
592 field => 'contactfirstname', # contact's firstname
595 after => 'contactname',
598 field => 'contacttitle', # contact's title
601 after => 'contactfirstname',
605 deletedborrowers => [
606 { field => 'B_email',
609 after => 'B_zipcode',
612 field => 'streetnumber', # street number (hidden if streettable table is empty)
618 field => 'streettype', # street table, list builded from a system table
621 after => 'streetnumber',
624 field => 'B_streetnumber', # street number (hidden if streettable table is empty)
630 field => 'B_streettype', # street table, list builded from a system table
633 after => 'B_streetnumber',
642 field => 'address2', # complement address
654 field => 'contactfirstname', # contact's firstname
657 after => 'contactname',
660 field => 'contacttitle', # contact's title
663 after => 'contactfirstname',
670 type => 'varchar(15)',
677 field => 'branchprinter',
678 type => 'varchar(100)',
687 field => 'category_type',
697 field => 'waitingdate',
709 # { indexname => 'index detail'
713 { indexname => 'shelfnumber',
714 content => 'shelfnumber',
716 { indexname => 'itemnumber',
717 content => 'itemnumber',
721 { indexname => 'biblionumber',
722 content => 'biblionumber',
726 { indexname => 'homebranch',
727 content => 'homebranch',
729 { indexname => 'holdingbranch',
730 content => 'holdingbranch',
734 { indexname => 'PRIMARY',
740 { indexname => 'booksellerid',
741 content => 'booksellerid',
745 { indexname => 'basketno',
746 content => 'basketno',
749 aqorderbreakdown => [
750 { indexname => 'ordernumber',
751 content => 'ordernumber',
753 { indexname => 'bookfundid',
754 content => 'bookfundid',
758 { indexname => 'PRIMARY',
759 content => 'currency',
767 # { key => 'the key in table' (must be indexed)
768 # foreigntable => 'the foreigntable name', # (the parent)
769 # foreignkey => 'the foreign key column(s)' # (in the parent)
770 # onUpdate => 'CASCADE|SET NULL|NO ACTION| RESTRICT',
771 # onDelete => 'CASCADE|SET NULL|NO ACTION| RESTRICT',
775 { key => 'shelfnumber',
776 foreigntable => 'bookshelf',
777 foreignkey => 'shelfnumber',
778 onUpdate => 'CASCADE',
779 onDelete => 'CASCADE',
781 { key => 'itemnumber',
782 foreigntable => 'items',
783 foreignkey => 'itemnumber',
784 onUpdate => 'CASCADE',
785 onDelete => 'CASCADE',
788 # onDelete is RESTRICT on reference tables (branches, itemtype) as we don't want items to be
789 # easily deleted, but branches/itemtype not too easy to empty...
791 { key => 'biblionumber',
792 foreigntable => 'biblio',
793 foreignkey => 'biblionumber',
794 onUpdate => 'CASCADE',
795 onDelete => 'CASCADE',
798 foreigntable => 'itemtypes',
799 foreignkey => 'itemtype',
800 onUpdate => 'CASCADE',
801 onDelete => 'RESTRICT',
805 { key => 'biblioitemnumber',
806 foreigntable => 'biblioitems',
807 foreignkey => 'biblioitemnumber',
808 onUpdate => 'CASCADE',
809 onDelete => 'CASCADE',
811 { key => 'homebranch',
812 foreigntable => 'branches',
813 foreignkey => 'branchcode',
814 onUpdate => 'CASCADE',
815 onDelete => 'RESTRICT',
817 { key => 'holdingbranch',
818 foreigntable => 'branches',
819 foreignkey => 'branchcode',
820 onUpdate => 'CASCADE',
821 onDelete => 'RESTRICT',
824 additionalauthors => [
825 { key => 'biblionumber',
826 foreigntable => 'biblio',
827 foreignkey => 'biblionumber',
828 onUpdate => 'CASCADE',
829 onDelete => 'CASCADE',
833 { key => 'biblionumber',
834 foreigntable => 'biblio',
835 foreignkey => 'biblionumber',
836 onUpdate => 'CASCADE',
837 onDelete => 'CASCADE',
841 { key => 'booksellerid',
842 foreigntable => 'aqbooksellers',
844 onUpdate => 'CASCADE',
845 onDelete => 'RESTRICT',
850 foreigntable => 'aqbasket',
851 foreignkey => 'basketno',
852 onUpdate => 'CASCADE',
853 onDelete => 'CASCADE',
855 { key => 'biblionumber',
856 foreigntable => 'biblio',
857 foreignkey => 'biblionumber',
858 onUpdate => 'SET NULL',
859 onDelete => 'SET NULL',
863 { key => 'listprice',
864 foreigntable => 'currency',
865 foreignkey => 'currency',
866 onUpdate => 'CASCADE',
867 onDelete => 'CASCADE',
869 { key => 'invoiceprice',
870 foreigntable => 'currency',
871 foreignkey => 'currency',
872 onUpdate => 'CASCADE',
873 onDelete => 'CASCADE',
876 aqorderbreakdown => [
877 { key => 'ordernumber',
878 foreigntable => 'aqorders',
879 foreignkey => 'ordernumber',
880 onUpdate => 'CASCADE',
881 onDelete => 'CASCADE',
883 { key => 'bookfundid',
884 foreigntable => 'aqbookfund',
885 foreignkey => 'bookfundid',
886 onUpdate => 'CASCADE',
887 onDelete => 'CASCADE',
891 { key => 'frombranch',
892 foreigntable => 'branches',
893 foreignkey => 'branchcode',
894 onUpdate => 'CASCADE',
895 onDelete => 'CASCADE',
898 foreigntable => 'branches',
899 foreignkey => 'branchcode',
900 onUpdate => 'CASCADE',
901 onDelete => 'CASCADE',
903 { key => 'itemnumber',
904 foreigntable => 'items',
905 foreignkey => 'itemnumber',
906 onUpdate => 'CASCADE',
907 onDelete => 'CASCADE',
911 { key => 'categorycode',
912 foreigntable => 'categories',
913 foreignkey => 'categorycode',
914 onUpdate => 'CASCADE',
915 onDelete => 'CASCADE',
918 foreigntable => 'itemtypes',
919 foreignkey => 'itemtype',
920 onUpdate => 'CASCADE',
921 onDelete => 'CASCADE',
924 issues => [ # constraint is SET NULL : when a borrower or an item is deleted, we keep the issuing record
926 { key => 'borrowernumber',
927 foreigntable => 'borrowers',
928 foreignkey => 'borrowernumber',
929 onUpdate => 'SET NULL',
930 onDelete => 'SET NULL',
932 { key => 'itemnumber',
933 foreigntable => 'items',
934 foreignkey => 'itemnumber',
935 onUpdate => 'SET NULL',
936 onDelete => 'SET NULL',
940 { key => 'borrowernumber',
941 foreigntable => 'borrowers',
942 foreignkey => 'borrowernumber',
943 onUpdate => 'CASCADE',
944 onDelete => 'CASCADE',
946 { key => 'biblionumber',
947 foreigntable => 'biblio',
948 foreignkey => 'biblionumber',
949 onUpdate => 'CASCADE',
950 onDelete => 'CASCADE',
952 { key => 'itemnumber',
953 foreigntable => 'items',
954 foreignkey => 'itemnumber',
955 onUpdate => 'CASCADE',
956 onDelete => 'CASCADE',
958 { key => 'branchcode',
959 foreigntable => 'branches',
960 foreignkey => 'branchcode',
961 onUpdate => 'CASCADE',
962 onDelete => 'CASCADE',
965 borrowers => [ # foreign keys are RESTRICT as we don't want to delete borrowers when a branch is deleted
966 # but prevent deleting a branch as soon as it has 1 borrower !
967 { key => 'categorycode',
968 foreigntable => 'categories',
969 foreignkey => 'categorycode',
970 onUpdate => 'RESTRICT',
971 onDelete => 'RESTRICT',
973 { key => 'branchcode',
974 foreigntable => 'branches',
975 foreignkey => 'branchcode',
976 onUpdate => 'RESTRICT',
977 onDelete => 'RESTRICT',
980 deletedborrowers => [ # foreign keys are RESTRICT as we don't want to delete borrowers when a branch is deleted
981 # but prevent deleting a branch as soon as it has 1 borrower !
982 { key => 'categorycode',
983 foreigntable => 'categories',
984 foreignkey => 'categorycode',
985 onUpdate => 'RESTRICT',
986 onDelete => 'RESTRICT',
988 { key => 'branchcode',
989 foreigntable => 'branches',
990 foreignkey => 'branchcode',
991 onUpdate => 'RESTRICT',
992 onDelete => 'RESTRICT',
996 { key => 'borrowernumber',
997 foreigntable => 'borrowers',
998 foreignkey => 'borrowernumber',
999 onUpdate => 'CASCADE',
1000 onDelete => 'CASCADE',
1002 { key => 'itemnumber',
1003 foreigntable => 'items',
1004 foreignkey => 'itemnumber',
1005 onUpdate => 'SET NULL',
1006 onDelete => 'SET NULL',
1009 auth_tag_structure => [
1010 { key => 'authtypecode',
1011 foreigntable => 'auth_types',
1012 foreignkey => 'authtypecode',
1013 onUpdate => 'CASCADE',
1014 onDelete => 'CASCADE',
1017 # FIXME : don't constraint auth_*_table and auth_word, as they may be replaced by zebra
1022 my %column_change = (
1026 from => 'emailaddress',
1031 from => 'streetaddress',
1033 after => 'initials',
1036 from => 'faxnumber',
1041 from => 'textmessaging',
1047 to => 'contactnote',
1048 after => 'opacnote',
1051 from => 'physstreet',
1056 from => 'streetcity',
1058 after => 'B_address',
1071 from => 'homezipcode',
1078 after => 'B_zipcode',
1083 after => 'dateenrolled',
1086 from => 'guarantor',
1087 to => 'guarantorid',
1088 after => 'contactname',
1091 from => 'textmessaging',
1097 to => 'contactnotes',
1098 after => 'opacnotes',
1101 from => 'altrelationship',
1102 to => 'relationship',
1103 after => 'borrowernotes',
1107 deletedborrowers => [
1109 from => 'emailaddress',
1114 from => 'streetaddress',
1116 after => 'initials',
1119 from => 'faxnumber',
1124 from => 'textmessaging',
1130 to => 'contactnote',
1131 after => 'opacnote',
1134 from => 'physstreet',
1139 from => 'streetcity',
1141 after => 'B_address',
1154 from => 'homezipcode',
1161 after => 'B_zipcode',
1166 after => 'dateenrolled',
1169 from => 'guarantor',
1170 to => 'guarantorid',
1171 after => 'contactname',
1174 from => 'textmessaging',
1180 to => 'contactnotes',
1181 after => 'opacnotes',
1184 from => 'altrelationship',
1185 to => 'relationship',
1186 after => 'borrowernotes',
1192 foreach my $table (keys %column_change) {
1193 $sth = $dbh->prepare("show columns from $table");
1196 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
1198 $types{$column}->{type} ="$type";
1199 $types{$column}->{null} = "$null";
1200 $types{$column}->{key} = "$key";
1201 $types{$column}->{default} = "$default";
1202 $types{$column}->{extra} = "$extra";
1204 my $tablerows = $column_change{$table};
1205 foreach my $row ( @$tablerows ) {
1206 if ($types{$row->{from}}->{type}) {
1207 print "altering $table $row->{from} to $row->{to}\n";
1208 # ALTER TABLE `borrowers` CHANGE `faxnumber` `fax` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
1209 # alter table `borrowers` change `faxnumber` `fax` type text null after phone
1211 "alter table `$table` change `$row->{from}` `$row->{to}` $types{$row->{from}}->{type} ".
1212 ($types{$row->{from}}->{null} eq 'YES'?" NULL":" NOT NULL").
1213 ($types{$row->{from}}->{default}?" default ".$types{$row->{from}}->{default}:"").
1214 "$types{$row->{from}}->{extra} after $row->{after} ";
1221 #-------------------
1226 # Get version of MySQL database engine.
1227 my $mysqlversion = `mysqld --version`;
1228 $mysqlversion =~ /Ver (\S*) /;
1230 if ( $mysqlversion ge '3.23' ) {
1231 print "Could convert to MyISAM database tables...\n" unless $silent;
1234 #---------------------------------
1237 # Collect all tables into a list
1238 $sth = $dbh->prepare("show tables");
1240 while ( my ($table) = $sth->fetchrow ) {
1241 $existingtables{$table} = 1;
1245 # Now add any missing tables
1246 foreach $table ( keys %requiretables ) {
1247 unless ( $existingtables{$table} ) {
1248 print "Adding $table table...\n" unless $silent;
1249 my $sth = $dbh->prepare("create table $table $requiretables{$table}");
1252 print "Error : $sth->errstr \n";
1258 # now drop useless tables
1259 foreach $table ( keys %dropable_table ) {
1260 if ( $existingtables{$table} ) {
1261 print "Dropping unused table $table\n" if $debug and not $silent;
1262 $dbh->do("drop table $table");
1264 print "Error : $dbh->errstr \n";
1269 #---------------------------------
1272 foreach $table ( keys %requirefields ) {
1273 print "Check table $table\n" if $debug and not $silent;
1274 $sth = $dbh->prepare("show columns from $table");
1277 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
1279 $types{$column} = $type;
1281 foreach $column ( keys %{ $requirefields{$table} } ) {
1282 print " Check column $column [$types{$column}]\n" if $debug and not $silent;
1283 if ( !$types{$column} ) {
1285 # column doesn't exist
1286 print "Adding $column field to $table table...\n" unless $silent;
1287 $query = "alter table $table
1288 add column $column " . $requirefields{$table}->{$column};
1289 print "Execute: $query\n" if $debug;
1290 my $sti = $dbh->prepare($query);
1293 print "**Error : $sti->errstr \n";
1300 foreach $table ( keys %fielddefinitions ) {
1301 print "Check table $table\n" if $debug;
1302 $sth = $dbh->prepare("show columns from $table");
1305 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
1307 $definitions->{$column}->{type} = $type;
1308 $definitions->{$column}->{null} = $null;
1309 $definitions->{$column}->{null} = 'NULL' if $null eq 'YES';
1310 $definitions->{$column}->{key} = $key;
1311 $definitions->{$column}->{default} = $default;
1312 $definitions->{$column}->{extra} = $extra;
1314 my $fieldrow = $fielddefinitions{$table};
1315 foreach my $row (@$fieldrow) {
1316 my $field = $row->{field};
1317 my $type = $row->{type};
1318 my $null = $row->{null};
1319 # $null = 'YES' if $row->{null} eq 'NULL';
1320 my $key = $row->{key};
1321 my $default = $row->{default};
1322 my $null = $row->{null};
1323 # $default="''" unless $default;
1324 my $extra = $row->{extra};
1325 my $def = $definitions->{$field};
1326 my $after = ($row->{after}?" after ".$row->{after}:"");
1328 unless ( $type eq $def->{type}
1329 && $null eq $def->{null}
1330 && $key eq $def->{key}
1331 && $extra eq $def->{extra} )
1333 if ( $null eq '' ) {
1336 if ( $key eq 'PRI' ) {
1337 $key = 'PRIMARY KEY';
1339 unless ( $extra eq 'auto_increment' ) {
1343 # if it's a new column use "add", if it's an old one, use "change".
1345 if ($definitions->{$field}->{type}) {
1346 $action="change $field"
1350 # if it's a primary key, drop the previous pk, before altering the table
1352 if ($key ne 'PRIMARY KEY') {
1353 $sth =$dbh->prepare("alter table $table $action $field $type $null $key $extra default ? $after");
1355 $sth =$dbh->prepare("alter table $table drop primary key, $action $field $type $null $key $extra default ? $after");
1357 $sth->execute($default);
1358 print " alter or create $field in $table\n" unless $silent;
1363 # Populate tables with required data
1366 # synch table and deletedtable.
1367 foreach my $table (('borrowers','items','biblio','biblioitems')) {
1368 my %deletedborrowers;
1369 print "synch'ing $table\n";
1370 $sth = $dbh->prepare("show columns from deleted$table");
1372 while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ) {
1373 $deletedborrowers{$column}=1;
1375 $sth = $dbh->prepare("show columns from $table");
1378 while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ) {
1379 unless ($deletedborrowers{$column}) {
1380 my $newcol="alter table deleted$table add $column $type";
1381 if ($null eq 'YES') {
1382 $newcol .= " NULL ";
1384 $newcol .= " NOT NULL ";
1386 $newcol .= "default $default" if $default;
1387 $newcol .= " after $previous" if $previous;
1389 print "creating column $column\n";
1395 foreach my $table ( keys %tabledata ) {
1396 print "Checking for data required in table $table...\n" unless $silent;
1397 my $tablerows = $tabledata{$table};
1398 foreach my $row (@$tablerows) {
1399 my $uniquefieldrequired = $row->{uniquefieldrequired};
1400 my $uniquevalue = $row->{$uniquefieldrequired};
1401 my $forceupdate = $row->{forceupdate};
1404 "select $uniquefieldrequired from $table where $uniquefieldrequired=?"
1406 $sth->execute($uniquevalue);
1408 foreach my $field (keys %$forceupdate) {
1409 if ($forceupdate->{$field}) {
1410 my $sth=$dbh->prepare("update systempreferences set $field=? where $uniquefieldrequired=?");
1411 $sth->execute($row->{$field}, $uniquevalue);
1415 print "Adding row to $table: " unless $silent;
1419 foreach my $field ( keys %$row ) {
1420 next if $field eq 'uniquefieldrequired';
1421 next if $field eq 'forceupdate';
1422 my $value = $row->{$field};
1423 push @values, $value;
1424 print " $field => $value" unless $silent;
1425 $fieldlist .= "$field,";
1426 $placeholders .= "?,";
1428 print "\n" unless $silent;
1429 $fieldlist =~ s/,$//;
1430 $placeholders =~ s/,$//;
1433 "insert into $table ($fieldlist) values ($placeholders)");
1434 $sth->execute(@values);
1440 # check indexes and create them when needed
1442 print "Checking for index required...\n" unless $silent;
1443 foreach my $table ( keys %indexes ) {
1445 # read all indexes from $table
1447 $sth = $dbh->prepare("show index from $table");
1449 my %existingindexes;
1450 while ( my ( $table, $non_unique, $key_name, $Seq_in_index, $Column_name, $Collation, $cardinality, $sub_part, $Packed, $comment ) = $sth->fetchrow ) {
1451 $existingindexes{$key_name} = 1;
1453 # read indexes to check
1454 my $tablerows = $indexes{$table};
1455 foreach my $row (@$tablerows) {
1456 my $key_name=$row->{indexname};
1457 if ($existingindexes{$key_name} eq 1) {
1458 # print "$key_name existing";
1460 print "\tCreating index $key_name in $table\n";
1462 if ($row->{indexname} eq 'PRIMARY') {
1463 $sql = "alter table $table ADD PRIMARY KEY ($row->{content})";
1465 $sql = "alter table $table ADD INDEX $key_name ($row->{content}) $row->{type}";
1468 print "Error $sql : $dbh->err \n" if $dbh->err;
1474 # check foreign keys and create them when needed
1476 print "Checking for foreign keys required...\n" unless $silent;
1477 foreach my $table ( keys %foreign_keys ) {
1479 # read all indexes from $table
1481 $sth = $dbh->prepare("show table status like '$table'");
1483 my $stat = $sth->fetchrow_hashref;
1484 # read indexes to check
1485 my $tablerows = $foreign_keys{$table};
1486 foreach my $row (@$tablerows) {
1487 my $foreign_table=$row->{foreigntable};
1488 if ($stat->{'Comment'} =~/$foreign_table/) {
1489 # print "$foreign_table existing\n";
1491 print "\tCreating foreign key $foreign_table in $table\n";
1492 # first, drop any orphan value in child table
1493 if ($row->{onDelete} ne "RESTRICT") {
1494 my $sql = "delete from $table where $row->{key} not in (select $row->{foreignkey} from $row->{foreigntable})";
1496 print "SQL ERROR: $sql : $dbh->err \n" if $dbh->err;
1498 my $sql="alter table $table ADD FOREIGN KEY $row->{key} ($row->{key}) REFERENCES $row->{foreigntable} ($row->{foreignkey})";
1499 $sql .= " on update ".$row->{onUpdate} if $row->{onUpdate};
1500 $sql .= " on delete ".$row->{onDelete} if $row->{onDelete};
1503 print "====================
1504 An error occured during :
1506 It probably means there is something wrong in your DB : a row ($table.$row->{key}) refers to a value in $row->{foreigntable}.$row->{foreignkey} that does not exist. solve the problem and run updater again (or just the previous SQL statement).
1507 You can find those values with select
1508 \t$table.* from $table where $row->{key} not in (select $row->{foreignkey} from $row->{foreigntable})
1509 ====================\n
1520 # create frameworkcode row in biblio table & fill it with marc_biblio.frameworkcode.
1523 # 1st, get how many biblio we will have to do...
1524 $sth = $dbh->prepare('select count(*) from marc_biblio');
1526 my ($totaltodo) = $sth->fetchrow;
1528 $sth = $dbh->prepare("show columns from biblio");
1531 my $bibliofwexist=0;
1532 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ){
1533 $bibliofwexist=1 if $column eq 'frameworkcode';
1535 unless ($bibliofwexist) {
1536 print "moving biblioframework to biblio table\n";
1537 $dbh->do('ALTER TABLE `biblio` ADD `frameworkcode` VARCHAR( 4 ) NOT NULL AFTER `biblionumber`');
1538 $sth = $dbh->prepare('select biblionumber,frameworkcode from marc_biblio');
1540 my $sth_update = $dbh->prepare('update biblio set frameworkcode=? where biblionumber=?');
1542 while (my ($biblionumber,$frameworkcode) = $sth->fetchrow) {
1543 $sth_update->execute($frameworkcode,$biblionumber);
1545 print "\r$totaldone / $totaltodo" unless ($totaldone % 100);
1551 # moving MARC data from marc_subfield_table to biblioitems.marc
1553 $sth = $dbh->prepare("show columns from biblioitems");
1557 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ){
1558 $marcdone=1 if ($type eq 'blob' && $column eq 'marc') ;
1560 unless ($marcdone) {
1561 print "moving MARC record to biblioitems table\n";
1562 # changing marc field type
1563 $dbh->do('ALTER TABLE `biblioitems` CHANGE `marc` `marc` BLOB NULL DEFAULT NULL ');
1564 # adding marc xml, just for convenience
1565 $dbh->do('ALTER TABLE `biblioitems` ADD `marcxml` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ');
1566 # moving data from marc_subfield_value to biblio
1567 $sth = $dbh->prepare('select bibid,biblionumber from marc_biblio');
1569 my $sth_update = $dbh->prepare('update biblioitems set marc=?, marcxml=? where biblionumber=?');
1571 while (my ($bibid,$biblionumber) = $sth->fetchrow) {
1572 my $record = MARCgetbiblio($dbh,$bibid);
1573 #Force UTF-8 in record leader
1574 $record->encoding('UTF-8');
1575 print $record->as_formatted if ($biblionumber==3902);
1576 $sth_update->execute($record->as_usmarc(),$record->as_xml_record(),$biblionumber);
1578 print "\r$totaldone / $totaltodo" unless ($totaldone % 100);
1584 # at last, remove useless fields
1585 foreach $table ( keys %uselessfields ) {
1586 my @fields = split /,/,$uselessfields{$table};
1589 foreach my $fieldtodrop (@fields) {
1590 $fieldtodrop =~ s/\t//g;
1591 $fieldtodrop =~ s/\n//g;
1593 $sth = $dbh->prepare("show columns from $table");
1595 while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
1597 $exists =1 if ($column eq $fieldtodrop);
1600 print "deleting $fieldtodrop field in $table...\n" unless $silent;
1601 my $sth = $dbh->prepare("alter table $table drop $fieldtodrop");
1608 # MOVE all tables TO UTF-8 and innoDB
1609 $sth = $dbh->prepare("show table status");
1611 while ( my $table = $sth->fetchrow_hashref ) {
1612 # if ($table->{Engine} ne 'InnoDB') {
1613 # $dbh->do("ALTER TABLE $table->{Name} TYPE = innodb");
1614 # print "moving $table->{Name} to InnoDB\n";
1616 unless ($table->{Collation} =~ /^utf8/) {
1617 $dbh->do("ALTER TABLE $table->{Name} CONVERT TO CHARACTER SET utf8");
1618 $dbh->do("ALTER TABLE $table->{Name} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
1619 # 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 !
1620 print "moving $table->{Name} to utf8\n";
1628 # those 2 subs are a copy of Biblio.pm, version 2.2.4
1629 # they are useful only once, for moving from 2.2 to 3.0
1630 # the MARCgetbiblio & MARCgetitem subs in Biblio.pm
1631 # are still here, but uses other tables
1632 # (the ones that are filled by updatedatabase !)
1637 # Returns MARC::Record of the biblio passed in parameter.
1638 my ( $dbh, $bibid ) = @_;
1639 my $record = MARC::Record->new();
1644 "select bibid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink
1645 from marc_subfield_table
1646 where bibid=? order by tag,tagorder,subfieldorder
1651 "select subfieldvalue from marc_blob_subfield where blobidlink=?");
1652 $sth->execute($bibid);
1653 my $prevtagorder = 1;
1654 my $prevtag = 'XXX';
1656 my $field; # for >=10 tags
1657 my $prevvalue; # for <10 tags
1658 while ( my $row = $sth->fetchrow_hashref ) {
1660 if ( $row->{'valuebloblink'} ) { #---- search blob if there is one
1661 $sth2->execute( $row->{'valuebloblink'} );
1662 my $row2 = $sth2->fetchrow_hashref;
1664 $row->{'subfieldvalue'} = $row2->{'subfieldvalue'};
1666 if ( $row->{tagorder} ne $prevtagorder || $row->{tag} ne $prevtag ) {
1667 $previndicator .= " ";
1668 if ( $prevtag < 10 ) {
1669 if ($prevtag ne '000') {
1670 $record->add_fields( ( sprintf "%03s", $prevtag ), $prevvalue ) unless $prevtag eq "XXX"; # ignore the 1st loop
1672 $record->leader(sprintf("%24s",$prevvalue));
1676 $record->add_fields($field) unless $prevtag eq "XXX";
1679 $prevtagorder = $row->{tagorder};
1680 $prevtag = $row->{tag};
1681 $previndicator = $row->{tag_indicator};
1682 if ( $row->{tag} < 10 ) {
1683 $prevvalue = $row->{subfieldvalue};
1686 $field = MARC::Field->new(
1687 ( sprintf "%03s", $prevtag ),
1688 substr( $row->{tag_indicator} . ' ', 0, 1 ),
1689 substr( $row->{tag_indicator} . ' ', 1, 1 ),
1690 $row->{'subfieldcode'},
1691 $row->{'subfieldvalue'}
1696 if ( $row->{tag} < 10 ) {
1697 $record->add_fields( ( sprintf "%03s", $row->{tag} ),
1698 $row->{'subfieldvalue'} );
1701 $field->add_subfields( $row->{'subfieldcode'},
1702 $row->{'subfieldvalue'} );
1704 $prevtag = $row->{tag};
1705 $previndicator = $row->{tag_indicator};
1709 # the last has not been included inside the loop... do it now !
1710 if ( $prevtag ne "XXX" )
1711 { # check that we have found something. Otherwise, prevtag is still XXX and we
1712 # must return an empty record, not make MARC::Record fail because we try to
1713 # create a record with XXX as field :-(
1714 if ( $prevtag < 10 ) {
1715 $record->add_fields( $prevtag, $prevvalue );
1719 # my $field = MARC::Field->new( $prevtag, "", "", %subfieldlist);
1720 $record->add_fields($field);
1728 # Returns MARC::Record of the biblio passed in parameter.
1729 my ( $dbh, $bibid, $itemnumber ) = @_;
1730 my $record = MARC::Record->new();
1732 # search MARC tagorder
1735 "select tagorder from marc_subfield_table,marc_subfield_structure where marc_subfield_table.tag=marc_subfield_structure.tagfield and marc_subfield_table.subfieldcode=marc_subfield_structure.tagsubfield and bibid=? and kohafield='items.itemnumber' and subfieldvalue=?"
1737 $sth2->execute( $bibid, $itemnumber );
1738 my ($tagorder) = $sth2->fetchrow_array();
1740 #---- TODO : the leader is missing
1743 "select bibid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink
1744 from marc_subfield_table
1745 where bibid=? and tagorder=? order by subfieldcode,subfieldorder
1750 "select subfieldvalue from marc_blob_subfield where blobidlink=?");
1751 $sth->execute( $bibid, $tagorder );
1752 while ( my $row = $sth->fetchrow_hashref ) {
1753 if ( $row->{'valuebloblink'} ) { #---- search blob if there is one
1754 $sth2->execute( $row->{'valuebloblink'} );
1755 my $row2 = $sth2->fetchrow_hashref;
1757 $row->{'subfieldvalue'} = $row2->{'subfieldvalue'};
1759 if ( $record->field( $row->{'tag'} ) ) {
1762 #--- this test must stay as this, because of strange behaviour of mySQL/Perl DBI with char var containing a number...
1763 #--- sometimes, eliminates 0 at beginning, sometimes no ;-\\\
1764 if ( length( $row->{'tag'} ) < 3 ) {
1765 $row->{'tag'} = "0" . $row->{'tag'};
1767 $field = $record->field( $row->{'tag'} );
1770 $field->add_subfields( $row->{'subfieldcode'},
1771 $row->{'subfieldvalue'} );
1772 $record->delete_field($field);
1773 $record->add_fields($field);
1777 if ( length( $row->{'tag'} ) < 3 ) {
1778 $row->{'tag'} = "0" . $row->{'tag'};
1781 MARC::Field->new( $row->{'tag'}, " ", " ",
1782 $row->{'subfieldcode'} => $row->{'subfieldvalue'} );
1783 $record->add_fields($temp);
1794 # Revision 1.147 2006/06/17 03:36:41 rangi
1795 # Table definition for the reviews table
1797 # Revision 1.146 2006/06/17 03:29:41 rangi
1798 # Variable to allow librarians to switch reviews on or off
1800 # Revision 1.145 2006/06/16 09:45:02 btoumi
1801 # updatedatabase.pl: add change of borrowers table to deletedborrowers table
1802 # deletemem.pl: delete use of warn function
1804 # Revision 1.144 2006/06/08 15:36:31 alaurin
1805 # Add a new system preference 'AutomaticItemReturn' :
1807 # if this prefence is switched on: the document returned in another library than homebranch, the system automaticly transfer the document to his homebranch (with notification for librarian in returns.tmpl) .
1809 # switch off : the document stay in the holdingbranch ...
1812 # - comment C4::acquisition (not using in request.pl).
1813 # - correcting date in request.pl
1814 # -add the new call of function getbranches in request.pl
1816 # Revision 1.143 2006/06/07 02:02:47 bob_lyon
1817 # merging katipo changes...
1819 # adding new preference IssuingInProcess
1821 # Revision 1.142 2006/06/06 23:42:46 bob_lyon
1822 # Merging Katipo changes...
1824 # Adding new system pref where one can still retrieve a correct reading
1825 # record history if one has moved older data from issues to oldissues table
1826 # to speed up issues speed
1828 # Revision 1.141 2006/06/01 03:18:11 rangi
1829 # Adding a new column to the statistics table
1831 # Revision 1.140 2006/05/22 22:40:45 rangi
1832 # Adding new systempreference allowing for the library to add borrowers to institutions (rest homes, parishes, schools, classes etc).
1834 # Revision 1.139 2006/05/19 19:31:29 tgarip1957
1835 # Added new fields to auth_header and auth_subfield_table to allow ZEBRA use of authorities and new MARC framework like structure.
1836 # Authority tables are modified to be compatible with new MARC frameworks. This change is part of Authority Linking & Zebra authorities. Requires change in Mysql database. It will break head unless all changes regarding this is implemented. This warning will take place on all commits regarding this
1838 # Revision 1.138 2006/05/19 16:51:44 alaurin
1839 # update database for :
1840 # - new feature ip and printer management
1841 # adding two fields in branches table (branchip,branchprinter)
1843 # - waiting date : adding one field in reserves table(waiting date) to calculate the Maximum delay to pick up a reserved document when it's available
1845 # new system preference :
1846 # - ReservesMaxPickUpDelay : Maximum delay to pick up a reserved document
1847 # TransfersMaxDaysWarning : Max delay before considering the transfer as potentialy a problem
1849 # Revision 1.137 2006/04/18 09:36:36 plg
1850 # bug fixed: typo fixed in labels and labels_conf tables creation query.
1852 # Revision 1.136 2006/04/17 21:55:33 sushi
1853 # Added 'labels' and 'labels_conf' tables, for spine lable tool.
1855 # Revision 1.135 2006/04/15 02:37:03 tgarip1957
1856 # Marc record should be set to UTF-8 in leader.Force it.
1857 # XML should be with<record> wrappers
1859 # Revision 1.134 2006/04/14 09:37:29 tipaul
1860 # improvements from SAN Ouest Provence :
1861 # * introducing a category_type into categories. It can be A (adult), C (children), P (Professionnal), I (institution/organisation).
1862 # * each category_type has it's own forms to create members.
1863 # * the borrowers table has been heavily modified (many fields changed), to get something more logic & readable
1864 # * reintroducing guarantor/guanrantee system that is now independant from hardcoded C/A for categories
1865 # * updating templates to fit template rules
1867 # (see mail feb, 17 on koha-devel "new features for borrowers" for more details)
1869 # Revision 1.133 2006/04/13 08:36:42 plg
1870 # new: function C4::Date::get_date_format_string_for_DHTMLcalendar based on
1871 # the system preference prefered date format.
1873 # improvement: book fund list and budget list screen redesigned. Filters on
1874 # each field. Columns are not sortable yet. Using DHTML Calendar to fill date
1875 # fields instead of manual filling. Pagination system. From the book fund
1876 # list, you can reach the budget list, filtered on a book fund, or not. A
1877 # budget can be added only from book fund list screen.
1879 # bug fixed: branchcode was missing in table aqbudget.
1881 # bug fixed: when setting a branchcode to a book fund, all associated budgets
1882 # move to this branchcode.
1884 # modification: when adding/modifying budget/fund, MySQL specific "REPLACE..."
1885 # statements replaced by standard SQL compliant statement.
1887 # bug fixed: when adding/modifying a budget, if the book fund is associated to
1888 # a branch, the branch selection is disabled and set to the book fund branch.
1890 # Revision 1.132 2006/04/06 12:37:05 hdl
1891 # Bugfixing : aqbookfund needed a field.
1893 # Revision 1.131 2006/03/03 17:02:22 tipaul
1894 # commit for holidays and news management.
1895 # (some forgotten files)
1897 # Revision 1.130 2006/03/03 16:35:21 tipaul
1898 # commit for holidays and news management.
1900 # Contrib from Tümer Garip (from Turkey) :
1902 # in /tools/ the holiday.pl script let you define holidays (days where the library is closed), branch by branch. You can define 3 types of holidays :
1903 # - single day : only this day is closed
1904 # - repet weekly (like "sunday") : the day is holiday every week
1905 # - repet yearly (like "July, 4") : this day is closed every year.
1907 # You can also put exception :
1908 # - sunday is holiday, but "2006 March, 5th" the library will be open
1910 # The holidays are used for return date calculation : the return date is set to the next date where the library is open. A systempreference (useDaysMode) set ON (Calendar) or OFF (Normal) the calendar calculation.
1912 # Revision 1.129 2006/02/27 18:19:33 hdl
1913 # New table used in overduerules.pl tools page.
1915 # Revision 1.128 2006/01/25 15:16:06 tipaul
1917 # * removing useless tables
1918 # * adding useful indexes
1919 # * altering some columns definitions
1920 # * The goal being to have updater working fine for foreign keys.
1922 # For me it's done, let me know if it works for you. You can see an updated schema of the DB (with constraints) on the wiki
1924 # Revision 1.127 2006/01/24 17:57:17 tipaul
1925 # DB improvements : adding foreign keys on some tables. partial stuff done.
1927 # Revision 1.126 2006/01/06 16:39:42 tipaul
1928 # synch'ing head and rel_2_2 (from 2.2.5, including npl templates)
1929 # Seems not to break too many things, but i'm probably wrong here.
1930 # at least, new features/bugfixes from 2.2.5 are here (tested on some features on my head local copy)
1932 # - removing useless directories (koha-html and koha-plucene)
1934 # Revision 1.125 2006/01/04 15:54:55 tipaul
1935 # utf8 is a : go for beta test in HEAD.
1936 # some explanations :
1937 # - 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.
1938 # - *-top.inc will show the pages in utf8
1939 # - 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.
1940 # - using marcxml field and no more the iso2709 raw marc biblioitems.marc field.
1942 # Revision 1.124 2005/10/27 12:09:05 tipaul
1943 # new features for serial module :
1944 # - 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")
1945 # - 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).
1947 # Revision 1.123 2005/10/26 09:13:37 tipaul
1948 # big commit, still breaking things...
1950 # * synch with rel_2_2. Probably the last non manual synch, as rel_2_2 should not be modified deeply.
1951 # * code cleaning (cleaning warnings from perl -w) continued
1953 # Revision 1.122 2005/09/02 14:18:38 tipaul
1954 # new feature : image for itemtypes.
1956 # * run updater/updatedatabase to create imageurl field in itemtypes.
1957 # * go to Koha >> parameters >> itemtypes >> modify (or add) an itemtype. You will see around 20 nice images to choose between (thanks to owen). If you prefer your own image, you also can type a complete url (http://www.myserver.lib/path/to/my/image.gif)
1958 # * go to OPAC, and search something. In the result list, you now have the picture instead of the text itemtype.
1960 # Revision 1.121 2005/08/24 08:49:03 hdl
1961 # Adding a note field in serial table.
1962 # This will allow librarian to mention a note on a peculiar waiting serial number.
1964 # Revision 1.120 2005/08/09 14:10:32 tipaul
1965 # 1st commit to go to zebra.
1966 # don't update your cvs if you want to have a working head...
1968 # this commit contains :
1969 # * updater/updatedatabase : get rid with marc_* tables, but DON'T remove them. As a lot of things uses them, it would not be a good idea for instance to drop them. If you really want to play, you can rename them to test head without them but being still able to reintroduce them...
1970 # * Biblio.pm : modify MARCgetbiblio to find the raw marc record in biblioitems.marc field, not from marc_subfield_table, modify MARCfindframeworkcode to find frameworkcode in biblio.frameworkcode, modify some other subs to use biblio.biblionumber & get rid of bibid.
1971 # * other files : get rid of bibid and use biblionumber instead.
1974 # * does not do anything on zebra yet.
1975 # * if you rename marc_subfield_table, you can't search anymore.
1976 # * you can view a biblio & bibliodetails, go to MARC editor, but NOT save any modif.
1977 # * don't try to add a biblio, it would add data poorly... (don't try to delete either, it may work, but that would be a surprise ;-) )
1979 # IMPORTANT NOTE : you need MARC::XML package (http://search.cpan.org/~esummers/MARC-XML-0.7/lib/MARC/File/XML.pm), that requires a recent version of MARC::Record
1980 # Updatedatabase stores the iso2709 data in biblioitems.marc field & an xml version in biblioitems.marcxml Not sure we will keep it when releasing the stable version, but I think it's a good idea to have something readable in sql, at least for development stage.
1982 # Revision 1.119 2005/08/04 16:07:58 tipaul
1983 # Synch really broke this script...
1985 # Revision 1.118 2005/08/04 16:02:55 tipaul
1986 # oops... error in synch between 2.2 and head
1988 # Revision 1.117 2005/08/04 14:24:39 tipaul
1989 # synch'ing 2.2 and head
1991 # Revision 1.116 2005/08/04 08:55:54 tipaul
1992 # Letters / alert system, continuing...
1994 # * adding a package Letters.pm, that manages Letters & alerts.
1995 # * adding feature : it's now possible to define a "letter" for any subscription created. If a letter is defined, users in OPAC can put an alert on the subscription. When an issue is marked "arrived", all users in the alert will recieve a mail (as defined in the "letter"). This last part (= send the mail) is not yet developped. (Should be done this week)
1996 # * adding feature : it's now possible to "put to an alert" in OPAC, for any serial subscription. The alert is stored in a new table, called alert. An alert can be put only if the librarian has activated them in subscription (and they activate it just by choosing a "letter" to sent to borrowers on new issues)
1997 # * adding feature : librarian can see in borrower detail which alerts they have put, and a user can see in opac-detail which alert they have put too.
1999 # Note that the system should be generic enough to manage any type of alert.
2000 # I plan to extend it soon to virtual shelves : a borrower will be able to put an alert on a virtual shelf, to be warned when something is changed in the virtual shelf (mail being sent once a day by cron, or manually by the shelf owner. Anyway, a mail won't be sent on every change, users would be spammed by Koha ;-) )
2002 # Revision 1.115 2005/08/02 16:15:34 tipaul
2003 # adding 2 fields to letter system :
2004 # * module (acquisition, catalogue...) : it will be usefull to show the librarian only letters he may be interested by.
2005 # * title, that will be used as mail subject.
2007 # Revision 1.114 2005/07/28 15:10:13 tipaul
2008 # Introducing new "Letters" system : Letters will be used everytime you want to sent something to someone (through mail or paper). For example, sending a mail for overdues use letter that you can put as parameters. Sending a mail to a borrower when a suggestion is validated uses a letter too.
2009 # the letter table contains 3 fields :
2010 # * code => the code of the letter
2011 # * name => the complete name of the letter
2012 # * content => the complete text. It's a TEXT field type, so has no limits.
2014 # My next goal now is to work on point 2-I "serial issue alert"
2015 # With this feature, in serials, a user can subscribe the "issue alert". For every issue arrived/missing, a mail is sent to all subscribers of this list. The mail warns the user that the issue is arrive or missing. Will be in head.
2016 # (see mail on koha-devel, 2005/04/07)
2018 # The "serial issue alert" will be the 1st to use this letter system that probably needs some tweaking ;-)
2020 # Once it will be stabilised default letters (in any languages) could be added during installer to help the library begin with this new feature.
2022 # Revision 1.113 2005/07/28 08:38:41 tipaul
2023 # For instance, the return date does not rely on the borrower expiration date. A systempref will be added in Koha, to modify return date calculation schema :
2024 # * ReturnBeforeExpiry = yes => return date can't be after expiry date
2025 # * ReturnBeforeExpiry = no => return date can be after expiry date
2027 # Revision 1.112 2005/07/26 08:19:47 hdl
2028 # Adding IndependantBranches System preference variable in order to manage Branch independancy.
2030 # Revision 1.111 2005/07/25 15:35:38 tipaul
2031 # we have decided that moving to Koha 3.0 requires being already in Koha 2.2.x
2032 # So, the updatedatabase script can highly be cleaned (90% removed).
2033 # Let's play with the new Koha DB structure now ;-)