constrainttype, branchcode, notificationdate,
reminderdate, cancellationdate, reservenotes,
priority, found, timestamp, itemnumber,
- waitingdate, expirationdate, lowestPriority
+ waitingdate, expirationdate, lowestPriority,
+ suspend, suspend_until
) SELECT
borrowernumber, reservedate, biblionumber,
constrainttype, branchcode, notificationdate,
reminderdate, cancellationdate, reservenotes,
priority, found, timestamp, itemnumber,
- waitingdate, expirationdate, lowestPriority
+ waitingdate, expirationdate, lowestPriority,
+ suspend, suspend_until
FROM old_reserves ORDER BY reservedate
");
$dbh->do('SET @ai = ( SELECT MAX( reserve_id ) FROM tmp_reserves )');
constrainttype, branchcode, notificationdate,
reminderdate, cancellationdate, reservenotes,
priority, found, timestamp, itemnumber,
- waitingdate, expirationdate, lowestPriority
+ waitingdate, expirationdate, lowestPriority,
+ suspend, suspend_until
) SELECT
borrowernumber, reservedate, biblionumber,
constrainttype, branchcode, notificationdate,
reminderdate, cancellationdate, reservenotes,
priority, found, timestamp, itemnumber,
- waitingdate, expirationdate, lowestPriority
+ waitingdate, expirationdate, lowestPriority,
+ suspend, suspend_until
FROM reserves ORDER BY reservedate
");
$dbh->do('TRUNCATE reserves');
$dbh->do('ALTER TABLE reserves ADD reserve_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
- $dbh->do('INSERT INTO reserves SELECT * FROM tmp_reserves WHERE reserve_id > @ai');
+ $dbh->do('INSERT INTO reserves SELECT * FROM tmp_reserves WHERE reserve_id > COALESCE(@ai, 0)');
$dbh->do('DROP TABLE tmp_reserves');
$dbh->do('COMMIT');
SetVersion($DBversion);
}
-
$DBversion = "3.09.00.047";
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
# to preserve default behaviour as best as possible, set this new preference differently depending on whether IndependantBranches is set or not
$DBversion = "3.11.00.016";
if ( CheckVersion($DBversion) ) {
$dbh->do(q{
- UPDATE userflags SET flagdesc="<b>Required for staff login.</b> Staff access, allows viewing of catalogue in staff client." where flag="catalogue";
+ UPDATE userflags SET flagdesc="<b>Required for staff login.</b> Staff access, allows viewing of catalogue in staff client." where flagdesc="Modify login / permissions for staff users";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Edit Authorities" where flag="editauthorities";
+ UPDATE userflags SET flagdesc="Edit Authorities" where flagdesc="Allow to edit authorities";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Allow access to the reports module" where flag="reports";
+ UPDATE userflags SET flagdesc="Allow access to the reports module" where flagdesc="Allow to access to the reports module";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Set library management parameters (deprecated)" where flag="management";
+ UPDATE userflags SET flagdesc="Set library management parameters (deprecated)" where flagdesc="Set library management parameters";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Manage serial subscriptions" where flag="serials";
+ UPDATE userflags SET flagdesc="Manage serial subscriptions" where flagdesc="Allow to manage serials subscriptions";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Manage patrons fines and fees" where flag="updatecharges";
+ UPDATE userflags SET flagdesc="Manage patrons fines and fees" where flagdesc="Update borrower charges";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Check out and check in items" where flag="circulate";
+ UPDATE userflags SET flagdesc="Check out and check in items" where flagdesc="Circulate books";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Manage Koha system settings (Administration panel)" where flag="parameters";
+ UPDATE userflags SET flagdesc="Manage Koha system settings (Administration panel)" where flagdesc="Set Koha system parameters";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Add or modify patrons" where flag="borrowers";
+ UPDATE userflags SET flagdesc="Add or modify patrons" where flagdesc="Add or modify borrowers";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Use all tools (expand for granular tools permissions)" where flag="tools";
+ UPDATE userflags SET flagdesc="Use all tools (expand for granular tools permissions)" where flagdesc="Use tools (export, import, barcodes)";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Allow staff members to modify permissions for other staff members" where flag="staffaccess";
+ UPDATE userflags SET flagdesc="Allow staff members to modify permissions for other staff members" where flagdesc="Set user permissions";
});
$dbh->do(q{
- UPDATE userflags SET flagdesc="Perform batch modification of patrons" where flag="edit_patrons";
+ UPDATE permissions SET description="Perform batch modification of patrons" where description="Perform batch modifivation of patrons";
});
- print "Upgrade to $DBversion done (Bug 9382 - refresh permission descriptions to make more sense)\n";
+ print "Upgrade to $DBversion done (Bug 9382 (updated with bug 9745) - refresh permission descriptions to make more sense)\n";
SetVersion ($DBversion);
}
}
$DBversion = "3.11.00.019";
-if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+if ( CheckVersion($DBversion) ) {
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorityField100', 'afrey50 ba0', NULL, NULL, 'Textarea')");
print "Upgrade to $DBversion done (Bug 9145 - Add syspref UNIMARCAuthorityField100)\n";
SetVersion ($DBversion);
}
$DBversion = "3.11.00.020";
-if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+if ( CheckVersion($DBversion) ) {
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UNIMARCField100Language', 'fre','UNIMARC field 100 default language',NULL,'short')");
print "Upgrade to $DBversion done (Bug 8347 - Koha forces UNIMARC 100 field code language to 'fre')\n";
SetVersion($DBversion);
SetVersion($DBversion);
}
+$DBversion = "3.11.00.XXX";
+if(CheckVersion($DBversion)) {
+ $dbh->do(
+"INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowHoldNotes',0,'Show hold notes on OPAC','','YesNo')"
+ );
+ print "Upgrade to $DBversion done (Bug 9722: Allow users to add notes when placing a hold in OPAC)\n";
+ SetVersion($DBversion);
+}
+
$DBversion = "3.11.00.024";
if ( CheckVersion($DBversion) ) {
}
$DBversion = "3.11.00.100";
-if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+if ( CheckVersion($DBversion) ) {
print "Upgrade to $DBversion done (3.12-alpha release)\n";
- SetVersion ($DBversion);
+ SetVersion ($DBversion);
}
$DBversion = "3.11.00.101";
}
$DBversion = "3.11.00.104";
-if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+if ( CheckVersion($DBversion) ) {
print "Upgrade to $DBversion done (3.12-alpha2 release)\n";
SetVersion ($DBversion);
}
$DBversion = "3.11.00.106";
-if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+if ( CheckVersion($DBversion) ) {
$dbh->do("INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES ('19', 'plugins', 'Koha plugins', '0')");
$dbh->do("INSERT INTO permissions (module_bit, code, description) VALUES
('19', 'manage', 'Manage plugins ( install / uninstall )'),
}
$DBversion = "3.11.00.113";
-if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+if ( CheckVersion($DBversion) ) {
$dbh->do(q{
ALTER TABLE branchcategories ADD show_in_pulldown BOOLEAN NOT NULL DEFAULT '0',
ADD INDEX ( show_in_pulldown )
SetVersion ($DBversion);
}
-$DBversion = "3.11.00.114";
-if ( CheckVersion($DBversion) ) {
- $dbh->do(qq|
- DROP TABLE IF EXISTS subscription_frequencies
- |);
- $dbh->do(qq|
- CREATE TABLE subscription_frequencies (
- id INTEGER NOT NULL AUTO_INCREMENT,
- description TEXT NOT NULL,
- displayorder INT DEFAULT NULL,
- unit ENUM('day','week','month','year') DEFAULT NULL,
- unitsperissue INTEGER NOT NULL DEFAULT '1',
- issuesperunit INTEGER NOT NULL DEFAULT '1',
- PRIMARY KEY (id)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
- |);
-
- $dbh->do(qq|
- DROP TABLE IF EXISTS subscription_numberpatterns
- |);
- $dbh->do(qq|
- CREATE TABLE subscription_numberpatterns (
- id INTEGER NOT NULL AUTO_INCREMENT,
- label VARCHAR(255) NOT NULL,
- displayorder INTEGER DEFAULT NULL,
- description TEXT NOT NULL,
- numberingmethod VARCHAR(255) NOT NULL,
- label1 VARCHAR(255) DEFAULT NULL,
- add1 INTEGER DEFAULT NULL,
- every1 INTEGER DEFAULT NULL,
- whenmorethan1 INTEGER DEFAULT NULL,
- setto1 INTEGER DEFAULT NULL,
- numbering1 VARCHAR(255) DEFAULT NULL,
- label2 VARCHAR(255) DEFAULT NULL,
- add2 INTEGER DEFAULT NULL,
- every2 INTEGER DEFAULT NULL,
- whenmorethan2 INTEGER DEFAULT NULL,
- setto2 INTEGER DEFAULT NULL,
- numbering2 VARCHAR(255) DEFAULT NULL,
- label3 VARCHAR(255) DEFAULT NULL,
- add3 INTEGER DEFAULT NULL,
- every3 INTEGER DEFAULT NULL,
- whenmorethan3 INTEGER DEFAULT NULL,
- setto3 INTEGER DEFAULT NULL,
- numbering3 VARCHAR(255) DEFAULT NULL,
- PRIMARY KEY (id)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
- |);
-
- $dbh->do(qq|
- INSERT INTO subscription_frequencies (description, unit, unitsperissue, issuesperunit, displayorder)
- VALUES
- ('2/day', 'day', 1, 2, 1),
- ('1/day', 'day', 1, 1, 2),
- ('3/week', 'week', 1, 3, 3),
- ('1/week', 'week', 1, 1, 4),
- ('1/2 weeks', 'week', 2, 1, 5),
- ('1/3 weeks', 'week', 3, 1, 6),
- ('1/month', 'month', 1, 1, 7),
- ('1/2 months', 'month', 2, 1, 8),
- ('1/3 months', 'month', 3, 1, 9),
- ('2/year', 'month', 6, 1, 10),
- ('1/year', 'year', 1, 1, 11),
- ('1/2 year', 'year', 2, 1, 12),
- ('Irregular', NULL, 1, 1, 13)
- |);
-
- # Used to link existing subscription to newly created frequencies
- my $frequencies_mapping = { # keys are old frequency numbers, values are the new ones
- 1 => 2, # daily (n/week)
- 2 => 4, # 1/week
- 3 => 5, # 1/2 weeks
- 4 => 6, # 1/3 weeks
- 5 => 7, # 1/month
- 6 => 8, # 1/2 months (6/year)
- 7 => 9, # 1/3 months (1/quarter)
- 8 => 9, # 1/quarter (seasonal)
- 9 => 10, # 2/year
- 10 => 11, # 1/year
- 11 => 12, # 1/2 years
- 12 => 1, # 2/day
- 16 => 13, # Without periodicity
- 32 => 13, # Irregular
- 48 => 13 # Unknown
- };
-
- $dbh->do(qq|
- INSERT INTO subscription_numberpatterns
- (label, displayorder, description, numberingmethod,
- label1, add1, every1, whenmorethan1, setto1, numbering1,
- label2, add2, every2, whenmorethan2, setto2, numbering2,
- label3, add3, every3, whenmorethan3, setto3, numbering3)
- VALUES
- ('Number', 1, 'Simple Numbering method', 'No.{X}',
- 'Number', 1, 1, 99999, 1, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL),
-
- ('Volume, Number, Issue', 2, 'Volume Number Issue 1', 'Vol.{X}, Number {Y}, Issue {Z}',
- 'Volume', 1, 48, 99999, 1, NULL,
- 'Number', 1, 4, 12, 1, NULL,
- 'Issue', 1, 1, 4, 1, NULL),
-
- ('Volume, Number', 3, 'Volume Number 1', 'Vol {X}, No {Y}',
- 'Volume', 1, 12, 99999, 1, NULL,
- 'Number', 1, 1, 12, 1, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL),
-
- ('Seasonal', 4, 'Season Year', '{X} {Y}',
- 'Season', 1, 1, 3, 0, 'season',
- 'Year', 1, 4, 99999, 1, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL)
- |);
-
- $dbh->do(qq|
- ALTER TABLE subscription
- MODIFY COLUMN numberpattern INTEGER DEFAULT NULL,
- MODIFY COLUMN periodicity INTEGER DEFAULT NULL
- |);
-
- # Update existing subscriptions
-
- my $query = qq|
- SELECT subscriptionid, periodicity, numberingmethod,
- add1, every1, whenmorethan1, setto1,
- add2, every2, whenmorethan2, setto2,
- add3, every3, whenmorethan3, setto3
- FROM subscription
- ORDER BY subscriptionid
- |;
- my $sth = $dbh->prepare($query);
- $sth->execute;
- my $insert_numberpatterns_sth = $dbh->prepare(qq|
- INSERT INTO subscription_numberpatterns
- (label, displayorder, description, numberingmethod,
- label1, add1, every1, whenmorethan1, setto1, numbering1,
- label2, add2, every2, whenmorethan2, setto2, numbering2,
- label3, add3, every3, whenmorethan3, setto3, numbering3)
- VALUES
- (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
- |);
- my $check_numberpatterns_sth = $dbh->prepare(qq|
- SELECT * FROM subscription_numberpatterns
- WHERE add1 = ? AND add2 = ? AND add3 = ?
- AND every1 = ? AND every2 = ? AND every3 = ?
- AND whenmorethan1 = ? AND whenmorethan2 = ? AND whenmorethan3 = ?
- AND setto1 = ? AND setto2 = ? AND setto3 = ?
- AND numberingmethod = ?
- LIMIT 1
- |);
- my $update_subscription_sth = $dbh->prepare(qq|
- UPDATE subscription
- SET numberpattern = ?,
- periodicity = ?
- WHERE subscriptionid = ?
- |);
-
- my $i = 1;
- while(my $sub = $sth->fetchrow_hashref) {
- $check_numberpatterns_sth->execute(
- $sub->{add1}, $sub->{add2}, $sub->{add3},
- $sub->{every1}, $sub->{every2}, $sub->{every3},
- $sub->{whenmorethan1}, $sub->{whenmorethan2}, $sub->{whenmorethan3},
- $sub->{setto1}, $sub->{setto2}, $sub->{setto3},
- $sub->{numberingmethod}
- );
- my $p = $check_numberpatterns_sth->fetchrow_hashref;
- if (defined $p) {
- # Pattern already exists, link to it
- $update_subscription_sth->execute($p->{id},
- $frequencies_mapping->{$sub->{periodicity}},
- $sub->{subscriptionid});
- } else {
- # Create a new numbering pattern for this subscription
- my $ok = $insert_numberpatterns_sth->execute(
- "Backup pattern $i", 4+$i, "Automatically created pattern by updatedatabase", $sub->{numberingmethod},
- "X", $sub->{add1}, $sub->{every1}, $sub->{whenmorethan1}, $sub->{setto1}, undef,
- "Y", $sub->{add2}, $sub->{every2}, $sub->{whenmorethan2}, $sub->{setto2}, undef,
- "Z", $sub->{add3}, $sub->{every3}, $sub->{whenmorethan3}, $sub->{setto3}, undef
- );
- if($ok) {
- my $id = $dbh->last_insert_id(undef, undef, 'subscription_numberpatterns', undef);
- # Link to subscription_numberpatterns and subscription_frequencies
- $update_subscription_sth->execute($id,
- $frequencies_mapping->{$sub->{periodicity}},
- $sub->{subscriptionid});
- }
- $i++;
- }
- }
-
- # Remove now useless columns
- $dbh->do(qq|
- ALTER TABLE subscription
- DROP COLUMN numberingmethod,
- DROP COLUMN add1,
- DROP COLUMN every1,
- DROP COLUMN whenmorethan1,
- DROP COLUMN setto1,
- DROP COLUMN add2,
- DROP COLUMN every2,
- DROP COLUMN whenmorethan2,
- DROP COLUMN setto2,
- DROP COLUMN add3,
- DROP COLUMN every3,
- DROP COLUMN whenmorethan3,
- DROP COLUMN setto3,
- DROP COLUMN dow,
- DROP COLUMN issuesatonce,
- DROP COLUMN hemisphere,
- ADD COLUMN countissuesperunit INTEGER NOT NULL DEFAULT 1 AFTER periodicity,
- ADD COLUMN skip_serialseq BOOLEAN NOT NULL DEFAULT 0 AFTER irregularity,
- ADD COLUMN locale VARCHAR(80) DEFAULT NULL AFTER numberpattern,
- ADD CONSTRAINT subscription_ibfk_1 FOREIGN KEY (periodicity) REFERENCES subscription_frequencies (id) ON DELETE SET NULL ON UPDATE CASCADE,
- ADD CONSTRAINT subscription_ibfk_2 FOREIGN KEY (numberpattern) REFERENCES subscription_numberpatterns (id) ON DELETE SET NULL ON UPDATE CASCADE
- |);
-
- # Set firstacquidate if not already set (firstacquidate is now mandatory)
- my $get_first_planneddate_sth = $dbh->prepare(qq|
- SELECT planneddate
- FROM serial
- WHERE subscriptionid = ?
- ORDER BY serialid
- LIMIT 1
- |);
- my $update_firstacquidate_sth = $dbh->prepare(qq|
- UPDATE subscription
- SET firstacquidate = ?
- WHERE subscriptionid = ?
- |);
- my $get_subscriptions_sth = $dbh->prepare(qq|
- SELECT subscriptionid, startdate
- FROM subscription
- WHERE firstacquidate IS NULL
- OR firstacquidate = '0000-00-00'
- |);
- $get_subscriptions_sth->execute;
- while ( my ($subscriptionid, $startdate) = $get_subscriptions_sth->fetchrow ) {
- # Try to get the planned date of the first serial
- $get_first_planneddate_sth->execute($subscriptionid);
- my ($first_planneddate) = $get_first_planneddate_sth->fetchrow;
- if ($first_planneddate and $first_planneddate =~ /^\d{4}-\d{2}-\d{2}$/) {
- $update_firstacquidate_sth->execute($first_planneddate, $subscriptionid);
- } else {
- # Defaults to subscription start date
- $update_firstacquidate_sth->execute($startdate, $subscriptionid);
- }
- }
-
- print "Upgrade to $DBversion done (Bug 7688: Add subscription_frequencies and subscription_numberpatterns tables)\n";
- SetVersion($DBversion);
-}
-
$DBversion = "3.11.00.115";
if ( CheckVersion($DBversion) ) {
$dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo')");
SetVersion ($DBversion);
}
+$DBversion = "3.11.00.200";
+if ( CheckVersion($DBversion) ) {
+ print "Upgrade to $DBversion done (3.12-beta1 release)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.11.00.201";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'BIBSYS' AND host LIKE 'z3950.bibsys.no'");
+ $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'NORBOK' AND host LIKE 'z3950.nb.no'");
+ $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'SAMBOK' AND host LIKE 'z3950.nb.no'");
+ $dbh->do("UPDATE z3950servers SET encoding = 'ISO_8859-1' WHERE name = 'DEICHMAN' AND host like 'z3950.deich.folkebibl.no'");
+ print "Upgrade to $DBversion done (Bug 9498 - Update encoding for Norwegian sample Z39.50 servers)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.11.00.202";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do("INSERT INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ca', 'language', 'Catalan','2013-01-12' )");
+ $dbh->do("INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES( 'ca','cat')");
+ $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'es', 'Catalán')");
+ $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'en', 'Catalan')");
+ $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'fr', 'Catalan')");
+ $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'ca', 'CatalĂ ')");
+ $dbh->do("INSERT INTO language_descriptions(subtag, type, lang, description) VALUES( 'ca', 'language', 'de', 'Katalanisch')");
+ print "Upgrade to $DBversion done (Bug 9381: Add Catalan laguage)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.11.00.203";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do(q{ALTER TABLE suggestions CHANGE COLUMN title title VARCHAR(255) DEFAULT NULL;});
+ print "Upgrade to $DBversion done (Bug 2046 - increasing title column length for suggestions)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.11.00.300";
+if ( CheckVersion($DBversion) ) {
+ print "Upgrade to $DBversion done (3.12-beta3 release)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.11.00.301";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ #issues
+ $dbh->do(q{
+ ALTER TABLE `issues`
+ ADD KEY `itemnumber_idx` (`itemnumber`),
+ ADD KEY `branchcode_idx` (`branchcode`),
+ ADD KEY `issuingbranch_idx` (`issuingbranch`)
+ });
+ $dbh->do(q{
+ ALTER TABLE `old_issues`
+ ADD KEY `branchcode_idx` (`branchcode`),
+ ADD KEY `issuingbranch_idx` (`issuingbranch`)
+ });
+ #items
+ $dbh->do(q{
+ ALTER TABLE `items` ADD KEY `itype_idx` (`itype`)
+ });
+ $dbh->do(q{
+ ALTER TABLE `deleteditems` ADD KEY `itype_idx` (`itype`)
+ });
+ # biblioitems
+ $dbh->do(q{
+ ALTER TABLE `biblioitems` ADD KEY `itemtype_idx` (`itemtype`)
+ });
+ $dbh->do(q{
+ ALTER TABLE `deletedbiblioitems` ADD KEY `itemtype_idx` (`itemtype`)
+ });
+ # statistics
+ $dbh->do(q{
+ ALTER TABLE `statistics`
+ ADD KEY `branch_idx` (`branch`),
+ ADD KEY `proccode_idx` (`proccode`),
+ ADD KEY `type_idx` (`type`),
+ ADD KEY `usercode_idx` (`usercode`),
+ ADD KEY `itemnumber_idx` (`itemnumber`),
+ ADD KEY `itemtype_idx` (`itemtype`),
+ ADD KEY `borrowernumber_idx` (`borrowernumber`),
+ ADD KEY `associatedborrower_idx` (`associatedborrower`),
+ ADD KEY `ccode_idx` (`ccode`)
+ });
+
+ print "Upgrade to $DBversion done (Bug 9681: Add some database indexes)\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.12.00.000";
+if ( CheckVersion($DBversion) ) {
+ print "Upgrade to $DBversion done (3.12.0 release)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = '3.13.00.000';
+if ( CheckVersion($DBversion) ) {
+ print "Upgrade to $DBversion done (start the journey to Koha Pi)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = "3.13.00.001";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UseCourseReserves', '0', NULL, 'Enable the course reserves feature.', 'YesNo')");
+ $dbh->do("INSERT INTO userflags (bit,flag,flagdesc,defaulton) VALUES ('18','coursereserves','Course Reserves','0')");
+ $dbh->do("
+CREATE TABLE `courses` (
+ `course_id` int(11) NOT NULL AUTO_INCREMENT,
+ `department` varchar(20) DEFAULT NULL,
+ `course_number` varchar(255) DEFAULT NULL,
+ `section` varchar(255) DEFAULT NULL,
+ `course_name` varchar(255) DEFAULT NULL,
+ `term` varchar(20) DEFAULT NULL,
+ `staff_note` mediumtext,
+ `public_note` mediumtext,
+ `students_count` varchar(20) DEFAULT NULL,
+ `enabled` enum('yes','no') NOT NULL DEFAULT 'yes',
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`course_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ ");
+
+ $dbh->do("
+CREATE TABLE `course_instructors` (
+ `course_id` int(11) NOT NULL,
+ `borrowernumber` int(11) NOT NULL,
+ PRIMARY KEY (`course_id`,`borrowernumber`),
+ KEY `borrowernumber` (`borrowernumber`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ ");
+
+ $dbh->do("
+ALTER TABLE `course_instructors`
+ ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
+ ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
+ ");
+
+ $dbh->do("
+CREATE TABLE `course_items` (
+ `ci_id` int(11) NOT NULL AUTO_INCREMENT,
+ `itemnumber` int(11) NOT NULL,
+ `itype` varchar(10) DEFAULT NULL,
+ `ccode` varchar(10) DEFAULT NULL,
+ `holdingbranch` varchar(10) DEFAULT NULL,
+ `location` varchar(80) DEFAULT NULL,
+ `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`ci_id`),
+ UNIQUE KEY `itemnumber` (`itemnumber`),
+ KEY `holdingbranch` (`holdingbranch`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ ");
+
+ $dbh->do("
+ALTER TABLE `course_items`
+ ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
+ ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
+");
+
+ $dbh->do("
+CREATE TABLE `course_reserves` (
+ `cr_id` int(11) NOT NULL AUTO_INCREMENT,
+ `course_id` int(11) NOT NULL,
+ `ci_id` int(11) NOT NULL,
+ `staff_note` mediumtext,
+ `public_note` mediumtext,
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`cr_id`),
+ UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
+ KEY `course_id` (`course_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+");
+
+ $dbh->do("
+ALTER TABLE `course_reserves`
+ ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
+ ");
+
+ $dbh->do("
+INSERT INTO permissions (module_bit, code, description) VALUES
+ (18, 'manage_courses', 'Add, edit and delete courses'),
+ (18, 'add_reserves', 'Add course reserves'),
+ (18, 'delete_reserves', 'Remove course reserves')
+;
+ ");
+
+
+ print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
+ SetVersion($DBversion);
+}
+
+$DBversion = "3.13.00.002";
+if ( CheckVersion($DBversion) ) {
+ $dbh->do("UPDATE systempreferences SET variable = 'IndependentBranches' WHERE variable = 'IndependantBranches'");
+ print "Upgrade to $DBversion done (Bug 10080 - Change system pref IndependantBranches to IndependentBranches)\n";
+ SetVersion ($DBversion);
+}
+
+$DBversion = '3.13.00.003';
+if ( CheckVersion($DBversion) ) {
+ $dbh->do("ALTER TABLE serial DROP itemnumber");
+ print "Upgrade to $DBversion done (Bug 7718 - Remove itemnumber column from serials table)\n";
+ SetVersion($DBversion);
+}
+
=head1 FUNCTIONS
=head2 TableExists($table)