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
56 `timestamp` TIMESTAMP NOT NULL ,
57 `user` INT( 11 ) NOT NULL ,
58 `module` TEXT default '',
59 `action` TEXT default '' ,
60 `object` INT(11) NULL ,
61 `info` TEXT default '' ,
62 PRIMARY KEY ( `timestamp` , `user` )
65 module varchar(20) NOT NULL default '',
66 code varchar(20) NOT NULL default '',
67 name varchar(100) NOT NULL default '',
68 title varchar(200) NOT NULL default '',
70 PRIMARY KEY (module,code)
73 alertid int(11) NOT NULL auto_increment,
74 borrowernumber int(11) NOT NULL default '0',
75 type varchar(10) NOT NULL default '',
76 externalid varchar(20) NOT NULL default '',
77 PRIMARY KEY (alertid),
78 KEY borrowernumber (borrowernumber),
79 KEY type (type,externalid)
82 `idnew` int(10) unsigned NOT NULL auto_increment,
83 `title` varchar(250) NOT NULL default '',
85 `lang` varchar(4) NOT NULL default '',
86 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
89 repeatable_holidays => "(
90 `id` int(11) NOT NULL auto_increment,
91 `branchcode` varchar(4) NOT NULL default '',
92 `weekday` smallint(6) default NULL,
93 `day` smallint(6) default NULL,
94 `month` smallint(6) default NULL,
95 `title` varchar(50) NOT NULL default '',
96 `description` text NOT NULL,
99 special_holidays => "(
100 `id` int(11) NOT NULL auto_increment,
101 `branchcode` varchar(4) NOT NULL default '',
102 `day` smallint(6) NOT NULL default '0',
103 `month` smallint(6) NOT NULL default '0',
104 `year` smallint(6) NOT NULL default '0',
105 `isexception` smallint(1) NOT NULL default '1',
106 `title` varchar(50) NOT NULL default '',
107 `description` text NOT NULL,
110 overduerules =>"(`branchcode` varchar(255) NOT NULL default '',
111 `categorycode` char(2) NOT NULL default '',
112 `delay1` int(4) default '0',
113 `letter1` varchar(20) default NULL,
114 `debarred1` char(1) default '0',
115 `delay2` int(4) default '0',
116 `debarred2` char(1) default '0',
117 `letter2` varchar(20) default NULL,
118 `delay3` int(4) default '0',
119 `letter3` varchar(20) default NULL,
120 `debarred3` int(1) default '0',
121 PRIMARY KEY (`branchcode`,`categorycode`)
123 cities => "(`cityid` int auto_increment,
124 `city_name` char(100) NOT NULL,
125 `city_zipcode` char(20),
126 PRIMARY KEY (`cityid`)
128 roadtype => "(`roadtypeid` int auto_increment,
129 `road_type` char(100) NOT NULL,
130 PRIMARY KEY (`roadtypeid`)
134 labelid int(11) NOT NULL auto_increment,
135 itemnumber varchar(100) NOT NULL default '',
136 timestamp timestamp(14) NOT NULL,
137 PRIMARY KEY (labelid)
141 id int(4) NOT NULL auto_increment,
142 barcodetype char(100) default '',
143 title tinyint(1) default '0',
144 isbn tinyint(1) default '0',
145 itemtype tinyint(1) default '0',
146 barcode tinyint(1) default '0',
147 dewey tinyint(1) default '0',
148 class tinyint(1) default '0',
149 author tinyint(1) default '0',
150 papertype char(100) default '',
151 startrow int(2) default NULL,
155 reviewid integer NOT NULL auto_increment,
156 borrowernumber integer,
157 biblionumber integer,
160 datereviewed datetime,
161 PRIMARY KEY (reviewid)
163 subscriptionroutinglist=>"(
164 routingid integer NOT NULL auto_increment,
165 borrowernumber integer,
167 subscriptionid integer,
168 PRIMARY KEY (routingid)
172 notify_id int(11) NOT NULL default '0',
173 `borrowernumber` int(11) NOT NULL default '0',
174 `itemnumber` int(11) NOT NULL default '0',
175 `notify_date` date NOT NULL default '0000-00-00',
176 `notify_send_date` date default NULL,
177 `notify_level` int(1) NOT NULL default '0',
178 `method` varchar(20) NOT NULL default ''
182 `charge_id` varchar(5) NOT NULL default '',
183 `description` text NOT NULL,
184 `amount` decimal(28,6) NOT NULL default '0.000000',
185 `min` int(4) NOT NULL default '0',
186 `max` int(4) NOT NULL default '0',
187 `level` int(1) NOT NULL default '0',
188 PRIMARY KEY (`charge_id`)
191 `entry` varchar(255) NOT NULL default '',
192 `weight` bigint(20) NOT NULL default '0',
193 PRIMARY KEY (`entry`)
197 `id` int NOT NULL auto_increment,
198 `biblio_auth_number` int NOT NULL,
199 `operation` char(20) NOT NULL,
200 `server` char(20) NOT NULL ,
202 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1",
206 my %requirefields = (
207 subscription => { 'letter' => 'char(20) NULL', 'distributedto' => 'text NULL', 'firstacquidate'=>'date NOT NULL','irregularity'=>'TEXT NULL default \'\'','numberpattern'=>'TINYINT(3) NULL default 0', 'callnumber'=>'text NULL', 'hemisphere' =>'TINYINT(3) NULL default 0', 'issuesatonce'=>'TINYINT(3) NOT NULL default 1', 'branchcode' =>'varchar(12) NOT NULL default \'\'', 'manualhistory'=>'TINYINT(1) NOT NULL default 0','internalnotes'=>'LONGTEXT NULL default \'\''},
208 itemtypes => { 'imageurl' => 'char(200) NULL'},
209 aqbookfund => { 'branchcode' => 'varchar(4) NULL'},
210 aqbudget => { 'branchcode' => 'varchar(4) NULL'},
211 auth_header => { 'marc' => 'BLOB NOT NULL', 'linkid' => 'BIGINT(20) NULL'},
212 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'},
213 marc_breeding => { 'isbn' => 'varchar(13) NOT NULL'},
214 serial =>{ 'publisheddate' => 'date', 'claimdate' => 'date', 'itemnumber'=>'text NULL','routingnotes'=>'text NULL',},
215 statistics => { 'associatedborrower' => 'integer'},
216 z3950servers =>{ "name" =>"text", "description" => "text NOT NULL",
217 "position" =>"enum('primary','secondary','') NOT NULL default 'primary'", "icon" =>"text",
218 "type" =>"enum('zed','opensearch') NOT NULL default 'zed'",
220 issues =>{ 'issuedate'=>"date NOT NULL default '0000-00-00'", },
222 # tablename => { 'field' => 'fieldtype' },
225 # Enter here the table to delete.
226 my @TableToDelete = qw(
233 my %uselessfields = (
234 # tablename => "field1,field2",
235 borrowers => "suburb,altstreetaddress,altsuburb,altcity,studentnumber,school,area,preferredcont,altcp",
236 deletedborrowers=> "suburb,altstreetaddress,altsuburb,altcity,studentnumber,school,area,preferredcont,altcp",
238 # the other hash contains other actions that can't be done elsewhere. they are done
239 # either BEFORE of AFTER everything else, depending on "when" entry (default => AFTER)
241 # The tabledata hash contains data that should be in the tables.
242 # The uniquefieldrequired hash entry is used to determine which (if any) fields
243 # must not exist in the table for this row to be inserted. If the
244 # uniquefieldrequired entry is already in the table, the existing data is not
245 # modified, unless the forceupdate hash entry is also set. Fields in the
246 # anonymous "forceupdate" hash will be forced to be updated to the default
247 # values given in the %tabledata hash.
251 # { uniquefielrequired => 'fieldname', # the primary key in the table
252 # fieldname => fieldvalue,
253 # fieldname2 => fieldvalue2,
256 systempreferences => [
258 uniquefieldrequired => 'variable',
259 variable => 'useDaysMode',
261 forceupdate => { 'explanation' => 1,
263 explanation => 'How to calculate return dates : Calendar means holidays will be controled, Days means the return date don\'t depend on holidays',
265 options => 'Calendar|Days'
268 uniquefieldrequired => 'variable',
269 variable => 'BorrowersTitles',
270 value => 'Mr|Mrs|Miss|Ms',
271 forceupdate => { 'explanation' => 1,
273 explanation => 'List all Titles for borrowers',
277 uniquefieldrequired => 'variable',
278 variable => 'BorrowerMandatoryField',
279 value => 'cardnumber|surname|address',
280 forceupdate => { 'explanation' => 1,
282 explanation => 'List all mandatory fields for borrowers',
286 uniquefieldrequired => 'variable',
287 variable => 'borrowerRelationship',
288 value => 'father|mother,grand-mother',
289 forceupdate => { 'explanation' => 1,
291 explanation => 'The relationships between a guarantor & a guarantee (separated by | or ,)',
295 uniquefieldrequired => 'variable',
296 variable => 'ReservesMaxPickUpDelay',
298 forceupdate => { 'explanation' => 1,
300 explanation => 'Maximum delay to pick up a reserved document',
304 uniquefieldrequired => 'variable',
305 variable => 'TransfersMaxDaysWarning',
307 forceupdate => { 'explanation' => 1,
309 explanation => 'Max delay before considering the transfer has potentialy a problem',
313 uniquefieldrequired => 'variable',
314 variable => 'memberofinstitution',
316 forceupdate => { 'explanation' => 1,
318 explanation => 'Are your patrons members of institutions',
322 uniquefieldrequired => 'variable',
323 variable => 'ReadingHistory',
325 forceupdate => { 'explanation' => 1,
327 explanation => 'Allow reading record info retrievable from issues and oldissues tables',
331 uniquefieldrequired => 'variable',
332 variable => 'IssuingInProcess',
334 forceupdate => { 'explanation' => 1,
336 explanation => 'Allow no debt alert if the patron is issuing item that accumulate debt',
340 uniquefieldrequired => 'variable',
341 variable => 'AutomaticItemReturn',
343 forceupdate => { 'explanation' => 1,
345 explanation => 'This Variable allow or not to return automaticly to his homebranch',
349 uniquefieldrequired => 'variable',
350 variable => 'reviewson',
352 forceupdate => { 'explanation' => 1,
354 explanation => 'Allows patrons to submit reviews from the opac',
358 uniquefieldrequired => 'variable',
359 variable => 'intranet_includes',
361 forceupdate => { 'explanation' => 1,
363 explanation => 'The includes directory you want for specific look of Koha (includes or includes_npl for example)',
367 uniquefieldrequired => 'variable',
368 variable => 'AutoLocation',
370 forceupdate => { 'explanation' => 1,
372 explanation => 'switch to activate or not Autolocation, if Yes, the Librarian can\'t change his location, it\'s defined by branchip',
376 uniquefieldrequired => 'variable',
377 variable => 'serialsadditems',
383 explanation => 'If set, a new item will be automatically added when receiving an issue',
387 uniquefieldrequired => 'variable',
388 variable => 'expandedSearchOption',
394 explanation => 'search among marc field',
398 uniquefieldrequired => 'variable',
399 variable => 'RequestOnOpac',
401 forceupdate => { 'explanation' => 1,
403 explanation => 'option to allow reserves on opac',
407 uniquefieldrequired => 'variable',
408 variable => 'OpacCloud',
410 forceupdate => { 'explanation' => 1,
412 explanation => 'Enable / Disable cloud link on OPAC (Require to run misc/cronjobs/build_browser_and_cloud.pl on the server)',
416 uniquefieldrequired => 'variable',
417 variable => 'OpacBrowser',
419 forceupdate => { 'explanation' => 1,
421 explanation => 'Enable/Disable browser link on OPAC (Require to run misc/cronjobs/build_browser_and_cloud.pl on the server)',
425 uniquefieldrequired => 'variable',
426 variable => 'OpacTopissue',
428 forceupdate => { 'explanation' => 1,
430 explanation => 'Enable / Disable the top issue link on OPAC',
434 uniquefieldrequired => 'variable',
435 variable => 'OpacAuthorities',
437 forceupdate => { 'explanation' => 1,
439 explanation => 'Enable / Disable the search authority link on OPAC',
443 uniquefieldrequired => 'variable',
444 variable => 'CataloguingLog',
446 forceupdate => {'explanation' => 1, 'type' => 1},
447 explanation => 'Active this if you want to log cataloguing action.',
451 uniquefieldrequired => 'variable',
452 variable => 'BorrowersLog',
454 forceupdate => {'explanation' => 1, 'type' => 1},
455 explanation => 'Active this if you want to log borrowers edition/creation/deletion...',
459 uniquefieldrequired => 'variable',
460 variable => 'SubscriptionLog',
462 forceupdate => {'explanation' => 1, 'type' => 1},
463 explanation => 'Active this if you want to log Subscription action',
467 uniquefieldrequired => 'variable',
468 variable => 'IssueLog',
470 forceupdate => {'explanation' => 1, 'type' => 1},
471 explanation => 'Active this if you want to log issue.',
475 uniquefieldrequired => 'variable',
476 variable => 'ReturnLog',
478 forceupdate => {'explanation' => 1, 'type' => 1},
479 explanation => 'Active this if you want to log the circulation return',
483 uniquefieldrequired => 'variable',
484 variable => 'Version',
486 forceupdate => {'explanation' => 1, 'type' => 1},
487 explanation => 'Koha Version',
491 uniquefieldrequired => 'variable',
492 variable => 'LetterLog',
494 forceupdate => {'explanation' => 1, 'type' => 1},
495 explanation => 'Active this if you want to log all the letter sent',
499 uniquefieldrequired => 'variable',
500 variable => 'FinesLog',
502 forceupdate => {'explanation' => 1, 'type' => 1},
503 explanation => 'Active this if you want to log fines',
507 uniquefieldrequired => 'variable',
508 variable => 'NoZebra',
510 forceupdate => {'explanation' => 1, 'type' => 1},
511 explanation => 'Active this if you want NOT to use zebra (large libraries should avoid this parameters)',
515 uniquefieldrequired => 'variable',
516 variable => 'NoZebraIndexes',
518 forceupdate => {'explanation' => 1, 'type' => 1},
519 explanation => "Enter a specific hash for NoZebra indexes. Enter : 'indexname' => '100a,245a,500*','index2' => '...'",
523 uniquefieldrequired => 'variable',
524 variable => 'uppercasesurnames',
526 forceupdate => {'explanation' => 1, 'type' => 1},
527 explanation => "Force Surnames to be uppercase",
533 uniquefieldrequired => 'bit',
535 flag => 'editauthorities',
536 flagdesc => 'allow to edit authorities',
540 uniquefieldrequired => 'bit',
543 flagdesc => 'allow to manage serials subscriptions',
547 uniquefieldrequired => 'bit',
550 flagdesc => 'allow to access to the reports module',
554 authorised_values => [
556 uniquefieldrequired => 'id',
557 category => 'SUGGEST',
558 authorised_value => 'Not enough budget',
559 lib => 'This book it too much expensive',
564 my %fielddefinitions = (
566 # { field => 'fieldname',
567 # type => 'fieldtype',
575 field => 'booksellerid',
590 extra => 'auto_increment',
593 field => 'listprice',
594 type => 'varchar(10)',
601 field => 'invoiceprice',
602 type => 'varchar(10)',
612 field => 'notify_id',
620 field => 'notify_level',
631 { field => 'firstname',
635 { field => 'initials',
639 { field => 'B_email',
642 after => 'B_zipcode',
645 field => 'streetnumber', # street number (hidden if streettable table is empty)
651 field => 'streettype', # street table, list builded from a system table
654 after => 'streetnumber',
661 field => 'B_streetnumber', # street number (hidden if streettable table is empty)
667 field => 'B_streettype', # street table, list builded from a system table
670 after => 'B_streetnumber',
679 field => 'address2', # complement address
691 field => 'contactfirstname', # contact's firstname
694 after => 'contactname',
697 field => 'contacttitle', # contact's title
700 after => 'contactfirstname',
703 field => 'branchcode',
704 type => 'varchar(10)',
710 field => 'categorycode',
711 type => 'varchar(10)',
721 type => 'varchar(25)',
729 type => 'varchar(4)',
737 type => 'varchar(30)',
743 deletedbiblioitems => [
746 type => 'varchar(30)',
755 type => 'varchar(15)',
762 field => 'branchprinter',
763 type => 'varchar(100)',
770 field => 'branchcode',
771 type => 'varchar(10)',
779 field => 'frombranch',
780 type => 'VARCHAR(10)',
788 type => 'VARCHAR(10)',
797 field => 'category_type',
805 field => 'categorycode',
806 type => 'varchar(10)',
814 deletedborrowers => [
815 { field => 'firstname',
819 { field => 'initials',
823 { field => 'B_email',
826 after => 'B_zipcode',
829 field => 'streetnumber', # street number (hidden if streettable table is empty)
835 field => 'streettype', # street table, list builded from a system table
838 after => 'streetnumber',
845 field => 'B_streetnumber', # street number (hidden if streettable table is empty)
851 field => 'B_streettype', # street table, list builded from a system table
854 after => 'B_streetnumber',
863 field => 'address2', # complement address
875 field => 'contactfirstname', # contact's firstname
878 after => 'contactname',
881 field => 'contacttitle', # contact's title
884 after => 'contactfirstname',
890 field => 'borrowernumber',
892 null => 'NULL', # can be null when a borrower is deleted and the foreign key rule executed
898 field => 'itemnumber',
900 null => 'NULL', # can be null when a borrower is deleted and the foreign key rule executed
906 field => 'branchcode',
907 type => 'varchar(10)',
914 field => 'issuedate',
918 default => '0000-00-00',
929 default => '0000-00-00',
933 field => 'cutterextra',
934 type => 'varchar(45)',
941 field => 'issue_date',
949 field => 'homebranch',
950 type => 'varchar(10)',
957 field => 'holdingbranch',
958 type => 'varchar(10)',
966 type => 'varchar(10)',
976 type => 'varchar(10)',
999 marc_subfield_structure => [
1001 field => 'defaultvalue',
1010 field => 'expirationdate',
1027 field => 'waitingdate',
1047 field => 'dateadded',
1048 type => 'timestamp',
1052 systempreferences => [
1062 field => 'explanation',
1084 # { indexname => 'index detail'
1088 { indexname => 'PRIMARY',
1094 { indexname => 'booksellerid',
1095 content => 'booksellerid',
1099 { indexname => 'basketno',
1100 content => 'basketno',
1103 aqorderbreakdown => [
1104 { indexname => 'ordernumber',
1105 content => 'ordernumber',
1107 { indexname => 'bookfundid',
1108 content => 'bookfundid',
1112 { indexname => 'isbn',
1115 { indexname => 'publishercode',
1116 content => 'publishercode',
1121 indexname => 'branchcode',
1122 content => 'branchcode',
1126 branchrelations => [
1128 indexname => 'PRIMARY',
1129 content => 'categorycode',
1133 branchrelations => [
1134 { indexname => 'PRIMARY',
1135 content => 'branchcode,categorycode',
1138 { indexname => 'branchcode',
1139 content => 'branchcode',
1141 { indexname => 'categorycode',
1142 content => 'categorycode',
1146 { indexname => 'PRIMARY',
1147 content => 'currency',
1153 indexname => 'categorycode',
1154 content => 'categorycode',
1158 { indexname => 'homebranch',
1159 content => 'homebranch',
1161 { indexname => 'holdingbranch',
1162 content => 'holdingbranch',
1167 indexname => 'itemtype',
1168 content => 'itemtype',
1172 { indexname => 'shelfnumber',
1173 content => 'shelfnumber',
1175 { indexname => 'itemnumber',
1176 content => 'itemnumber',
1180 { indexname => 'PRIMARY',
1187 my %foreign_keys = (
1189 # { key => 'the key in table' (must be indexed)
1190 # foreigntable => 'the foreigntable name', # (the parent)
1191 # foreignkey => 'the foreign key column(s)' # (in the parent)
1192 # onUpdate => 'CASCADE|SET NULL|NO ACTION| RESTRICT',
1193 # onDelete => 'CASCADE|SET NULL|NO ACTION| RESTRICT',
1196 branchrelations => [
1197 { key => 'branchcode',
1198 foreigntable => 'branches',
1199 foreignkey => 'branchcode',
1200 onUpdate => 'CASCADE',
1201 onDelete => 'CASCADE',
1203 { key => 'categorycode',
1204 foreigntable => 'branchcategories',
1205 foreignkey => 'categorycode',
1206 onUpdate => 'CASCADE',
1207 onDelete => 'CASCADE',
1211 { key => 'shelfnumber',
1212 foreigntable => 'bookshelf',
1213 foreignkey => 'shelfnumber',
1214 onUpdate => 'CASCADE',
1215 onDelete => 'CASCADE',
1217 { key => 'itemnumber',
1218 foreigntable => 'items',
1219 foreignkey => 'itemnumber',
1220 onUpdate => 'CASCADE',
1221 onDelete => 'CASCADE',
1224 # onDelete is RESTRICT on reference tables (branches, itemtype) as we don't want items to be
1225 # easily deleted, but branches/itemtype not too easy to empty...
1227 { key => 'biblionumber',
1228 foreigntable => 'biblio',
1229 foreignkey => 'biblionumber',
1230 onUpdate => 'CASCADE',
1231 onDelete => 'CASCADE',
1233 { key => 'itemtype',
1234 foreigntable => 'itemtypes',
1235 foreignkey => 'itemtype',
1236 onUpdate => 'CASCADE',
1237 onDelete => 'RESTRICT',
1241 { key => 'biblioitemnumber',
1242 foreigntable => 'biblioitems',
1243 foreignkey => 'biblioitemnumber',
1244 onUpdate => 'CASCADE',
1245 onDelete => 'CASCADE',
1247 { key => 'homebranch',
1248 foreigntable => 'branches',
1249 foreignkey => 'branchcode',
1250 onUpdate => 'CASCADE',
1251 onDelete => 'RESTRICT',
1253 { key => 'holdingbranch',
1254 foreigntable => 'branches',
1255 foreignkey => 'branchcode',
1256 onUpdate => 'CASCADE',
1257 onDelete => 'RESTRICT',
1261 { key => 'booksellerid',
1262 foreigntable => 'aqbooksellers',
1264 onUpdate => 'CASCADE',
1265 onDelete => 'RESTRICT',
1269 { key => 'basketno',
1270 foreigntable => 'aqbasket',
1271 foreignkey => 'basketno',
1272 onUpdate => 'CASCADE',
1273 onDelete => 'CASCADE',
1275 { key => 'biblionumber',
1276 foreigntable => 'biblio',
1277 foreignkey => 'biblionumber',
1278 onUpdate => 'SET NULL',
1279 onDelete => 'SET NULL',
1283 { key => 'listprice',
1284 foreigntable => 'currency',
1285 foreignkey => 'currency',
1286 onUpdate => 'CASCADE',
1287 onDelete => 'CASCADE',
1289 { key => 'invoiceprice',
1290 foreigntable => 'currency',
1291 foreignkey => 'currency',
1292 onUpdate => 'CASCADE',
1293 onDelete => 'CASCADE',
1296 aqorderbreakdown => [
1297 { key => 'ordernumber',
1298 foreigntable => 'aqorders',
1299 foreignkey => 'ordernumber',
1300 onUpdate => 'CASCADE',
1301 onDelete => 'CASCADE',
1303 { key => 'bookfundid',
1304 foreigntable => 'aqbookfund',
1305 foreignkey => 'bookfundid',
1306 onUpdate => 'CASCADE',
1307 onDelete => 'CASCADE',
1310 branchtransfers => [
1311 { key => 'frombranch',
1312 foreigntable => 'branches',
1313 foreignkey => 'branchcode',
1314 onUpdate => 'CASCADE',
1315 onDelete => 'CASCADE',
1317 { key => 'tobranch',
1318 foreigntable => 'branches',
1319 foreignkey => 'branchcode',
1320 onUpdate => 'CASCADE',
1321 onDelete => 'CASCADE',
1323 { key => 'itemnumber',
1324 foreigntable => 'items',
1325 foreignkey => 'itemnumber',
1326 onUpdate => 'CASCADE',
1327 onDelete => 'CASCADE',
1331 { key => 'categorycode',
1332 foreigntable => 'categories',
1333 foreignkey => 'categorycode',
1334 onUpdate => 'CASCADE',
1335 onDelete => 'CASCADE',
1337 { key => 'itemtype',
1338 foreigntable => 'itemtypes',
1339 foreignkey => 'itemtype',
1340 onUpdate => 'CASCADE',
1341 onDelete => 'CASCADE',
1344 issues => [ # constraint is SET NULL : when a borrower or an item is deleted, we keep the issuing record
1346 { key => 'borrowernumber',
1347 foreigntable => 'borrowers',
1348 foreignkey => 'borrowernumber',
1349 onUpdate => 'SET NULL',
1350 onDelete => 'SET NULL',
1352 { key => 'itemnumber',
1353 foreigntable => 'items',
1354 foreignkey => 'itemnumber',
1355 onUpdate => 'SET NULL',
1356 onDelete => 'SET NULL',
1360 { key => 'borrowernumber',
1361 foreigntable => 'borrowers',
1362 foreignkey => 'borrowernumber',
1363 onUpdate => 'CASCADE',
1364 onDelete => 'CASCADE',
1366 { key => 'biblionumber',
1367 foreigntable => 'biblio',
1368 foreignkey => 'biblionumber',
1369 onUpdate => 'CASCADE',
1370 onDelete => 'CASCADE',
1372 { key => 'itemnumber',
1373 foreigntable => 'items',
1374 foreignkey => 'itemnumber',
1375 onUpdate => 'CASCADE',
1376 onDelete => 'CASCADE',
1378 { key => 'branchcode',
1379 foreigntable => 'branches',
1380 foreignkey => 'branchcode',
1381 onUpdate => 'CASCADE',
1382 onDelete => 'CASCADE',
1385 borrowers => [ # foreign keys are RESTRICT as we don't want to delete borrowers when a branch is deleted
1386 # but prevent deleting a branch as soon as it has 1 borrower !
1387 { key => 'categorycode',
1388 foreigntable => 'categories',
1389 foreignkey => 'categorycode',
1390 onUpdate => 'RESTRICT',
1391 onDelete => 'RESTRICT',
1393 { key => 'branchcode',
1394 foreigntable => 'branches',
1395 foreignkey => 'branchcode',
1396 onUpdate => 'RESTRICT',
1397 onDelete => 'RESTRICT',
1400 deletedborrowers => [ # foreign keys are RESTRICT as we don't want to delete borrowers when a branch is deleted
1401 # but prevent deleting a branch as soon as it has 1 borrower !
1402 { key => 'categorycode',
1403 foreigntable => 'categories',
1404 foreignkey => 'categorycode',
1405 onUpdate => 'RESTRICT',
1406 onDelete => 'RESTRICT',
1408 { key => 'branchcode',
1409 foreigntable => 'branches',
1410 foreignkey => 'branchcode',
1411 onUpdate => 'RESTRICT',
1412 onDelete => 'RESTRICT',
1416 { key => 'borrowernumber',
1417 foreigntable => 'borrowers',
1418 foreignkey => 'borrowernumber',
1419 onUpdate => 'CASCADE',
1420 onDelete => 'CASCADE',
1422 { key => 'itemnumber',
1423 foreigntable => 'items',
1424 foreignkey => 'itemnumber',
1425 onUpdate => 'SET NULL',
1426 onDelete => 'SET NULL',
1429 auth_tag_structure => [
1430 { key => 'authtypecode',
1431 foreigntable => 'auth_types',
1432 foreignkey => 'authtypecode',
1433 onUpdate => 'CASCADE',
1434 onDelete => 'CASCADE',
1437 # FIXME : don't constraint auth_*_table and auth_word, as they may be replaced by zebra
1442 my %column_change = (
1446 from => 'emailaddress',
1451 from => 'streetaddress',
1453 after => 'initials',
1456 from => 'faxnumber',
1461 from => 'textmessaging',
1467 to => 'contactnote',
1468 after => 'opacnote',
1471 from => 'physstreet',
1476 from => 'streetcity',
1478 after => 'B_address',
1491 from => 'homezipcode',
1498 after => 'B_zipcode',
1503 after => 'dateenrolled',
1506 from => 'guarantor',
1507 to => 'guarantorid',
1508 after => 'contactname',
1511 from => 'altrelationship',
1512 to => 'relationship',
1513 after => 'borrowernotes',
1517 deletedborrowers => [
1519 from => 'emailaddress',
1524 from => 'streetaddress',
1526 after => 'initials',
1529 from => 'faxnumber',
1534 from => 'textmessaging',
1540 to => 'contactnote',
1541 after => 'opacnote',
1544 from => 'physstreet',
1549 from => 'streetcity',
1551 after => 'B_address',
1564 from => 'homezipcode',
1571 after => 'B_zipcode',
1576 after => 'dateenrolled',
1579 from => 'guarantor',
1580 to => 'guarantorid',
1581 after => 'contactname',
1584 from => 'altrelationship',
1585 to => 'relationship',
1586 after => 'borrowernotes',
1592 # MOVE all tables TO UTF-8 and innoDB
1593 $sth = $dbh->prepare("show table status");
1595 while ( my $table = $sth->fetchrow_hashref ) {
1596 next if $table->{Name} eq 'marc_word';
1597 next if $table->{Name} eq 'marc_subfield_table';
1598 next if $table->{Name} eq 'auth_word';
1599 next if $table->{Name} eq 'auth_subfield_table';
1600 if ($table->{Engine} ne 'InnoDB') {
1601 $dbh->do("ALTER TABLE $table->{Name} TYPE = innodb");
1602 print "moving $table->{Name} to InnoDB\n";
1604 unless ($table->{Collation} =~ /^utf8/) {
1605 print "moving $table->{Name} to utf8\n";
1606 $dbh->do("ALTER TABLE $table->{Name} CONVERT TO CHARACTER SET utf8");
1607 $dbh->do("ALTER TABLE $table->{Name} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
1608 # 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 !
1614 foreach my $table (keys %column_change) {
1615 $sth = $dbh->prepare("show columns from $table");
1618 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
1620 $types{$column}->{type} ="$type";
1621 $types{$column}->{null} = "$null";
1622 $types{$column}->{key} = "$key";
1623 $types{$column}->{default} = "$default";
1624 $types{$column}->{extra} = "$extra";
1626 my $tablerows = $column_change{$table};
1627 foreach my $row ( @$tablerows ) {
1628 if ($types{$row->{from}}->{type}) {
1629 print "altering $table $row->{from} to $row->{to}\n";
1630 # ALTER TABLE `borrowers` CHANGE `faxnumber` `fax` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
1631 # alter table `borrowers` change `faxnumber` `fax` type text null after phone
1633 "alter table `$table` change `$row->{from}` `$row->{to}` $types{$row->{from}}->{type} ".
1634 ($types{$row->{from}}->{null} eq 'YES'?" NULL":" NOT NULL").
1635 ($types{$row->{from}}->{default}?" default ".$types{$row->{from}}->{default}:"").
1636 "$types{$row->{from}}->{extra} after $row->{after} ";
1643 # Enter here the field you want to delete from DB.
1644 # FIXME :: there is a %uselessfield before which seems doing the same things.
1645 my %fieldtodelete = (
1646 # tablename => [fieldname1,fieldname2,...]
1650 print "removing some unused fields...\n";
1651 foreach my $table ( keys %fieldtodelete ) {
1652 foreach my $field ( @{$fieldtodelete{$table}} ){
1653 print "removing ".$field." from ".$table;
1654 my $sth = $dbh->prepare("ALTER TABLE $table DROP $field");
1657 print "Error : $sth->errstr \n";
1662 # Enter here the line you want to remove from DB.
1663 my %linetodelete = (
1664 # table name => where clause.
1665 userflags => "bit = 8", # delete the 'reserveforself' flags
1669 #-------------------
1674 # Get version of MySQL database engine.
1675 my $mysqlversion = `mysqld --version`;
1676 $mysqlversion =~ /Ver (\S*) /;
1678 if ( $mysqlversion ge '3.23' ) {
1679 print "Could convert to MyISAM database tables...\n" unless $silent;
1682 #---------------------------------
1685 # Collect all tables into a list
1686 $sth = $dbh->prepare("show tables");
1688 while ( my ($table) = $sth->fetchrow ) {
1689 $existingtables{$table} = 1;
1693 # Now add any missing tables
1694 foreach $table ( keys %requiretables ) {
1695 unless ( $existingtables{$table} ) {
1696 print "Adding $table table...\n" unless $silent;
1697 my $sth = $dbh->prepare("create table $table $requiretables{$table}");
1700 print "Error : $sth->errstr \n";
1706 #---------------------------------
1709 foreach $table ( keys %requirefields ) {
1710 print "Check table $table\n" if $debug and not $silent;
1711 $sth = $dbh->prepare("show columns from $table");
1714 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
1716 $types{$column} = $type;
1718 foreach $column ( keys %{ $requirefields{$table} } ) {
1719 print " Check column $column [$types{$column}]\n" if $debug and not $silent;
1720 if ( !$types{$column} ) {
1722 # column doesn't exist
1723 print "Adding $column field to $table table...\n" unless $silent;
1724 $query = "alter table $table
1725 add column $column " . $requirefields{$table}->{$column};
1726 print "Execute: $query\n" if $debug;
1727 my $sti = $dbh->prepare($query);
1730 print "**Error : $sti->errstr \n";
1737 foreach $table ( keys %fielddefinitions ) {
1738 print "Check table $table\n" if $debug;
1739 $sth = $dbh->prepare("show columns from $table");
1742 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
1744 $definitions->{$column}->{type} = $type;
1745 $definitions->{$column}->{null} = $null;
1746 $definitions->{$column}->{null} = 'NULL' if $null eq 'YES';
1747 $definitions->{$column}->{key} = $key;
1748 $definitions->{$column}->{default} = $default;
1749 $definitions->{$column}->{extra} = $extra;
1751 my $fieldrow = $fielddefinitions{$table};
1752 foreach my $row (@$fieldrow) {
1753 my $field = $row->{field};
1754 my $type = $row->{type};
1755 my $null = $row->{null};
1756 # $null = 'YES' if $row->{null} eq 'NULL';
1757 my $key = $row->{key};
1758 my $default = $row->{default};
1759 # $default="''" unless $default;
1760 my $extra = $row->{extra};
1761 my $def = $definitions->{$field};
1762 my $after = ($row->{after}?" after ".$row->{after}:"");
1764 unless ( $type eq $def->{type}
1765 && $null eq $def->{null}
1766 && $key eq $def->{key}
1767 && $extra eq $def->{extra} )
1769 if ( $null eq '' ) {
1772 if ( $key eq 'PRI' ) {
1773 $key = 'PRIMARY KEY';
1775 unless ( $extra eq 'auto_increment' ) {
1779 # if it's a new column use "add", if it's an old one, use "change".
1781 if ($definitions->{$field}->{type}) {
1782 $action="change $field"
1786 # if it's a primary key, drop the previous pk, before altering the table
1787 print " alter or create $field in $table\n" unless $silent;
1789 if ($key ne 'PRIMARY KEY') {
1790 # warn "alter table $table $action $field $type $null $key $extra default $default $after";
1791 $query = "alter table $table $action $field $type $null $key $extra ".($default?"default ".$dbh->quote($default):"")." $after";
1793 # warn "alter table $table drop primary key, $action $field $type $null $key $extra default $default $after";
1794 # something strange : for indexes UNIQUE, they are reported as primary key here.
1795 # but if you try to run with drop primary key, it fails.
1796 # thus, we run the query twice, one will fail, one will succeed.
1798 $query="alter table $table drop primary key, $action $field $type $null $key $extra ".($default?"default ".$dbh->quote($default):"")." $after";
1799 $query="alter table $table $action $field $type $null $key $extra ".($default?"default ".$dbh->quote($default):"")." $after";
1806 print "removing some unused data...\n";
1807 foreach my $table ( keys %linetodelete ) {
1808 foreach my $where ( @{linetodelete{$table}} ){
1809 print "DELETE FROM ".$table." where ".$where;
1811 my $sth = $dbh->prepare("DELETE FROM $table where $where");
1814 print "Error : $sth->errstr \n";
1819 # Populate tables with required data
1821 # synch table and deletedtable.
1822 foreach my $table (('borrowers','items','biblio','biblioitems')) {
1823 my %deletedborrowers;
1824 print "synch'ing $table and deleted$table\n";
1825 $sth = $dbh->prepare("show columns from deleted$table");
1827 while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ) {
1828 $deletedborrowers{$column}=1;
1830 $sth = $dbh->prepare("show columns from $table");
1833 while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ) {
1834 unless ($deletedborrowers{$column}) {
1835 my $newcol="alter table deleted$table add $column $type";
1836 if ($null eq 'YES') {
1837 $newcol .= " NULL ";
1839 $newcol .= " NOT NULL ";
1841 $newcol .= "default ".$dbh->quote($default) if $default;
1842 $newcol .= " after $previous" if $previous;
1844 print "creating column $column\n";
1850 # update publisheddate
1852 $sth = $dbh->prepare("select count(*) from serial where publisheddate is NULL");
1854 my ($emptypublished) = $sth->fetchrow;
1855 if ($emptypublished) {
1856 print "Updating publisheddate\n";
1857 $dbh->do("update serial set publisheddate=planneddate where publisheddate is NULL");
1859 foreach my $table ( keys %tabledata ) {
1860 print "Checking for data required in table $table...\n" unless $silent;
1861 my $tablerows = $tabledata{$table};
1862 foreach my $row (@$tablerows) {
1863 my $uniquefieldrequired = $row->{uniquefieldrequired};
1864 my $uniquevalue = $row->{$uniquefieldrequired};
1865 my $forceupdate = $row->{forceupdate};
1868 "select $uniquefieldrequired from $table where $uniquefieldrequired=?"
1870 $sth->execute($uniquevalue);
1872 foreach my $field (keys %$forceupdate) {
1873 if ($forceupdate->{$field}) {
1874 my $sth=$dbh->prepare("update systempreferences set $field=? where $uniquefieldrequired=?");
1875 $sth->execute($row->{$field}, $uniquevalue);
1879 print "Adding row to $table: " unless $silent;
1883 foreach my $field ( keys %$row ) {
1884 next if $field eq 'uniquefieldrequired';
1885 next if $field eq 'forceupdate';
1886 my $value = $row->{$field};
1887 push @values, $value;
1888 print " $field => $value" unless $silent;
1889 $fieldlist .= "$field,";
1890 $placeholders .= "?,";
1892 print "\n" unless $silent;
1893 $fieldlist =~ s/,$//;
1894 $placeholders =~ s/,$//;
1895 print "insert into $table ($fieldlist) values ($placeholders)";
1898 "insert into $table ($fieldlist) values ($placeholders)");
1899 $sth->execute(@values);
1905 # check indexes and create them when needed
1907 print "Checking for index required...\n" unless $silent;
1908 foreach my $table ( keys %indexes ) {
1910 # read all indexes from $table
1912 $sth = $dbh->prepare("show index from $table");
1914 my %existingindexes;
1915 while ( my ( $table, $non_unique, $key_name, $Seq_in_index, $Column_name, $Collation, $cardinality, $sub_part, $Packed, $comment ) = $sth->fetchrow ) {
1916 $existingindexes{$key_name} = 1;
1918 # read indexes to check
1919 my $tablerows = $indexes{$table};
1920 foreach my $row (@$tablerows) {
1921 my $key_name=$row->{indexname};
1922 if ($existingindexes{$key_name} eq 1) {
1923 # print "$key_name existing";
1925 print "\tCreating index $key_name in $table\n";
1927 if ($row->{indexname} eq 'PRIMARY') {
1928 $sql = "alter table $table ADD PRIMARY KEY ($row->{content})";
1930 $sql = "alter table $table ADD INDEX $key_name ($row->{content}) $row->{type}";
1933 print "Error $sql : $dbh->err \n" if $dbh->err;
1939 # check foreign keys and create them when needed
1941 print "Checking for foreign keys required...\n" unless $silent;
1942 foreach my $table ( keys %foreign_keys ) {
1944 # read all indexes from $table
1946 $sth = $dbh->prepare("show table status like '$table'");
1948 my $stat = $sth->fetchrow_hashref;
1949 # read indexes to check
1950 my $tablerows = $foreign_keys{$table};
1951 foreach my $row (@$tablerows) {
1952 my $foreign_table=$row->{foreigntable};
1953 if ($stat->{'Comment'} =~/$foreign_table/) {
1954 # print "$foreign_table existing\n";
1956 print "\tCreating foreign key $foreign_table in $table\n";
1957 # first, drop any orphan value in child table
1958 if ($row->{onDelete} ne "RESTRICT") {
1959 my $sql = "delete from $table where $row->{key} not in (select $row->{foreignkey} from $row->{foreigntable})";
1961 print "SQL ERROR: $sql : $dbh->err \n" if $dbh->err;
1963 my $sql="alter table $table ADD FOREIGN KEY $row->{key} ($row->{key}) REFERENCES $row->{foreigntable} ($row->{foreignkey})";
1964 $sql .= " on update ".$row->{onUpdate} if $row->{onUpdate};
1965 $sql .= " on delete ".$row->{onDelete} if $row->{onDelete};
1968 print "====================
1969 An error occured during :
1971 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).
1972 You can find those values with select
1973 \t$table.* from $table where $row->{key} not in (select $row->{foreignkey} from $row->{foreigntable})
1974 ====================\n
1980 # now drop useless tables
1981 foreach $table ( @TableToDelete ) {
1982 if ( $existingtables{$table} ) {
1983 print "Dropping unused table $table\n" if $debug and not $silent;
1984 $dbh->do("drop table $table");
1986 print "Error : $dbh->errstr \n";
1995 # create frameworkcode row in biblio table & fill it with marc_biblio.frameworkcode.
1998 # 1st, get how many biblio we will have to do...
1999 $sth = $dbh->prepare('select count(*) from marc_biblio');
2001 my ($totaltodo) = $sth->fetchrow;
2003 $sth = $dbh->prepare("show columns from biblio");
2006 my $bibliofwexist=0;
2007 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ){
2008 $bibliofwexist=1 if $column eq 'frameworkcode';
2010 unless ($bibliofwexist) {
2011 print "moving biblioframework to biblio table\n";
2012 $dbh->do('ALTER TABLE `biblio` ADD `frameworkcode` VARCHAR( 4 ) NOT NULL AFTER `biblionumber`');
2013 $sth = $dbh->prepare('select biblionumber,frameworkcode from marc_biblio');
2015 my $sth_update = $dbh->prepare('update biblio set frameworkcode=? where biblionumber=?');
2017 while (my ($biblionumber,$frameworkcode) = $sth->fetchrow) {
2018 $sth_update->execute($frameworkcode,$biblionumber);
2020 print "\r$totaldone / $totaltodo" unless ($totaldone % 100);
2025 # at last, remove useless fields
2026 foreach $table ( keys %uselessfields ) {
2027 my @fields = split /,/,$uselessfields{$table};
2030 foreach my $fieldtodrop (@fields) {
2031 $fieldtodrop =~ s/\t//g;
2032 $fieldtodrop =~ s/\n//g;
2034 $sth = $dbh->prepare("show columns from $table");
2036 while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
2038 $exists =1 if ($column eq $fieldtodrop);
2041 print "deleting $fieldtodrop field in $table...\n" unless $silent;
2042 my $sth = $dbh->prepare("alter table $table drop $fieldtodrop");
2049 # Changing aqbookfund's primary key
2051 $sth=$dbh->prepare("ALTER TABLE `aqbookfund` DROP PRIMARY KEY , ADD PRIMARY KEY ( `bookfundid` , `branchcode` ) ;");
2059 # Revision 1.171 2007/07/02 02:30:16 rangi
2060 # Fix for bug 1296, making surnames uppercase a systems preference
2062 # Revision 1.170 2007/06/26 13:25:37 tipaul
2063 # removing some useless tables from updatedatabase
2065 # Revision 1.169 2007/06/26 09:23:26 tipaul
2066 # improving OpacBrowser systempref explanation
2068 # Revision 1.168 2007/06/25 15:02:31 tipaul
2069 # missing field declaration
2071 # Revision 1.167 2007/06/15 13:09:08 toins
2072 # bugfix : bibliotitems.dewey & deletedbiblioitems.dewey mustn't be double(8,6).
2074 # Revision 1.166 2007/06/08 09:40:12 toins
2075 # bug fix : items.homebranch must be VARCHAR(10)
2077 # Revision 1.165 2007/05/23 16:33:10 tipaul
2078 # skip move to innoDB for the 4 22 tables, that are used to store MARC records, are useless in Koha 3.0 The process is very very long, so the updatedatabase should speed up a lot (by long I mean 1 hour on my Dual core with SCSI disk, for a 50 000 biblios long table
2080 # Revision 1.164 2007/05/04 16:24:09 tipaul
2081 # various bugfixes on parameters modules + adding default NoZebraIndexes systempreference if it's empty
2083 # Revision 1.163 2007/05/02 16:44:31 tipaul
2084 # NoZebra SQL index management :
2085 # * adding 3 subs in Biblio.pm
2086 # - GetNoZebraIndexes, that get the index structure in a new systempreference (added with this commit)
2087 # - _DelBiblioNoZebra, that retrieve all index entries for a biblio and remove in a variable the biblio reference
2088 # - _AddBiblioNoZebra, that add index entries for a biblio.
2089 # Note that the 2 _Add and _Del subs work only in a hash variable, to speed up things in case of a modif (ie : delete+add). The effective SQL update is done in the ModZebra sub (that existed before, and dealed with zebra index).
2090 # I think the code has to be more deeply tested, but it works at least partially.
2092 # Revision 1.162 2007/04/30 16:16:50 tipaul
2093 # bugfix for updatedatabase : when there is no default value (NULL fields) + removing bibliothesaurus table+adding NoZebra systempref (False by default)
2095 # Revision 1.161 2007/04/13 16:27:55 hdl
2096 # Adding Version variable to systempreferences.
2098 # Revision 1.160 2007/03/19 18:35:13 toins
2099 # - adding default value in marc_subfield_structure.
2100 # - now marc_subfields_structure displays subfields in tab view.
2102 # Revision 1.159 2007/03/16 01:25:09 kados
2103 # Using my precrash CVS copy I did the following:
2105 # cvs -z3 -d:ext:kados@cvs.savannah.nongnu.org:/sources/koha co -P koha
2106 # find koha.precrash -type d -name "CVS" -exec rm -v {} \;
2107 # cp -r koha.precrash/* koha/
2111 # This should in theory put us right back where we were before the crash
2113 # Revision 1.159 2007/03/12 17:52:30 rych
2114 # add pri key to userflags
2116 # Revision 1.158 2007/03/09 15:14:57 tipaul
2117 # rel_3_0 moved to HEAD
2119 # Revision 1.157.2.56 2007/01/31 16:22:54 btoumi
2120 # -add possibility to use isbn with length of 13 characters
2121 # for Import datas in the reservoir.
2122 # -modify isbn field in marc_breeding table (varchar 13)
2123 # -add isbn filter (no - )when u read a notice from reservoir
2124 # -add filter to have right field 100
2126 # Revision 1.157.2.55 2007/01/30 10:50:19 tipaul
2127 # adding 2 usefull indexes to biblioitems table
2129 # Revision 1.157.2.54 2007/01/29 16:45:52 toins
2130 # * adding a new default authorised value : SUGGEST.
2131 # SUGGEST give some reasons to accept or reject a suggestion.
2133 # * default value for borrowersMandatoryfield syspref is now "cardnumber|surname|adress"
2135 # Revision 1.157.2.53 2007/01/26 20:48:37 hdl
2136 # Serials management : Bugfixes + improvements.
2137 # - Partial dates are now managed
2138 # - next Date Calculation with irregularity tested for 1 week and 1 month.
2139 # - manage if subscription is abouttoexpire or expired.
2140 # - Adding some information on serials pages about subscription.
2141 # - Managing irregularity with numbers.
2142 # - Adding Internal Notes in subscription management.
2143 # - Repeating Button above pages.
2145 # Please run Updatedatabase to change irregularity and add internalnotes field to subscription
2147 # Revision 1.157.2.52 2007/01/24 13:57:26 tipaul
2148 # - setting supplierid to auto_increment (HDL : could you check that is works, i'm not 100% sure)
2149 # - removing 22 -> 30 marc_subfield_table -> marcxml stuff, it's now in misc/migration_tools/22_to_30/
2151 # Revision 1.157.2.51 2007/01/18 09:58:45 tipaul
2152 # defaulting NOT NULL fields (to '')
2154 # Revision 1.157.2.50 2007/01/18 09:39:21 tipaul
2155 # issuedate must be defaulted with ' '
2157 # Revision 1.157.2.49 2007/01/18 09:37:30 tipaul
2158 # removing 2 field definitions that were here twice
2160 # Revision 1.157.2.48 2007/01/15 09:55:40 toins
2161 # adding a new logging systempref : FinesLog.
2163 # Revision 1.157.2.47 2007/01/12 18:09:49 toins
2166 # Revision 1.157.2.46 2007/01/11 14:35:39 tipaul
2167 # adding Opac Browser feature : the build_browser_and_cloud.pl script will :
2168 # - fill the browser table, that enable browsing, digit by digit of a given category, the catalogue. A complete dewey classification is provided in the script, active only for french libraries, of course (although, for instance, the script check that the catalogue is in english for developping convenience)
2169 # - fill the tags table, that contains the subject cloud.
2171 # The cloud part is a copy of the previous build_tags.pl script that can be deleted : those 2 scripts require to parse all the catalogue to extract interesting data, so they are long. It's useless to parse the catalogue twice !
2173 # The commit also add the systempreference to hide/show the OpacBrowse in database & in systempref management script.
2175 # IMPROVEMENTS to do :
2176 # - the script that builds the tables can be improved to update only last week biblios (at the price of a small error in value links, but it's not a problem).
2177 # - add, in parameters section, a place to edit browser descriptions. The build script has to be updated to to avoid deleting existing browser descriptions.
2179 # Revision 1.157.2.45 2007/01/10 16:52:52 toins
2180 # Value for Log Features syspref are set to 0 by default.
2182 # Revision 1.157.2.44 2007/01/10 16:31:15 toins
2183 # new systems preferences :
2184 # - CataloguingLog (log the update/creation/deletion of a notice if set to 1)
2185 # - BorrowersLog ( idem for borrowers )
2186 # - IssueLog (log all issue if set to 1)
2187 # - ReturnLog (log all return if set to 1)
2188 # - SusbcriptionLog (log all creation/deletion/update of a subcription)
2190 # All of theses are in a new tab called 'LOGFeatures' in systempreferences.pl
2192 # Revision 1.157.2.43 2007/01/10 14:13:17 toins
2193 # opac_news.displayed is replaced by opac_news.number.
2194 # This field say how are ordered the news on the template.
2196 # Revision 1.157.2.42 2007/01/09 14:09:01 toins
2197 # 2 field added to opac_news.('expirationdate' and 'displayed').