View | Details | Raw Unified | Return to bug 12933
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_12933.sql (+5 lines)
Line 0 Link Here
1
INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
2
VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
3
4
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
5
', 'print' );
(-)a/installer/data/mysql/de-DE/mandatory/sample_notices.sql (-1 / +7 lines)
Lines 135-138 Ihr Biblioheksteam' Link Here
135
);
135
);
136
136
137
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
137
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
138
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Benachrichtigung bei Zugang', 'Bestelltes Medium ist eingetroffen', 'Liebe/r <<borrowers.firstname>> <<borrowers.surname>>,\n\nDie Bestellung <<aqorders.ordernumber>> (<<biblio.title>>) ist eingetroffen und wird bearbeitet.\n\nIhr Bibliotheksteam', 'email')
138
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Benachrichtigung bei Zugang', 'Bestelltes Medium ist eingetroffen', 'Liebe/r <<borrowers.firstname>> <<borrowers.surname>>,\n\nDie Bestellung <<aqorders.ordernumber>> (<<biblio.title>>) ist eingetroffen und wird bearbeitet.\n\nIhr Bibliotheksteam', 'email');
139
140
INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
141
VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
142
143
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
144
', 'print' );
(-)a/installer/data/mysql/en/mandatory/sample_notices.sql (-1 / +7 lines)
Lines 154-157 Your library.' Link Here
154
);
154
);
155
155
156
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
156
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
157
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email')
157
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email');
158
159
INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
160
VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
161
162
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
163
', 'print' );
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql (-1 / +7 lines)
Lines 150-153 Your library.' Link Here
150
);
150
);
151
151
152
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
152
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
153
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email')
153
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email');
154
155
INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
156
VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
157
158
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
159
', 'print' );
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql (-1 / +7 lines)
Lines 169-172 Your library.' Link Here
169
);
169
);
170
170
171
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
171
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
172
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email')
172
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email');
173
174
INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
175
VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
176
177
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
178
', 'print' );
(-)a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql (-1 / +7 lines)
Lines 147-150 Your library.' Link Here
147
);
147
);
148
148
149
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
149
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
150
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email')
150
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email');
151
152
INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
153
VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
154
155
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
156
', 'print' );
(-)a/installer/data/mysql/ru-RU/mandatory/sample_notices.sql (-1 / +7 lines)
Lines 149-152 Your library.' Link Here
149
);
149
);
150
150
151
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
151
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
152
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email')
152
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email');
153
154
INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
155
VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
156
157
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
158
', 'print' );
(-)a/installer/data/mysql/uk-UA/mandatory/sample_notices.sql (-1 / +7 lines)
Lines 148-151 Your library.' Link Here
148
);
148
);
149
149
150
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
150
INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
151
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email')
151
VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email');
152
153
INSERT INTO letter ( module, code, branchcode, name, is_html, title, content, message_transport_type )
154
VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLIP', 'The following item(s) is/are currently overdue:
155
156
<item>"<<biblio.title>>" by <<biblio.author>>, <<items.itemcallnumber>>, Barcode: <<items.barcode>> Fine: <<items.fine>></item>
157
', 'print' );
(-)a/installer/data/mysql/updatedatabase.pl (-1134 / +24 lines)
Lines 6-23 Link Here
6
# Parts copyright Catalyst IT 2011
6
# Parts copyright Catalyst IT 2011
7
7
8
# Part of the Koha Library Software www.koha-community.org
8
# Part of the Koha Library Software www.koha-community.org
9
# Koha is free software; you can redistribute it and/or modify it
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# under the terms of the GNU General Public License as published by
10
# terms of the GNU General Public License as published by the Free Software
11
# the Free Software Foundation; either version 3 of the License, or
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# (at your option) any later version.
12
# version.
13
#
13
#
14
# Koha is distributed in the hope that it will be useful, but
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
# GNU General Public License for more details.
18
#
17
#
19
# You should have received a copy of the GNU General Public License
18
# You should have received a copy of the GNU General Public License along
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
#
21
#
22
22
23
# Bugs/ToDo:
23
# Bugs/ToDo:
Lines 37-44 use Getopt::Long; Link Here
37
use C4::Context;
37
use C4::Context;
38
use C4::Installer;
38
use C4::Installer;
39
use C4::Dates;
39
use C4::Dates;
40
use Koha::Database;
41
use Koha;
42
40
43
use MARC::Record;
41
use MARC::Record;
44
use MARC::File::XML ( BinaryEncoding => 'utf8' );
42
use MARC::File::XML ( BinaryEncoding => 'utf8' );
Lines 59-66 my ( Link Here
59
    $prefitem,          # preference item in systempreferences table
57
    $prefitem,          # preference item in systempreferences table
60
);
58
);
61
59
62
my $schema = Koha::Database->new()->schema();
63
64
my $silent;
60
my $silent;
65
GetOptions(
61
GetOptions(
66
    's' =>\$silent
62
    's' =>\$silent
Lines 3813-3820 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
3813
    print "Upgrade to $DBversion done (3.2.0 general release)\n";
3809
    print "Upgrade to $DBversion done (3.2.0 general release)\n";
3814
    SetVersion ($DBversion);
3810
    SetVersion ($DBversion);
3815
}
3811
}
3816
# This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't
3817
3812
3813
# This is the point where 3.2.x and master diverged, we can use $original_version to make sure we don't
3818
# apply updates that have already been done
3814
# apply updates that have already been done
3819
3815
3820
$DBversion = "3.03.00.001";
3816
$DBversion = "3.03.00.001";
Lines 4945-4996 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
4945
4941
4946
$DBversion = "3.07.00.029";
4942
$DBversion = "3.07.00.029";
4947
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4943
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
4948
    $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_descriptions`;});
4944
    my $installer = C4::Installer->new();
4949
    $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_mappings`;});
4945
    my $full_path = C4::Context->config('intranetdir') . "/installer/data/$installer->{dbms}/atomicupdate/oai_sets.sql";
4950
    $dbh->do(q{DROP TABLE IF EXISTS `oai_sets_biblios`;});
4946
    my $error     = $installer->load_sql($full_path);
4951
    $dbh->do(q{DROP TABLE IF EXISTS `oai_sets`;});
4947
    warn $error if $error;
4952
4953
    $dbh->do(q{
4954
        CREATE TABLE `oai_sets` (
4955
          `id` int(11) NOT NULL auto_increment,
4956
          `spec` varchar(80) NOT NULL UNIQUE,
4957
          `name` varchar(80) NOT NULL,
4958
          PRIMARY KEY (`id`)
4959
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4960
    });
4961
4962
    $dbh->do(q{
4963
        CREATE TABLE `oai_sets_descriptions` (
4964
          `set_id` int(11) NOT NULL,
4965
          `description` varchar(255) NOT NULL,
4966
          CONSTRAINT `oai_sets_descriptions_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4967
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4968
    });
4969
4970
    $dbh->do(q{
4971
        CREATE TABLE `oai_sets_mappings` (
4972
          `set_id` int(11) NOT NULL,
4973
          `marcfield` char(3) NOT NULL,
4974
          `marcsubfield` char(1) NOT NULL,
4975
          `marcvalue` varchar(80) NOT NULL,
4976
          CONSTRAINT `oai_sets_mappings_ibfk_1` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4977
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4978
    });
4979
4980
    $dbh->do(q{
4981
        CREATE TABLE `oai_sets_biblios` (
4982
          `biblionumber` int(11) NOT NULL,
4983
          `set_id` int(11) NOT NULL,
4984
          PRIMARY KEY (`biblionumber`, `set_id`),
4985
          CONSTRAINT `oai_sets_biblios_ibfk_1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
4986
          CONSTRAINT `oai_sets_biblios_ibfk_2` FOREIGN KEY (`set_id`) REFERENCES `oai_sets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
4987
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4988
    });
4989
4990
    $dbh->do(q{
4991
        INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OAI-PMH:AutoUpdateSets','0','Automatically update OAI sets when a bibliographic record is created or updated','','YesNo');
4992
    });
4993
4994
    print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
4948
    print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
4995
    SetVersion($DBversion);
4949
    SetVersion($DBversion);
4996
}
4950
}
Lines 5006-5012 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5006
    $dbh->do("ALTER TABLE default_branch_item_rules ADD
4960
    $dbh->do("ALTER TABLE default_branch_item_rules ADD
5007
            COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
4961
            COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
5008
    # set the default rule to the current value of HomeOrHoldingBranchReturn (default to 'homebranch' if need be)
4962
    # set the default rule to the current value of HomeOrHoldingBranchReturn (default to 'homebranch' if need be)
5009
    my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn') || 'homebranch';
4963
    my $homeorholdingbranchreturn = C4::Context->prefernce('HomeOrHoldingBranchReturn') || 'homebranch';
5010
    $dbh->do("UPDATE default_circ_rules SET returnbranch = '$homeorholdingbranchreturn'");
4964
    $dbh->do("UPDATE default_circ_rules SET returnbranch = '$homeorholdingbranchreturn'");
5011
    print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
4965
    print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
5012
    SetVersion($DBversion);
4966
    SetVersion($DBversion);
Lines 9668-9674 if ( CheckVersion($DBversion) ) { Link Here
9668
                DROP INDEX userid ,
9622
                DROP INDEX userid ,
9669
                ADD UNIQUE userid (userid)
9623
                ADD UNIQUE userid (userid)
9670
        });
9624
        });
9671
        print "Upgrade to $DBversion done (Bug 1861: Unique patrons logins not (totally) enforced)\n";
9625
        print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced)\n";
9672
    }
9626
    }
9673
9627
9674
    SetVersion($DBversion);
9628
    SetVersion($DBversion);
Lines 9698-10783 if(CheckVersion($DBversion)) { Link Here
9698
        ALTER TABLE borrower_attribute_types MODIFY COLUMN authorised_value_category VARCHAR(32) DEFAULT NULL
9652
        ALTER TABLE borrower_attribute_types MODIFY COLUMN authorised_value_category VARCHAR(32) DEFAULT NULL
9699
    });
9653
    });
9700
9654
9701
    print "Upgrade to $DBversion done (Bug 13379: Modify authorised_values.category to varchar(32))\n";
9655
    print "Upgrade to $DBversion done (Bug 13379 - Modify authorised_values.category to varchar(32))\n";
9702
    SetVersion($DBversion);
9656
    SetVersion($DBversion);
9703
}
9657
}
9704
9658
9705
$DBversion = "3.19.00.006";
9659
$DBversion = "3.19.00.006";
9706
if ( CheckVersion($DBversion) ) {
9660
if ( CheckVersion($DBversion) ) {
9707
    $dbh->do(q|SET foreign_key_checks = 0|);
9661
    $dbh->do(q|SET foreign_key_checks = 0|);;
9708
    my $sth = $dbh->table_info( '','','','TABLE' );
9662
    my @tables = $dbh->tables();
9709
    my ( $cat, $schema, $name, $type, $remarks );
9663
    for my $table ( @tables ) {
9710
    while ( ( $cat, $schema, $name, $type, $remarks ) = $sth->fetchrow_array ) {
9664
        $dbh->do(qq|ALTER TABLE $table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci|);
9711
        my $table_sth = $dbh->prepare(qq|SHOW CREATE TABLE $name|);
9712
        $table_sth->execute;
9713
        my @table = $table_sth->fetchrow_array;
9714
        unless ( $table[1] =~ /COLLATE=utf8mb4_unicode_ci/ ) { #catches utf8mb4 collated tables
9715
            if ( $name eq 'marc_subfield_structure' ) {
9716
                $dbh->do(q|
9717
                    ALTER TABLE marc_subfield_structure
9718
                    MODIFY COLUMN tagfield varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9719
                    MODIFY COLUMN tagsubfield varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '',
9720
                    MODIFY COLUMN liblibrarian varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9721
                    MODIFY COLUMN libopac varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9722
                    MODIFY COLUMN kohafield varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
9723
                    MODIFY COLUMN authorised_value varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
9724
                    MODIFY COLUMN authtypecode varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
9725
                    MODIFY COLUMN value_builder varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL,
9726
                    MODIFY COLUMN frameworkcode varchar(4) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
9727
                    MODIFY COLUMN seealso varchar(1100) COLLATE utf8_unicode_ci DEFAULT NULL,
9728
                    MODIFY COLUMN link varchar(80) COLLATE utf8_unicode_ci DEFAULT NULL
9729
                |);
9730
            }
9731
            else {
9732
                $dbh->do(qq|ALTER TABLE $name CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci|);
9733
            }
9734
        }
9735
    }
9665
    }
9736
    $dbh->do(q|SET foreign_key_checks = 1|);;
9666
    $dbh->do(q|SET foreign_key_checks = 1|);;
9737
9667
9738
    print "Upgrade to $DBversion done (Bug 11944: Convert DB tables to utf8_unicode_ci)\n";
9668
    print "Upgrade to $DBversion done (Bug 11944 - Convert DB tables to utf8_unicode_ci)\n";
9739
    SetVersion($DBversion);
9740
}
9741
9742
$DBversion = "3.19.00.007";
9743
if ( CheckVersion($DBversion) ) {
9744
    my $orphan_budgets = $dbh->selectall_arrayref(q|
9745
        SELECT budget_id, budget_name, budget_code
9746
        FROM aqbudgets
9747
        WHERE   budget_parent_id IS NOT NULL
9748
            AND budget_parent_id NOT IN (
9749
                SELECT DISTINCT budget_id FROM aqbudgets
9750
            )
9751
    |, { Slice => {} } );
9752
9753
    if ( @$orphan_budgets ) {
9754
        for my $b ( @$orphan_budgets ) {
9755
            print "Fund $b->{budget_name} (code:$b->{budget_code}, id:$b->{budget_id}) does not have a parent, it may cause problem\n";
9756
        }
9757
        print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: FAIL)\n";
9758
    } else {
9759
        print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: OK)\n";
9760
    }
9761
    SetVersion($DBversion);
9762
}
9763
9764
$DBversion = "3.19.00.008";
9765
if ( CheckVersion($DBversion) ) {
9766
    my $number_of_orders_not_linked = $dbh->selectcol_arrayref(q|
9767
        SELECT COUNT(*)
9768
        FROM aqorders o
9769
        WHERE NOT EXISTS (
9770
            SELECT NULL
9771
            FROM aqbudgets b
9772
            WHERE b.budget_id = o.budget_id
9773
        );
9774
    |);
9775
9776
    if ( $number_of_orders_not_linked->[0] > 0 ) {
9777
        $dbh->do(q|
9778
            INSERT INTO aqbudgetperiods(budget_period_startdate, budget_period_enddate, budget_period_active, budget_period_description, budget_period_total) VALUES ( CAST(NOW() AS date), CAST(NOW() AS date), 0, "WARNING: This budget has been automatically created by the updatedatabase script, please see bug 12601 for more information", 0)
9779
        |);
9780
        my $budget_period_id = $dbh->last_insert_id( undef, undef, 'aqbudgetperiods', undef );
9781
        $dbh->do(qq|
9782
            INSERT INTO aqbudgets(budget_code, budget_name, budget_amount, budget_period_id) VALUES ( "BACKUP_TMP", "WARNING: fund created by the updatedatabase script, please see bug 12601", 0, $budget_period_id );
9783
        |);
9784
        my $budget_id = $dbh->last_insert_id( undef, undef, 'aqbudgets', undef );
9785
        $dbh->do(qq|
9786
            UPDATE aqorders o
9787
            SET budget_id = $budget_id
9788
            WHERE NOT EXISTS (
9789
                SELECT NULL
9790
                FROM aqbudgets b
9791
                WHERE b.budget_id = o.budget_id
9792
            )
9793
        |);
9794
    }
9795
9796
    $dbh->do(q|
9797
        ALTER TABLE aqorders
9798
        ADD CONSTRAINT aqorders_budget_id_fk FOREIGN KEY (budget_id) REFERENCES aqbudgets(budget_id) ON DELETE CASCADE ON UPDATE CASCADE
9799
    |);
9800
9801
    print "Upgrade to $DBversion done (Bug 12601: Add new foreign key aqorders.budget_id" . ( ( $number_of_orders_not_linked->[0] > 0 )  ? ' WARNING: temporary budget and fund have been created (search for "BACKUP_TMP"). At least one of your order was not linked to a budget' : '' ) . ")\n";
9802
    SetVersion($DBversion);
9803
}
9804
9805
$DBversion = "3.19.00.009";
9806
if ( CheckVersion($DBversion) ) {
9807
    $dbh->do(q|
9808
        UPDATE suggestions s SET s.budgetid = NULL
9809
        WHERE NOT EXISTS (
9810
            SELECT NULL
9811
            FROM aqbudgets b
9812
            WHERE b.budget_id = s.budgetid
9813
        );
9814
    |);
9815
9816
    $dbh->do(q|
9817
        ALTER TABLE suggestions
9818
        ADD CONSTRAINT suggestions_budget_id_fk FOREIGN KEY (budgetid) REFERENCES aqbudgets(budget_id) ON DELETE SET NULL ON UPDATE CASCADE
9819
    |);
9820
9821
    print "Upgrade to $DBversion done (Bug 13007: Add new foreign key suggestions.budgetid)\n";
9822
    SetVersion($DBversion);
9823
}
9824
9825
$DBversion = "3.19.00.010";
9826
if ( CheckVersion($DBversion) ) {
9827
    $dbh->do(q|
9828
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
9829
        VALUES('SessionRestrictionByIP','1','Check for Change in  Remote IP address for Session Security. Disable when remote ip address changes frequently.','','YesNo')
9830
    |);
9831
    print "Upgrade to $DBversion done (Bug 5511: SessionRestrictionByIP)\n";
9832
    SetVersion ($DBversion);
9833
}
9834
9835
$DBversion = "3.19.00.011";
9836
if ( CheckVersion($DBversion) ) {
9837
    $dbh->do(q|
9838
        INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES
9839
        (20, 'lists', 'Lists', 0)
9840
    |);
9841
    $dbh->do(q|
9842
        INSERT INTO permissions (module_bit, code, description) VALUES
9843
        (20, 'delete_public_lists', 'Delete public lists')
9844
    |);
9845
    print "Upgrade to $DBversion done (Bug 13417: Add permission to delete public lists)\n";
9846
    SetVersion ($DBversion);
9847
}
9848
9849
$DBversion = "3.19.00.012";
9850
if(CheckVersion($DBversion)) {
9851
    $dbh->do(q{
9852
        ALTER TABLE biblioitems MODIFY COLUMN marcxml longtext
9853
    });
9854
9855
    $dbh->do(q{
9856
        ALTER TABLE deletedbiblioitems MODIFY COLUMN marcxml longtext
9857
    });
9858
9859
    print "Upgrade to $DBversion done (Bug 13523 Remove NOT NULL restriction on field marcxml due to mysql STRICT_TRANS_TABLES)\n";
9860
    SetVersion ($DBversion);
9861
}
9862
9863
$DBversion = "3.19.00.013";
9864
if ( CheckVersion($DBversion) ) {
9865
    $dbh->do(q|
9866
        INSERT INTO permissions (module_bit, code, description) VALUES
9867
          (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)')
9868
    |);
9869
    print "Upgrade to $DBversion done (Bug 11395: Add permission tools_records_batchmod)\n";
9870
    SetVersion($DBversion);
9871
}
9872
9873
$DBversion = "3.19.00.014";
9874
if ( CheckVersion($DBversion) ) {
9875
    $dbh->do(q|
9876
        CREATE TABLE aqorder_users (
9877
            ordernumber int(11) NOT NULL,
9878
            borrowernumber int(11) NOT NULL,
9879
            PRIMARY KEY (ordernumber, borrowernumber),
9880
            CONSTRAINT aqorder_users_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE,
9881
            CONSTRAINT aqorder_users_ibfk_2 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
9882
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
9883
    |);
9884
9885
    $dbh->do(q|
9886
        INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type)
9887
        VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email')
9888
    |);
9889
    print "Upgrade to $DBversion done (Bug 12648: Add letter ACQ_NOTIF_ON_RECEIV )\n";
9890
    SetVersion ($DBversion);
9891
}
9892
9893
$DBversion = "3.19.00.015";
9894
if ( CheckVersion($DBversion) ) {
9895
    $dbh->do(q|
9896
        ALTER TABLE search_history ADD COLUMN id INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY(id);
9897
    |);
9898
    print "Upgrade to $DBversion done (Bug 11430: Add primary key for search_history)\n";
9899
    SetVersion($DBversion);
9900
}
9901
9902
$DBversion = "3.19.00.016";
9903
if(CheckVersion($DBversion)) {
9904
    my @order_cancellation_reason = $dbh->selectrow_array("SELECT count(*) FROM authorised_values WHERE category='ORDER_CANCELLATION_REASON'");
9905
    if ($order_cancellation_reason[0] == 0) {
9906
        $dbh->do(q{
9907
            INSERT INTO authorised_values (category, authorised_value, lib) VALUES
9908
             ('ORDER_CANCELLATION_REASON', 0, 'No reason provided'),
9909
             ('ORDER_CANCELLATION_REASON', 1, 'Out of stock'),
9910
             ('ORDER_CANCELLATION_REASON', 2, 'Restocking')
9911
        });
9912
9913
        my $already_existing_reasons = $dbh->selectcol_arrayref(q{
9914
            SELECT DISTINCT( cancellationreason )
9915
            FROM aqorders;
9916
        }, { Slice => {} });
9917
9918
        my $update_orders_sth = $dbh->prepare(q{
9919
            UPDATE aqorders
9920
            SET cancellationreason = ?
9921
            WHERE cancellationreason = ?
9922
        });
9923
9924
        my $insert_av_sth = $dbh->prepare(q{
9925
            INSERT INTO authorised_values (category, authorised_value, lib) VALUES
9926
             ('ORDER_CANCELLATION_REASON', ?, ?)
9927
        });
9928
        my $i = 3;
9929
        for my $reason ( @$already_existing_reasons ) {
9930
            next unless $reason;
9931
            $insert_av_sth->execute( $i, $reason );
9932
            $update_orders_sth->execute( $i, $reason );
9933
            $i++;
9934
        }
9935
        print "Upgrade to $DBversion done (Bug 13380: Add the ORDER_CANCELLATION_REASON authorised value)\n";
9936
    }
9937
    else {
9938
        print "Upgrade to $DBversion done (Bug 13380: ORDER_CANCELLATION_REASON authorised value already existed from earlier update!)\n";
9939
    }
9940
9941
    SetVersion($DBversion);
9942
}
9943
9944
$DBversion = '3.19.00.017';
9945
if ( CheckVersion($DBversion) ) {
9946
    # First create the column
9947
    $dbh->do("ALTER TABLE issuingrules ADD onshelfholds tinyint(1) default 0 NOT NULL");
9948
    # Now update the column
9949
    if (C4::Context->preference("AllowOnShelfHolds")){
9950
        # Pref is on, set allow for all rules
9951
        $dbh->do("UPDATE issuingrules SET onshelfholds=1");
9952
    } else {
9953
        # If the preference is not set, leave off
9954
        $dbh->do("UPDATE issuingrules SET onshelfholds=0");
9955
    }
9956
    # Remove from the systempreferences table
9957
    $dbh->do("DELETE FROM systempreferences WHERE variable = 'AllowOnShelfHolds'");
9958
9959
    # First create the column
9960
    $dbh->do("ALTER TABLE issuingrules ADD opacitemholds char(1) DEFAULT 'N' NOT NULL");
9961
    # Now update the column
9962
    my $opacitemholds = C4::Context->preference("OPACItemHolds") || '';
9963
    if (lc ($opacitemholds) eq 'force') {
9964
        $opacitemholds = 'F';
9965
    }
9966
    else {
9967
        $opacitemholds = $opacitemholds ? 'Y' : 'N';
9968
    }
9969
    # Set allow for all rules
9970
    $dbh->do("UPDATE issuingrules SET opacitemholds='$opacitemholds'");
9971
9972
    # Remove from the systempreferences table
9973
    $dbh->do("DELETE FROM systempreferences WHERE variable = 'OPACItemHolds'");
9974
9975
    print "Upgrade to $DBversion done (Bug 5786: Move AllowOnShelfHolds to circulation matrix; Move OPACItemHolds system preference to circulation matrix)\n";
9976
    SetVersion ($DBversion);
9977
}
9978
9979
9980
$DBversion = "3.19.00.018";
9981
if ( CheckVersion($DBversion) ) {
9982
    $dbh->do(q|
9983
        UPDATE systempreferences set variable="OpacAdditionalStylesheet" WHERE variable="opaccolorstylesheet"
9984
    |);
9985
    print "Upgrade to $DBversion done (Bug 10328: Rename opaccolorstylesheet to OpacAdditionalStylesheet\n";
9986
    SetVersion ($DBversion);
9987
}
9988
9989
$DBversion = "3.19.00.019";
9990
if ( CheckVersion($DBversion) ) {
9991
    $dbh->do(q{
9992
        INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
9993
        VALUES('Coce','0', 'If on, enables cover retrieval from the configured Coce server', NULL, 'YesNo')
9994
    });
9995
    $dbh->do(q{
9996
        INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
9997
        VALUES('CoceHost', NULL, 'Coce server URL', NULL,'Free')
9998
    });
9999
    $dbh->do(q{
10000
        INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type)
10001
        VALUES('CoceProviders', NULL, 'Coce providers', 'aws,gb,ol', 'multiple')
10002
    });
10003
    print "Upgrade to $DBversion done (Bug 9580: Cover image from Coce, a remote image URL cache)\n";
10004
    SetVersion($DBversion);
10005
}
10006
10007
$DBversion = "3.19.00.020";
10008
if ( CheckVersion($DBversion) ) {
10009
    $dbh->do(q|
10010
        ALTER TABLE aqorders DROP COLUMN supplierreference;
10011
    |);
10012
10013
    print "Upgrade to $DBversion done (Bug 11008: DROP column aqorders.supplierreference)\n";
10014
    SetVersion($DBversion);
10015
}
10016
10017
$DBversion = "3.19.00.021";
10018
if ( CheckVersion($DBversion) ) {
10019
    $dbh->do(q|
10020
        ALTER TABLE issues DROP COLUMN issuingbranch
10021
    |);
10022
    $dbh->do(q|
10023
        ALTER TABLE old_issues DROP COLUMN issuingbranch
10024
    |);
10025
    print "Upgrade to $DBversion done (Bug 2806: Remove issuingbranch columns)\n";
10026
    SetVersion ($DBversion);
10027
}
10028
10029
$DBversion = '3.19.00.022';
10030
if ( CheckVersion($DBversion) ) {
10031
    $dbh->do(q{
10032
        ALTER TABLE suggestions DROP COLUMN mailoverseeing;
10033
    });
10034
    print "Upgrade to $DBversion done (Bug 13006: Drop column suggestion.mailoverseeing)\n";
10035
    SetVersion($DBversion);
10036
}
10037
10038
$DBversion = "3.19.00.023";
10039
if ( CheckVersion($DBversion) ) {
10040
    $dbh->do(q|
10041
        DELETE FROM systempreferences where variable = 'AddPatronLists'
10042
    |);
10043
    print "Upgrade to $DBversion done (Bug 13497: Remove the AddPatronLists system preferences)\n";
10044
    SetVersion ($DBversion);
10045
}
10046
10047
$DBversion = "3.19.00.024";
10048
if ( CheckVersion($DBversion) ) {
10049
    $dbh->do(qq|DROP table patroncards;|);
10050
    print "Upgrade to $DBversion done (Bug 13539: Remove table patroncards from database as it's no longer in use)\n";
10051
    SetVersion ($DBversion);
10052
}
10053
10054
$DBversion = "3.19.00.025";
10055
if ( CheckVersion($DBversion) ) {
10056
    $dbh->do(q|
10057
        INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
10058
        ('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo')
10059
    |);
10060
    print "Upgrade to $DBversion done (Bug 13528: Add the SearchWithISBNVariations syspref)\n";
10061
    SetVersion ($DBversion);
9669
    SetVersion ($DBversion);
10062
}
9670
}
10063
9671
10064
$DBversion = "3.19.00.026";
10065
if( CheckVersion($DBversion) ) {
10066
    if ( C4::Context->preference('marcflavour') eq 'MARC21' ) {
10067
    $dbh->do(q{
10068
        INSERT IGNORE INTO auth_tag_structure (authtypecode, tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value) VALUES
10069
        ('', '388', 'TIME PERIOD OF CREATION', 'TIME PERIOD OF CREATION', 1, 0, NULL);
10070
    });
10071
10072
    $dbh->do(q{
10073
        INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
10074
        mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
10075
        ('', '388', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10076
        ('', '388', '2', 'Source of term', 'Source of term', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10077
        ('', '388', '3', 'Materials specified', 'Materials specified', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10078
        ('', '388', '6', 'Linkage', 'Linkage', 0, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10079
        ('', '388', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', ''),
10080
        ('', '388', 'a', 'Time period of creation term', 'Time period of creation term', 1, 0, 3, NULL, NULL, NULL, 0, 0, '', '', '');
10081
    });
10082
10083
    $dbh->do(q{
10084
        UPDATE IGNORE auth_subfield_structure SET repeatable = 1 WHERE tagsubfield = 'g' AND tagfield IN
10085
        ('100','110','111','130','400','410','411','430','500','510','511','530','700','710','730');
10086
    });
10087
10088
    $dbh->do(q{
10089
        INSERT IGNORE INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable,
10090
        mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES
10091
        ('', '150', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 1, NULL, NULL, NULL, 0, 0, '', '', ''),
10092
        ('', '151', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 1, NULL, NULL, NULL, 0, 0, '', '', ''),
10093
        ('', '450', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 4, NULL, NULL, NULL, 0, 0, '', '', ''),
10094
        ('', '451', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 4, NULL, NULL, NULL, 0, 0, '', '', ''),
10095
        ('', '550', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 5, NULL, NULL, NULL, 0, 0, '', '', ''),
10096
        ('', '551', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 5, NULL, NULL, NULL, 0, 0, '', '', ''),
10097
        ('', '750', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10098
        ('', '751', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10099
        ('', '748', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10100
        ('', '755', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10101
        ('', '780', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10102
        ('', '781', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10103
        ('', '782', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10104
        ('', '785', 'i', 'Relationship information', 'Relationship information', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10105
        ('', '710', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10106
        ('', '730', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10107
        ('', '748', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10108
        ('', '750', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10109
        ('', '751', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10110
        ('', '755', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10111
        ('', '762', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10112
        ('', '780', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10113
        ('', '781', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10114
        ('', '782', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10115
        ('', '785', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', ''),
10116
        ('', '788', '4', 'Relationship code', 'Relationship code', 1, 0, 7, NULL, NULL, NULL, 0, 0, '', '', '');
10117
    });
10118
10119
    $dbh->do(q{
10120
        UPDATE IGNORE auth_subfield_structure SET liblibrarian = 'Relationship information', libopac = 'Relationship information'
10121
        WHERE tagsubfield = 'i' AND tagfield IN ('700','710','730','750','751','762');
10122
    });
10123
10124
    $dbh->do(q{
10125
        UPDATE IGNORE auth_subfield_structure SET liblibrarian = 'Relationship code', libopac = 'Relationship code'
10126
        WHERE tagsubfield = '4' AND tagfield IN ('700','710');
10127
    });
10128
10129
    $dbh->do(q{
10130
        INSERT IGNORE INTO marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) VALUES
10131
        ('370', 'ASSOCIATED PLACE', 'ASSOCIATED PLACE', 1, 0, NULL, ''),
10132
        ('388', 'TIME PERIOD OF CREATION', 'TIME PERIOD OF CREATION', 1, 0, NULL, '');
10133
    });
10134
10135
    $dbh->do(q{
10136
        INSERT IGNORE INTO marc_subfield_structure (tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory,
10137
        kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES
10138
        ('370', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10139
        ('370', '2', 'Source of term', 'Source of term', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10140
        ('370', '6', 'Linkage', 'Linkage', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10141
        ('370', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10142
        ('370', 'c', 'Associated country', 'Associated country', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10143
        ('370', 'f', 'Other associated place', 'Other associated place', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10144
        ('370', 'g', 'Place of origin of work', 'Place of origin of work', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10145
        ('370', 's', 'Start period', 'Start period', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10146
        ('370', 't', 'End period', 'End period', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10147
        ('370', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10148
        ('370', 'v', 'Source of information', 'Source of information', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10149
        ('377', 'l', 'Language term', 'Language term', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10150
        ('382', 's', 'Total number of performers', 'Total number of performers', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10151
        ('388', '0', 'Authority record control number or standard number', 'Authority record control number or standard number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10152
        ('388', '2', 'Source of term', 'Source of term', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10153
        ('388', '3', ' Materials specified', ' Materials specified', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10154
        ('388', '6', ' Linkage', ' Linkage', 0, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10155
        ('388', '8', 'Field link and sequence number', 'Field link and sequence number', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10156
        ('388', 'a', 'Time period of creation term', 'Time period of creation term', 1, 0, '', 3, '', '', '', NULL, -6, '', '', '', NULL),
10157
        ('650', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, '', 6, '', '', '', 0, -1, '', '', '', NULL),
10158
        ('651', 'g', 'Miscellaneous information', 'Miscellaneous information', 1, 0, '', 6, '', '', '', 0, -1, '', '', '', NULL);
10159
    });
10160
10161
    $dbh->do(q{
10162
        UPDATE IGNORE marc_subfield_structure SET repeatable = 1 WHERE tagsubfield = 'g' AND
10163
        tagfield IN ('100','110','111','130','240','243','246','247','600','610','611','630','700','710','711','730','800','810','811','830');
10164
    });
10165
    }
10166
10167
    print "Upgrade to $DBversion done (Bug 13322: Update MARC21 frameworks to Update No. 19 - October 2014)\n";
10168
    SetVersion($DBversion);
10169
}
10170
10171
$DBversion = '3.19.00.027';
10172
if ( CheckVersion($DBversion) ) {
10173
    $dbh->do("ALTER TABLE items ADD COLUMN itemnotes_nonpublic MEDIUMTEXT AFTER itemnotes");
10174
    $dbh->do("ALTER TABLE deleteditems ADD COLUMN itemnotes_nonpublic MEDIUMTEXT AFTER itemnotes");
10175
    print "Upgrade to $DBversion done (Bug 4222: Nonpublic note not appearing in the staff client) <b>Please check each of your frameworks to ensure your non-public item notes are mapped to items.itemnotes_nonpublic. After doing so please have your administrator run misc/batchRebuildItemsTables.pl </b>)\n";
10176
    SetVersion($DBversion);
10177
}
10178
10179
$DBversion = "3.19.00.028";
10180
if( CheckVersion($DBversion) ) {
10181
    eval {
10182
        local $dbh->{PrintError} = 0;
10183
        $dbh->do(q{
10184
            ALTER TABLE issues DROP PRIMARY KEY
10185
        });
10186
    };
10187
10188
    $dbh->do(q{
10189
        ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10190
    });
10191
10192
    $dbh->do(q{
10193
        ALTER TABLE old_issues CHANGE issue_id issue_id INT( 11 ) NOT NULL
10194
    });
10195
10196
    $dbh->do(q{
10197
        ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10198
    });
10199
10200
    $dbh->do(q{
10201
        UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC
10202
    });
10203
10204
    my $max_issue_id = $schema->resultset('Issue')->get_column('issue_id')->max();
10205
    if ($max_issue_id) {
10206
        $max_issue_id++;
10207
        $dbh->do(qq{
10208
            ALTER TABLE issues AUTO_INCREMENT = $max_issue_id
10209
        });
10210
    }
10211
10212
    print "Upgrade to $DBversion done (Bug 13790: Add unique id issue_id to issues and oldissues tables)\n";
10213
    SetVersion($DBversion);
10214
}
10215
10216
$DBversion = "3.19.00.029";
10217
if ( CheckVersion($DBversion) ) {
10218
    $dbh->do(q|
10219
         ALTER TABLE sessions CHANGE COLUMN a_session a_session MEDIUMTEXT
10220
    |);
10221
    print "Upgrade to $DBversion done (Bug 13606: Upgrade sessions.a_session to MEDIUMTEXT)\n";
10222
    SetVersion($DBversion);
10223
}
10224
10225
$DBversion = "3.19.00.030";
10226
if ( CheckVersion($DBversion) ) {
10227
    $dbh->do(q|
10228
UPDATE language_subtag_registry SET subtag = 'kn' WHERE subtag = 'ka' AND description = 'Kannada';
10229
    |);
10230
    $dbh->do(q|
10231
UPDATE language_rfc4646_to_iso639 SET rfc4646_subtag = 'kn' WHERE rfc4646_subtag = 'ka' AND iso639_2_code = 'kan';
10232
    |);
10233
    $dbh->do(q|
10234
UPDATE language_descriptions SET subtag = 'kn', lang = 'kn' WHERE subtag = 'ka' AND lang = 'ka' AND description = 'ಕನ್ನಡ';
10235
    |);
10236
    $dbh->do(q|
10237
UPDATE language_descriptions SET subtag = 'kn' WHERE subtag = 'ka' AND description = 'Kannada';
10238
    |);
10239
    $dbh->do(q|
10240
INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'ka', 'language', 'Georgian','2015-04-20');
10241
    |);
10242
    $dbh->do(q|
10243
DELETE FROM language_subtag_registry
10244
       WHERE NOT id IN
10245
         (SELECT id FROM
10246
           (SELECT MIN(id) as id,subtag,type,description,added
10247
            FROM language_subtag_registry
10248
            GROUP BY subtag,type,description,added)
10249
           AS subtable);
10250
    |);
10251
    $dbh->do(q|
10252
INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'ka', 'geo');
10253
    |);
10254
    $dbh->do(q|
10255
DELETE FROM language_rfc4646_to_iso639
10256
       WHERE NOT id IN
10257
         (SELECT id FROM
10258
           (SELECT MIN(id) as id,rfc4646_subtag,iso639_2_code
10259
            FROM language_rfc4646_to_iso639
10260
            GROUP BY rfc4646_subtag,iso639_2_code)
10261
           AS subtable);
10262
    |);
10263
    $dbh->do(q|
10264
INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'ka', 'ქართული');
10265
    |);
10266
    $dbh->do(q|
10267
INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'en', 'Georgian');
10268
    |);
10269
    $dbh->do(q|
10270
INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'fr', 'Géorgien');
10271
    |);
10272
    $dbh->do(q|
10273
INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'de', 'Georgisch');
10274
    |);
10275
    $dbh->do(q|
10276
INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'ka', 'language', 'es', 'Georgiano');
10277
    |);
10278
    $dbh->do(q|
10279
DELETE FROM language_descriptions
10280
       WHERE NOT id IN
10281
         (SELECT id FROM
10282
           (SELECT MIN(id) as id,subtag,type,lang,description
10283
            FROM language_descriptions GROUP BY subtag,type,lang,description)
10284
           AS subtable);
10285
    |);
10286
    print "Upgrade to $DBversion done (Bug 14030: Add Georgian language and fix Kannada language code)\n";
10287
    SetVersion($DBversion);
10288
}
10289
10290
$DBversion = "3.19.00.031";
10291
if ( CheckVersion($DBversion) ) {
10292
    $dbh->do(q{
10293
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10294
        VALUES('IdRef','0','Disable/enable the IdRef webservice from the OPAC detail page.',NULL,'YesNo')
10295
    });
10296
    print "Upgrade to $DBversion done (Bug 8992: Add system preference IdRef))\n";
10297
    SetVersion($DBversion);
10298
}
10299
10300
$DBversion = "3.19.00.032";
10301
if ( CheckVersion($DBversion) ) {
10302
    $dbh->do(q|
10303
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10304
        VALUES('AddressFormat','us','Choose format to display postal addresses','','Choice')
10305
    |);
10306
    print "Upgrade to $DBversion done (Bug 4041: Address Format as a I18N/L10N system preference\n";
10307
    SetVersion ($DBversion);
10308
}
10309
10310
$DBversion = "3.19.00.033";
10311
if ( CheckVersion($DBversion) ) {
10312
    $dbh->do(q|
10313
        ALTER TABLE auth_header
10314
        CHANGE COLUMN datemodified modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP
10315
    |);
10316
    $dbh->do(q|
10317
        ALTER TABLE auth_header
10318
        CHANGE COLUMN modification_time modification_time TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
10319
    |);
10320
    print "Upgrade to $DBversion done (Bug 11165: Update auth_header.datemodified when updated)\n";
10321
    SetVersion ($DBversion);
10322
}
10323
10324
$DBversion = "3.19.00.034";
10325
if ( CheckVersion($DBversion) ) {
10326
    $dbh->do(q|
10327
        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10328
        VALUES('CardnumberLength', '', '', 'Set a length for card numbers.', 'Free')
10329
    |);
10330
    print "Upgrade to $DBversion done (Bug 13984: CardnumberLength syspref missing on some setups\n";
10331
    SetVersion ($DBversion);
10332
}
10333
10334
$DBversion = "3.19.00.035";
10335
if ( CheckVersion($DBversion) ) {
10336
    $dbh->do(q|
10337
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('useDischarge','','Allows librarians to discharge borrowers and borrowers to request a discharge','','YesNo')
10338
    |);
10339
    $dbh->do(q|
10340
        INSERT IGNORE INTO letter (module, code, name, title, content) VALUES('members', 'DISCHARGE', 'Discharge', 'Discharge for <<borrowers.firstname>> <<borrowers.surname>>', '<h1>Discharge</h1>\r\n\r\nThe library <<borrowers.branchcode>> certifies that the following borrower :\r\n\r\n    <<borrowers.firstname>> <<borrowers.surname>>\r\n   Cardnumber : <<borrowers.cardnumber>>\r\n\r\nreturned all his documents.')
10341
    |);
10342
10343
    $dbh->do(q|
10344
        ALTER TABLE borrower_debarments CHANGE type type ENUM('SUSPENSION','OVERDUES','MANUAL','DISCHARGE') NOT NULL DEFAULT 'MANUAL'
10345
    |);
10346
10347
    $dbh->do(q|
10348
        CREATE TABLE discharges (
10349
          borrower int(11) DEFAULT NULL,
10350
          needed timestamp NULL DEFAULT NULL,
10351
          validated timestamp NULL DEFAULT NULL,
10352
          KEY borrower_discharges_ibfk1 (borrower),
10353
          CONSTRAINT borrower_discharges_ibfk1 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
10354
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
10355
    |);
10356
10357
    print "Upgrade to $DBversion done (Bug 8007: Add System Preferences useDischarge, the discharge notice and the new table discharges)\n";
10358
    SetVersion($DBversion);
10359
}
10360
10361
$DBversion = "3.19.00.036";
10362
if ( CheckVersion($DBversion) ) {
10363
    $dbh->do(q|
10364
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10365
        VALUES ('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo')
10366
    |);
10367
    print "Upgrade to $DBversion done (Bug 13889: Add cron jobs information to system log)\n";
10368
    SetVersion ($DBversion);
10369
}
10370
10371
$DBversion = "3.19.00.037";
10372
if ( CheckVersion($DBversion) ) {
10373
    $dbh->do(q|
10374
        ALTER TABLE marc_subfield_structure
10375
        MODIFY COLUMN tagsubfield varchar(1) COLLATE utf8_bin NOT NULL DEFAULT ''
10376
    |);
10377
    print "Upgrade to $DBversion done (Bug 13810: Change collate for tagsubfield (utf8_bin))\n";
10378
    SetVersion ($DBversion);
10379
}
10380
10381
$DBversion = "3.19.00.038";
10382
if ( CheckVersion($DBversion) ) {
10383
    $dbh->do(q|
10384
        ALTER TABLE virtualshelves
10385
        ADD COLUMN created_on TIMESTAMP NOT NULL AFTER lastmodified
10386
    |);
10387
    # Set created_on = lastmodified
10388
    # I would say it's better than 0000-00-00
10389
    # Set modified to the existing value (do not get the current ts!)
10390
    $dbh->do(q|
10391
        UPDATE virtualshelves
10392
        SET created_on = lastmodified, lastmodified = lastmodified
10393
    |);
10394
    print "Upgrade to $DBversion done (Bug 13421: Add DB field virtualshelves.created_on)\n";
10395
    SetVersion ($DBversion);
10396
}
10397
10398
$DBversion = "3.19.00.039";
10399
if ( CheckVersion($DBversion) ) {
10400
    print "Upgrade to $DBversion done (Koha 3.20 beta)\n";
10401
    SetVersion ($DBversion);
10402
}
10403
10404
$DBversion = "3.19.00.040";
10405
if ( CheckVersion($DBversion) ) {
10406
    $dbh->do(q|
10407
        ALTER TABLE aqorders DROP COLUMN totalamount
10408
    |);
10409
    print "Upgrade to $DBversion done (Bug 11006: Drop column aqorders.totalamount)\n";
10410
    SetVersion ($DBversion);
10411
}
10412
10413
$DBversion = "3.19.00.041";
10414
if ( CheckVersion($DBversion) ) {
10415
    $dbh->do(q|
10416
        ALTER IGNORE TABLE suggestions ADD KEY status (STATUS)
10417
    |);
10418
    $dbh->do(q|
10419
        ALTER IGNORE TABLE suggestions ADD KEY biblionumber (biblionumber)
10420
    |);
10421
    $dbh->do(q|
10422
        ALTER IGNORE TABLE suggestions ADD KEY branchcode (branchcode)
10423
    |);
10424
    print "Upgrade to $DBversion done (Bug 14132: suggestions table is missing indexes)\n";
10425
    SetVersion ($DBversion);
10426
}
10427
10428
$DBversion = "3.19.00.042";
10429
if ( CheckVersion($DBversion) ) {
10430
    $dbh->do(q{
10431
        DELETE ass.*
10432
        FROM auth_subfield_structure AS ass
10433
        LEFT JOIN auth_types USING(authtypecode)
10434
        WHERE auth_types.authtypecode IS NULL
10435
    });
10436
10437
    $dbh->do(q{
10438
        ALTER IGNORE TABLE auth_subfield_structure
10439
        ADD CONSTRAINT auth_subfield_structure_ibfk_1
10440
        FOREIGN KEY (authtypecode) REFERENCES auth_types(authtypecode)
10441
        ON DELETE CASCADE ON UPDATE CASCADE
10442
    });
10443
10444
    print "Upgrade to $DBversion done (Bug 8480: Add foreign key on auth_subfield_structure.authtypecode)\n";
10445
    SetVersion($DBversion);
10446
}
10447
10448
$DBversion = "3.19.00.043";
10449
if ( CheckVersion($DBversion) ) {
10450
    $dbh->do(q|
10451
        INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES
10452
        ('REPORT_GROUP', 'SER', 'Serials')
10453
    |);
10454
10455
    print "Upgrade to $DBversion done (Bug 5338: Add Serial to the report groups if does not exist)\n";
10456
    SetVersion ($DBversion);
10457
}
10458
10459
$DBversion = "3.20.00.000";
10460
if ( CheckVersion($DBversion) ) {
10461
    print "Upgrade to $DBversion done (Koha 3.20)\n";
10462
    SetVersion ($DBversion);
10463
}
10464
10465
$DBversion = "3.21.00.000";
10466
if ( CheckVersion($DBversion) ) {
10467
    print "Upgrade to $DBversion done (El tiempo vuela, un nuevo ciclo comienza.)\n";
10468
    SetVersion ($DBversion);
10469
}
10470
10471
$DBversion = "3.21.00.001";
10472
if ( CheckVersion($DBversion) ) {
10473
    $dbh->do(q|
10474
        UPDATE systempreferences SET variable='IntranetUserJS' where variable='intranetuserjs'
10475
    |);
10476
    print "Upgrade to $DBversion done (Bug 12160: Rename intranetuserjs to IntranetUserJS)\n";
10477
    SetVersion ($DBversion);
10478
}
10479
10480
$DBversion = "3.21.00.002";
10481
if ( CheckVersion($DBversion) ) {
10482
    $dbh->do(q|
10483
        UPDATE systempreferences SET variable='OPACUserJS' where variable='opacuserjs'
10484
    |);
10485
    print "Upgrade to $DBversion done (Bug 12160: Rename opacuserjs to OPACUserJS)\n";
10486
    SetVersion ($DBversion);
10487
}
10488
10489
$DBversion = "3.21.00.003";
10490
if ( CheckVersion($DBversion) ) {
10491
    $dbh->do(q|
10492
        INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added)
10493
        VALUES ( 'IN', 'region', 'India','2015-05-28');
10494
    |);
10495
    $dbh->do(q|
10496
        INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
10497
        VALUES ( 'IN', 'region', 'en', 'India');
10498
    |);
10499
    $dbh->do(q|
10500
        INSERT IGNORE INTO language_descriptions(subtag, type, lang, description)
10501
        VALUES ( 'IN', 'region', 'bn', 'ভারত');
10502
    |);
10503
    print "Upgrade to $DBversion done (Bug 14285: Add new region India)\n";
10504
    SetVersion ($DBversion);
10505
}
10506
10507
$DBversion = '3.21.00.004';
10508
if ( CheckVersion($DBversion) ) {
10509
    my $OPACBaseURL = C4::Context->preference('OPACBaseURL');
10510
    if (defined($OPACBaseURL) && substr($OPACBaseURL,0,4) ne "http") {
10511
        my $explanation = q{Specify the Base URL of the OPAC, e.g., http://opac.mylibrary.com, including the protocol (http:// or https://). Otherwise, the http:// will be added automatically by Koha upon saving.};
10512
        $OPACBaseURL = 'http://' . $OPACBaseURL;
10513
        my $sth_OPACBaseURL = $dbh->prepare( q{
10514
            UPDATE systempreferences SET value=?,explanation=?
10515
            WHERE variable='OPACBaseURL'; } );
10516
        $sth_OPACBaseURL->execute($OPACBaseURL,$explanation);
10517
    }
10518
    if (defined($OPACBaseURL)) {
10519
        $dbh->do( q{ UPDATE letter
10520
                     SET content=replace(content,
10521
                                         'http://<<OPACBaseURL>>',
10522
                                         '<<OPACBaseURL>>')
10523
                     WHERE content LIKE "%http://<<OPACBaseURL>>%"; } );
10524
    }
10525
10526
    print "Upgrade to $DBversion done (Bug 5010: Fix OPACBaseURL to include protocol)\n";
10527
    SetVersion($DBversion);
10528
}
10529
10530
$DBversion = "3.21.00.005";
10531
if ( CheckVersion($DBversion) ) {
10532
    $dbh->do(q|
10533
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10534
        VALUES ('ReportsLog','0',NULL,'If ON, log information about reports.','YesNo')
10535
    |);
10536
    print "Upgrade to $DBversion done (Bug 14024: Add reports to action logs)\n";
10537
    SetVersion ($DBversion);
10538
}
10539
10540
$DBversion = "3.21.00.006";
10541
if ( CheckVersion($DBversion) ) {
10542
    # Remove the borrow permission flag (bit 7)
10543
    $dbh->do(q|
10544
        UPDATE borrowers
10545
        SET flags = flags - ( flags & (1<<7) )
10546
        WHERE flags IS NOT NULL
10547
            AND flags > 0
10548
    |);
10549
    $dbh->do(q|
10550
        DELETE FROM userflags WHERE bit=7;
10551
    |);
10552
    print "Upgrade to $DBversion done (Bug 7976: Remove the 'borrow' permission)\n";
10553
    SetVersion($DBversion);
10554
}
10555
10556
$DBversion = "3.21.00.007";
10557
if ( CheckVersion($DBversion) ) {
10558
    $dbh->do(q|
10559
        ALTER IGNORE TABLE aqbasket
10560
            ADD KEY authorisedby (authorisedby)
10561
    |);
10562
    $dbh->do(q|
10563
        ALTER IGNORE TABLE aqbooksellers
10564
            ADD KEY name (name(255))
10565
    |);
10566
    $dbh->do(q|
10567
        ALTER IGNORE TABLE aqbudgets
10568
            ADD KEY budget_parent_id (budget_parent_id),
10569
            ADD KEY budget_code (budget_code),
10570
            ADD KEY budget_branchcode (budget_branchcode),
10571
            ADD KEY budget_period_id (budget_period_id),
10572
            ADD KEY budget_owner_id (budget_owner_id)
10573
    |);
10574
    $dbh->do(q|
10575
        ALTER IGNORE TABLE aqbudgets_planning
10576
            ADD KEY budget_period_id (budget_period_id)
10577
    |);
10578
    $dbh->do(q|
10579
        ALTER IGNORE TABLE aqorders
10580
            ADD KEY parent_ordernumber (parent_ordernumber),
10581
            ADD KEY orderstatus (orderstatus)
10582
    |);
10583
    print "Upgrade to $DBversion done (Bug 14053: Acquisition db tables are missing indexes)\n";
10584
    SetVersion ($DBversion);
10585
}
10586
10587
$DBversion = "3.21.00.008";
10588
if ( CheckVersion($DBversion) ) {
10589
    $dbh->do(q{
10590
        DELETE IGNORE FROM systempreferences
10591
        WHERE variable = 'HomeOrHoldingBranchReturn';
10592
    });
10593
    print "Upgrade to $DBversion done (Bug 7981: Transfer message on return. HomeOrHoldingBranchReturn syspref removed in favour of circulation rules.)\n";
10594
    SetVersion($DBversion);
10595
}
10596
10597
$DBversion = "3.21.00.009";
10598
if ( CheckVersion($DBversion) ) {
10599
    $dbh->do(q|
10600
        UPDATE aqorders SET orderstatus='cancelled'
10601
        WHERE (datecancellationprinted IS NOT NULL OR
10602
               datecancellationprinted<>'0000-00-00');
10603
    |);
10604
    print "Upgrade to $DBversion done (Bug 13993: Correct orderstatus for transferred orders)\n";
10605
    SetVersion($DBversion);
10606
}
10607
10608
$DBversion = "3.21.00.010";
10609
if ( CheckVersion($DBversion) ) {
10610
    $dbh->do(q|
10611
        ALTER TABLE message_queue
10612
            DROP message_id
10613
    |);
10614
    $dbh->do(q|
10615
        ALTER TABLE message_queue
10616
            ADD message_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
10617
    |);
10618
    print "Upgrade to $DBversion done (Bug 7793: redefine the field message_id as PRIMARY KEY of message_queue)\n";
10619
    SetVersion ($DBversion);
10620
}
10621
10622
$DBversion = "3.21.00.011";
10623
if ( CheckVersion($DBversion) ) {
10624
    $dbh->do(q{
10625
        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10626
        VALUES ('OpacLangSelectorMode','footer','top|both|footer','Select the location to display the language selector','Choice')
10627
    });
10628
    print "Upgrade to $DBversion done (Bug 14252: Make the OPAC language switcher available in the masthead navbar, footer, or both)\n";
10629
    SetVersion ($DBversion);
10630
}
10631
10632
$DBversion = "3.21.00.012";
10633
if ( CheckVersion($DBversion) ) {
10634
    $dbh->do(q|
10635
        INSERT INTO letter (module, code, name, title, content, message_transport_type)
10636
        VALUES
10637
        ('suggestions','TO_PROCESS','Notify budget owner', 'A suggestion is ready to be processed','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nA new suggestion is ready to be processed: <<suggestions.title>> by <<suggestions.autho    r>>.\n\nThank you,\n\n<<branches.branchname>>', 'email')
10638
    |);
10639
    print "Upgrade to $DBversion done (Bug 13014: Add the TO_PROCESS letter code)\n";
10640
    SetVersion($DBversion);
10641
}
10642
10643
$DBversion = "3.21.00.013";
10644
if ( CheckVersion($DBversion) ) {
10645
    my $msg;
10646
    if ( C4::Context->preference('OPACPrivacy') ) {
10647
        if ( my $anonymous_patron = C4::Context->preference('AnonymousPatron') ) {
10648
            my $anonymous_patron_exists = $dbh->selectcol_arrayref(q|
10649
                SELECT COUNT(*)
10650
                FROM borrowers
10651
                WHERE borrowernumber=?
10652
            |, {}, $anonymous_patron);
10653
            unless ( $anonymous_patron_exists->[0] ) {
10654
                $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not linked to an existing patron";
10655
            }
10656
        }
10657
        else {
10658
            $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not";
10659
        }
10660
    }
10661
    else {
10662
        my $patrons_have_required_anonymity = $dbh->selectcol_arrayref(q|
10663
            SELECT COUNT(*)
10664
            FROM borrowers
10665
            WHERE privacy = 2
10666
        |, {} );
10667
        if ( $patrons_have_required_anonymity->[0] ) {
10668
            $msg = "Configuration WARNING: OPACPrivacy is not set but $patrons_have_required_anonymity->[0] patrons have required anonymity (perhaps in a previous configuration). You should fix that asap.";
10669
        }
10670
    }
10671
10672
    $msg //= "Privacy is correctly set";
10673
    print "Upgrade to $DBversion done (Bug 9942: $msg)\n";
10674
    SetVersion ($DBversion);
10675
}
10676
10677
$DBversion = "3.21.00.014";
10678
if ( CheckVersion($DBversion) ) {
10679
    $dbh->do(q{
10680
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
10681
        VALUES ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent) or might be deleted (transient)','transient|persistent','Choice')
10682
    });
10683
    $dbh->do(q|
10684
        ALTER TABLE oai_sets_biblios DROP FOREIGN KEY oai_sets_biblios_ibfk_1
10685
    |);
10686
    print "Upgrade to $DBversion done (Bug 3206: OAI repository deleted record support)\n";
10687
    SetVersion ($DBversion);
10688
}
10689
10690
$DBversion = "3.21.00.015";
10691
if ( CheckVersion($DBversion) ) {
10692
    $dbh->do(q{
10693
        UPDATE systempreferences SET value='0' WHERE variable='CalendarFirstDayOfWeek' AND value='Sunday';
10694
    });
10695
    $dbh->do(q{
10696
        UPDATE systempreferences SET value='1' WHERE variable='CalendarFirstDayOfWeek' AND value='Monday';
10697
    });
10698
    $dbh->do(q{
10699
        UPDATE systempreferences SET options='0|1|2|3|4|5|6' WHERE variable='CalendarFirstDayOfWeek';
10700
    });
10701
10702
    print "Upgrade to $DBversion done (Bug 12137: Extend functionality of CalendarFirstDayOfWeek to be any day)\n";
10703
    SetVersion($DBversion);
10704
}
10705
10706
$DBversion = "3.21.00.016";
10707
if ( CheckVersion($DBversion) ) {
10708
    my $rs = $schema->resultset('Systempreference');
10709
    $rs->find_or_create(
10710
        {
10711
            variable => 'DumpTemplateVarsIntranet',
10712
            value    => 0,
10713
            explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',
10714
            type => 'YesNo',
10715
        }
10716
    );
10717
    $rs->find_or_create(
10718
        {
10719
            variable => 'DumpTemplateVarsOpac',
10720
            value    => 0,
10721
            explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',
10722
            type => 'YesNo',
10723
        }
10724
    );
10725
    print "Upgrade to $DBversion done (Bug 13948: Add ability to dump template toolkit variables to html comment)\n";
10726
    SetVersion($DBversion);
10727
}
10728
10729
$DBversion = "3.21.00.017";
10730
if ( CheckVersion($DBversion) ) {
10731
    $dbh->do("
10732
        CREATE TABLE uploaded_files (
10733
            id int(11) NOT NULL AUTO_INCREMENT,
10734
            hashvalue CHAR(40) NOT NULL,
10735
            filename TEXT NOT NULL,
10736
            dir TEXT NOT NULL,
10737
            filesize int(11),
10738
            dtcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
10739
            categorycode tinytext,
10740
            owner int(11),
10741
            PRIMARY KEY (id)
10742
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
10743
    ");
10744
10745
    print "Upgrade to $DBversion done (Bug 6874: New cataloging plugin upload.pl)\n";
10746
    print "This plugin comes with a new config variable (upload_path) and a new table (uploaded_files)\n";
10747
    print "To use it, set 'upload_path' config variable and 'OPACBaseURL' system preference and link this plugin to a subfield (856\$u for instance)\n";
10748
    SetVersion($DBversion);
10749
}
10750
10751
$DBversion = "3.21.00.018";
10752
if ( CheckVersion($DBversion) ) {
10753
    $dbh->do(q{
10754
        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
10755
        VALUES
10756
            ('RestrictedPageLocalIPs','',NULL,'Beginning of IP addresses considered as local (comma separated ex: \"127.0.0,127.0.2\")','Free'),
10757
            ('RestrictedPageContent','',NULL,'HTML content of the restricted page','TextArea'),
10758
            ('RestrictedPageTitle','',NULL,'Title of the restricted page (breadcrumb and header)','Free')
10759
    });
10760
    print "Upgrade to $DBversion done (Bug 13485: Add a page to display links to restricted sites)\n";
10761
    SetVersion ($DBversion);
10762
}
10763
10764
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10765
# SEE bug 13068
10766
# if there is anything in the atomicupdate, read and execute it.
10767
10768
my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';
10769
opendir( my $dirh, $update_dir );
10770
foreach my $file ( sort readdir $dirh ) {
10771
    next if $file !~ /\.(sql|perl)$/;  #skip other files
10772
    print "DEV atomic update: $file\n";
10773
    if ( $file =~ /\.sql$/ ) {
10774
        my $installer = C4::Installer->new();
10775
        my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1;
10776
    } elsif ( $file =~ /\.perl$/ ) {
10777
        do $update_dir . $file;
10778
    }
10779
}
10780
10781
=head1 FUNCTIONS
9672
=head1 FUNCTIONS
10782
9673
10783
=head2 TableExists($table)
9674
=head2 TableExists($table)
Lines 10880-10886 sub CheckVersion { Link Here
10880
    return 1 if ( $proposed_version =~ m/XXX/ );
9771
    return 1 if ( $proposed_version =~ m/XXX/ );
10881
9772
10882
    if ( C4::Context->preference("Version") < $version_number
9773
    if ( C4::Context->preference("Version") < $version_number
10883
        && $version_number <= TransformToNum( $Koha::VERSION ) )
9774
        && $version_number <= TransformToNum( C4::Context->final_linear_version ) )
10884
    {
9775
    {
10885
        return 1;
9776
        return 1;
10886
    }
9777
    }
10887
- 

Return to bug 12933