Bug 12478 - set up database tables for elasticsearch
[srvgit] / installer / data / mysql / updatedatabase.pl
index 0610e66..0b844d8 100755 (executable)
@@ -10355,7 +10355,7 @@ if ( CheckVersion($DBversion) ) {
     |);
 
     print "Upgrade to $DBversion done (Bug 8007: Add System Preferences useDischarge, the discharge notice and the new table discharges)\n";
-    SetVersion($DBversion);
+    SetVersion ($DBversion);
 }
 
 $DBversion = "3.19.00.036";
@@ -11755,9 +11755,6 @@ if ( CheckVersion($DBversion) ) {
     $dbh->do(q{
         ALTER TABLE deletedborrowers ADD sms_provider_id INT( 11 ) NULL DEFAULT NULL AFTER smsalertnumber;
     });
-    $dbh->do(q{
-        ALTER TABLE deletedborrowers ADD FOREIGN KEY ( sms_provider_id ) REFERENCES sms_providers ( id ) ON UPDATE CASCADE ON DELETE SET NULL;
-    });
 
     print "Upgrade to $DBversion done (Bug 9021 - Add SMS via email as an alternative to SMS services via SMS::Send drivers)\n";
     SetVersion($DBversion);
@@ -11788,9 +11785,9 @@ if ( CheckVersion($DBversion) ) {
 $DBversion = "3.23.00.023";
 if ( CheckVersion($DBversion) ) {
     $dbh->do(q{
-    INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
-VALUES('OpenLibrarySearch','0','If Yes Open Library search results will show in OPAC',NULL,'YesNo');
-});
+        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+        VALUES('OpenLibrarySearch','0','If Yes Open Library search results will show in OPAC',NULL,'YesNo');
+    });
 
     print "Upgrade to $DBversion done (Bug 6624 - Allow Koha to use the new read API from OpenLibrary)\n";
     SetVersion($DBversion);
@@ -11799,11 +11796,13 @@ VALUES('OpenLibrarySearch','0','If Yes Open Library search results will show in
 $DBversion = "3.23.00.024";
 if ( CheckVersion($DBversion) ) {
     $dbh->do(q{
-    ALTER TABLE deletedborrowers MODIFY COLUMN userid VARCHAR(75) DEFAULT NULL;
-});
+        ALTER TABLE deletedborrowers MODIFY COLUMN userid VARCHAR(75) DEFAULT NULL;
+    });
+
     $dbh->do(q{
-    ALTER TABLE deletedborrowers MODIFY COLUMN password VARCHAR(60) DEFAULT NULL;
-});
+        ALTER TABLE deletedborrowers MODIFY COLUMN password VARCHAR(60) DEFAULT NULL;
+    });
+
     print "Upgrade to $DBversion done (Bug 15517 - Tables borrowers and deletedborrowers differ again)\n";
     SetVersion($DBversion);
 }
@@ -11811,11 +11810,461 @@ if ( CheckVersion($DBversion) ) {
 $DBversion = "3.23.00.025";
 if ( CheckVersion($DBversion) ) {
     $dbh->do(q{
-    DROP TABLE nozebra;
-});
+        DROP TABLE IF EXISTS nozebra;
+    });
 
     print "Upgrade to $DBversion done (Bug 15526 - Drop nozebra database table)\n";
     SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.026";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        UPDATE systempreferences SET value = CONCAT_WS('|', IF(value='', NULL, value), "password") WHERE variable="PatronSelfRegistrationBorrowerUnwantedField" AND value NOT LIKE "%password%";
+    });
+
+    print "Upgrade to $DBversion done (Bug 15343 - Allow patrons to choose their own password on self registration)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.027";
+if ( CheckVersion($DBversion) ) {
+    my ( $db_value ) = $dbh->selectrow_array(q|SELECT count(*) FROM branches|);
+    my $pref_value = C4::Context->preference("singleBranchMode") || 0;
+    if ( $db_value > 1 and $pref_value == 1 ) {
+        warn "WARNING: You have more than 1 libraries in your branches tables but the singleBranchMode system preference is on.\n";
+        warn "This configuration does not make sense. The system preference is going to be deleted,\n";
+        warn "and this parameter will be based on the number of libraries defined.\n";
+    }
+    $dbh->do(q|DELETE FROM systempreferences WHERE variable="singleBranchMode"|);
+
+    print "Upgrade to $DBversion done (Bug 4941 - Can't set branch in staff client when singleBranchMode is enabled)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.028";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) SELECT 'PatronSelfModificationBorrowerUnwantedField',value,NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free' FROM systempreferences WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField';
+    });
+
+    print "Upgrade to $DBversion done (Bug 14658 - Split PatronSelfRegistrationBorrowerUnwantedField into two preferences for creating and editing)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.029";
+if ( CheckVersion($DBversion) ) {
+
+    # move marc21_field_003.pl 040c and 040d to marc21_orgcode.pl
+    $dbh->do(q{
+        update marc_subfield_structure set value_builder='marc21_orgcode.pl' where value_builder IN ( 'marc21_field_003.pl', 'marc21_field_040c.pl', 'marc21_field_040d.pl' );
+    });
+    $dbh->do(q{
+        update auth_subfield_structure set value_builder='marc21_orgcode.pl' where value_builder IN ( 'marc21_field_003.pl', 'marc21_field_040c.pl', 'marc21_field_040d.pl' );
+    });
+
+    print "Upgrade to $DBversion done (Bug 14199 - Unify all organization code plugins)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.030";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+        VALUES ('OpacMaintenanceNotice','','','A user-defined block of HTML to appear on screen when OpacMaintenace is enabled','Textarea')
+    });
+
+    print "Upgrade to $DBversion done (Bug 15311: Let libraries set text to display when OpacMaintenance = on)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.031";
+if(CheckVersion($DBversion)) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+        VALUES ('NoRenewalBeforePrecision', 'date', 'Calculate "No renewal before" based on date or exact time. Only relevant for loans calculated in days, hourly loans are not affected.', 'date|exact_time', 'Choice')
+    });
+
+    print "Upgrade to $DBversion done (Bug 14395 - Two different ways to calculate 'No renewal before')\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.032";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+   -- Add issue_id to accountlines table
+    ALTER TABLE accountlines ADD issue_id INT(11) NULL DEFAULT NULL AFTER accountlines_id;
+    });
+
+## Close out any accruing fines with no current issue
+    $dbh->do(q{
+    UPDATE accountlines LEFT JOIN issues USING ( itemnumber, borrowernumber ) SET accounttype = 'F' WHERE accounttype = 'FU' and issues.issue_id IS NULL;
+    });
+
+## Close out any extra not really accruing fines, keep only the latest accring fine
+    $dbh->do(q{
+    UPDATE accountlines a1
+    LEFT JOIN (SELECT MAX(accountlines_id) AS keeper,
+                      borrowernumber,
+                      itemnumber
+               FROM   accountlines
+               WHERE  accounttype = 'FU'
+               GROUP BY borrowernumber, itemnumber
+              ) a2 USING ( borrowernumber, itemnumber )
+    SET    a1.accounttype = 'F'
+    WHERE  a1.accounttype = 'FU'
+    AND  a1.accountlines_id != a2.keeper;
+    });
+
+## Update the unclosed fines to add the current issue_id to them
+    $dbh->do(q{
+    UPDATE accountlines LEFT JOIN issues USING ( itemnumber ) SET accountlines.issue_id = issues.issue_id WHERE accounttype = 'FU'; 
+    });
+
+    print "Upgrade to $DBversion done (Bug 15675 - Add issue_id column to accountlines and use it for updating fines)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.033";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+    UPDATE systempreferences SET value = CONCAT_WS('|', IF(value = '', NULL, value), 'cardnumber') WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField' AND value NOT LIKE '%cardnumber%';
+    });
+
+    $dbh->do(q{
+    UPDATE systempreferences SET value = CONCAT_WS('|', IF(value = '', NULL, value), 'categorycode') WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField' AND value NOT LIKE '%categorycode%';
+    });
+
+    print "Upgrade to $DBversion done (Bug 14659 - Allow patrons to enter card number and patron category on OPAC registration page)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.034";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do(q{
+        ALTER TABLE `items` ADD `new` VARCHAR(32) NULL AFTER `stocknumber`;
+    });
+    $dbh->do(q{
+        ALTER TABLE `deleteditems` ADD `new` VARCHAR(32) NULL AFTER `stocknumber`;
+    });
+    print "Upgrade to $DBversion done (Bug 11023: Adds field 'new' in items and deleteditems tables)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.035";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('HTML5MediaYouTube',0,'Embed|Don\'t embed','YouTube links as videos','YesNo');
+    });
+    print "Upgrade to $DBversion done (Bug 14168 - enhance streaming cataloging to include youtube)\n";
+
+    SetVersion($DBversion);
+    }
+
+$DBversion = "3.23.00.036";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do(q{
+    INSERT INTO systempreferences (variable,value,explanation,type) VALUES ('HoldsQueueSkipClosed', '0', 'If enabled, any libraries that are closed when the holds queue is built will be ignored for the purpose of filling holds.', 'YesNo');
+    });
+    print "Upgrade to $DBversion done (Bug 12803 - Add ability to skip closed libraries when generating the holds queue)\n";
+    SetVersion($DBversion);
+    }
+
+$DBversion = "3.23.00.037";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+## Add the new currency.archived column
+    $dbh->do(q{
+    ALTER TABLE currency ADD column archived tinyint(1) DEFAULT 0;
+    });
+## Set currency=NULL if empty (just in case)
+    $dbh->do(q{
+    UPDATE aqorders SET currency=NULL WHERE currency="";
+    });
+## Insert the missing currency and mark them as archived before adding the FK
+    $dbh->do(q{
+    INSERT INTO currency(currency, archived) SELECT distinct currency, 1 FROM aqorders WHERE currency NOT IN (SELECT currency FROM currency);
+    });
+## Correct the field length in aqorders before adding FK too
+    $dbh->do(q{ ALTER TABLE aqorders MODIFY COLUMN currency varchar(10) default NULL; });
+## And finally add the FK
+    $dbh->do(q{
+    ALTER TABLE aqorders ADD FOREIGN KEY (currency) REFERENCES currency(currency) ON DELETE SET NULL ON UPDATE SET null;
+    });
+
+    print "Upgrade to $DBversion done (Bug 15084 - Move the currency related code to Koha::Acquisition::Currenc[y|ies])\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.038";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do(q{
+    INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('decreaseLoanHighHoldsControl', 'static', 'static|dynamic', "Chooses between static and dynamic high holds checking", 'Choice'), ('decreaseLoanHighHoldsIgnoreStatuses', '', 'damaged|itemlost|notforloan|withdrawn', "Ignore items with these statuses for dynamic high holds checking", 'Choice');
+    });
+    print "Upgrade to $DBversion done (Bug 14694 - Make decreaseloanHighHolds more flexible)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.039";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+
+    $dbh->do(q{
+    ALTER TABLE suggestions
+    MODIFY COLUMN currency varchar(10) default NULL;
+    });
+    $dbh->do(q{
+    ALTER TABLE aqbooksellers
+    MODIFY COLUMN currency varchar(10) default NULL;
+    });
+    print "Upgrade to $DBversion done (Bug 15084 - Move the currency related code to Koha::Acquisition::Currenc[y|ies])\n";
+    SetVersion($DBversion);
+}
+
+
+$DBversion = "3.23.00.040";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+
+    my $c = $dbh->selectrow_array('SELECT COUNT(*) FROM systempreferences WHERE variable="intranetcolorstylesheet" AND value="blue.css"');
+
+    if ( $c ) {
+        print "WARNING: You are using a stylesheeet which has been removed from the Koha codebase.\n";
+        print "Update your intranetcolorstylesheet.\n";
+    }
+    print "Upgrade to $DBversion done (Bug 16019 - Check intranetcolorstylesheet for blue.css)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.041";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+
+    my $dbh = C4::Context->dbh;
+    my ($print_error) = $dbh->{PrintError};
+    $dbh->{RaiseError} = 0;
+    $dbh->{PrintError} = 0;
+    $dbh->do("ALTER TABLE overduerules_transport_types ADD COLUMN letternumber INT(1) NOT NULL DEFAULT 1 AFTER id");
+    $dbh->{PrintError} = $print_error;
+
+    print "Upgrade to $DBversion done (Bug 16007: Make sure overduerules_transport_types.letternumber exists)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.042";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+
+    $dbh->do(q{
+            ALTER TABLE items CHANGE new new_status VARCHAR(32) NULL;
+            });
+    $dbh->do(q{
+            ALTER TABLE deleteditems CHANGE new new_status VARCHAR(32) NULL;
+            });
+    $dbh->do(q{
+            UPDATE systempreferences SET value=REPLACE(value, '"items.new"', '"items.new_status"') WHERE variable="automatic_item_modification_by_age_configuration";
+            });
+
+    print "Upgrade to $DBversion done (Bug 16004 - Replace items.new with items.new_status)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.043";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do(q{
+            UPDATE systempreferences SET value="" WHERE value IS NULL;
+            });
+
+    print "Upgrade to $DBversion done (Bug 16070 - Empty (undef) system preferences may cause some issues in combination with memcache)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.044";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do(q{
+            INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES
+            ('GoogleOpenIDConnect', '0', NULL, 'if ON, allows the use of Google OpenID Connect for login', 'YesNo'),
+            ('GoogleOAuth2ClientID', '', NULL, 'Client ID for the web app registered with Google', 'Free'),
+            ('GoogleOAuth2ClientSecret', '', NULL, 'Client Secret for the web app registered with Google', 'Free'),
+            ('GoogleOpenIDConnectDomain', '', NULL, 'Restrict OpenID Connect to this domain (or subdomains of this domain). Leave blank for all Google domains', 'Free');
+            });
+
+    print "Upgrade to $DBversion done (Bug 10988 - Allow login via Google OAuth2 (OpenID Connect))\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.045";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+## Holds details for vendors supplying goods by EDI
+   $dbh->do(q{
+           CREATE TABLE IF NOT EXISTS vendor_edi_accounts (
+                   id INT(11) NOT NULL auto_increment,
+                   description TEXT NOT NULL,
+                   host VARCHAR(40),
+                   username VARCHAR(40),
+                   password VARCHAR(40),
+                   last_activity DATE,
+                   vendor_id INT(11) REFERENCES aqbooksellers( id ),
+                   download_directory TEXT,
+                   upload_directory TEXT,
+                   san VARCHAR(20),
+                   id_code_qualifier VARCHAR(3) default '14',
+                   transport VARCHAR(6) default 'FTP',
+                   quotes_enabled TINYINT(1) not null default 0,
+                   invoices_enabled TINYINT(1) not null default 0,
+                   orders_enabled TINYINT(1) not null default 0,
+                   responses_enabled TINYINT(1) not null default 0,
+                   auto_orders TINYINT(1) not null default 0,
+                   shipment_budget INTEGER(11) REFERENCES aqbudgets( budget_id ),
+                   PRIMARY KEY  (id),
+                   KEY vendorid (vendor_id),
+                   KEY shipmentbudget (shipment_budget),
+                   CONSTRAINT vfk_vendor_id FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ),
+                   CONSTRAINT vfk_shipment_budget FOREIGN KEY ( shipment_budget ) REFERENCES aqbudgets ( budget_id )
+                       ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+   });
+
+## Hold the actual edifact messages with links to associated baskets
+   $dbh->do(q{
+           CREATE TABLE IF NOT EXISTS edifact_messages (
+                   id INT(11) NOT NULL auto_increment,
+                   message_type VARCHAR(10) NOT NULL,
+                   transfer_date DATE,
+                   vendor_id INT(11) REFERENCES aqbooksellers( id ),
+                   edi_acct  INTEGER REFERENCES vendor_edi_accounts( id ),
+                   status TEXT,
+                   basketno INT(11) REFERENCES aqbasket( basketno),
+                   raw_msg MEDIUMTEXT,
+                   filename TEXT,
+                   deleted BOOLEAN NOT NULL DEFAULT 0,
+                   PRIMARY KEY  (id),
+                   KEY vendorid ( vendor_id),
+                   KEY ediacct (edi_acct),
+                   KEY basketno ( basketno),
+                   CONSTRAINT emfk_vendor FOREIGN KEY ( vendor_id ) REFERENCES aqbooksellers ( id ),
+                   CONSTRAINT emfk_edi_acct FOREIGN KEY ( edi_acct ) REFERENCES vendor_edi_accounts ( id ),
+                   CONSTRAINT emfk_basketno FOREIGN KEY ( basketno ) REFERENCES aqbasket ( basketno )
+                       ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+            });
+
+## invoices link back to the edifact message it was generated from
+   $dbh->do(q{
+           ALTER TABLE aqinvoices ADD COLUMN message_id INT(11) REFERENCES edifact_messages( id );
+           });
+
+## clean up link on deletes
+   $dbh->do(q{
+           ALTER TABLE aqinvoices ADD CONSTRAINT edifact_msg_fk FOREIGN KEY ( message_id ) REFERENCES edifact_messages ( id ) ON DELETE SET NULL;
+           });
+
+## Hold the supplier ids from quotes for ordering
+## although this is an EAN-13 article number the standard says 35 characters ???
+   $dbh->do(q{
+           ALTER TABLE aqorders ADD COLUMN line_item_id VARCHAR(35);
+           });
+
+## The suppliers unique reference usually a quotation line number ('QLI')
+## Otherwise Suppliers unique orderline reference ('SLI')
+   $dbh->do(q{
+           ALTER TABLE aqorders ADD COLUMN suppliers_reference_number VARCHAR(35);
+           });
+   $dbh->do(q{
+           ALTER TABLE aqorders ADD COLUMN suppliers_reference_qualifier VARCHAR(3);
+           });
+   $dbh->do(q{
+           ALTER TABLE aqorders ADD COLUMN suppliers_report text;
+           });
+
+## hold the EAN/SAN used in ordering
+   $dbh->do(q{
+           CREATE TABLE IF NOT EXISTS edifact_ean (
+                   ee_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+                   description VARCHAR(128) NULL DEFAULT NULL,
+                   branchcode VARCHAR(10) NOT NULL REFERENCES branches (branchcode),
+                   ean VARCHAR(15) NOT NULL,
+                   id_code_qualifier VARCHAR(3) NOT NULL DEFAULT '14',
+                   CONSTRAINT efk_branchcode FOREIGN KEY ( branchcode ) REFERENCES branches ( branchcode )
+                   ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+           });
+## Syspref budget to hold shipping costs
+   $dbh->do(q{
+           INSERT INTO systempreferences (variable, explanation, type) VALUES('EDIInvoicesShippingBudget','The budget code used to allocate shipping charges to when processing EDI Invoice messages',  'free');
+           });
+
+## Add a permission for managing EDI
+   $dbh->do(q{
+           INSERT INTO permissions (module_bit, code, description) values (11, 'edi_manage', 'Manage EDIFACT transmissions');
+           });
+
+   print "Upgrade to $DBversion done (Bug 7736 - Edifact QUOTE and ORDER functionality))\n";
+   SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.046";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+
+    $dbh->do(q{
+    ALTER TABLE vendor_edi_accounts ADD COLUMN plugin VARCHAR(256) NOT NULL DEFAULT "";
+    });
+
+    print "Upgrade to $DBversion done (Bug 15630 - Make Edifact module pluggable))\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.047";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+
+    $dbh->do(q{
+         INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('IntranetReportsHomeHTML', '', 'Show the following HTML in a div on the bottom of the reports home page', NULL, 'Free');
+         });
+    $dbh->do(q{
+         INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('IntranetCirculationHomeHTML', '', 'Show the following HTML in a div on the bottom of the reports home page', NULL, 'Free');
+         });
+
+    print "Upgrade to $DBversion done (Bug 15008 - Add custom HTML areas to circulation and reports home pages)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.23.00.048";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do(q{
+    INSERT IGNORE INTO `systempreferences` (variable,value,options,explanation,type)  SELECT 'OPACISBD', value, '70|10', 'Allows to define ISBD view in OPAC', 'Textarea' FROM `systempreferences` WHERE variable = 'ISBD';
+    });
+
+    print "Upgrade to $DBversion done (Bug 5979 - Add separate OPACISBD system preference)\n";
+    SetVersion($DBversion);
+}
+
+
+
+$DBversion = "3.23.00.049";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+my $dbh = C4::Context->dbh;
+my ( $column_has_been_used ) = $dbh->selectrow_array(q|
+            SELECT COUNT(*)
+                FROM borrower_attributes
+                    WHERE password IS NOT NULL
+                    |);
+
+if ( $column_has_been_used ) {
+        print q|WARNING: The columns borrower_attribute_types.password_allowed and borrower_attributes.password have been removed from the Koha codebase. They were not used. However your installation has at least one borrower_attributes.password defined. In order not to alter your data, the columns have been kept, please save the information elsewhere and remove these columns manually.|;
+} else {
+        $dbh->do(q|
+        ALTER TABLE borrower_attribute_types DROP column password_allowed
+        |);
+        $dbh->do(q|
+        ALTER TABLE borrower_attributes DROP column password;
+        |);
+    }
+    print "Upgrade to $DBversion done (Bug 12267 - Allow password option in Patron Attribute non functional)\n";
+        SetVersion($DBversion);
+}
+
+
+$DBversion = "XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    my $installer = C4::Installer->new();
+    my $full_path = C4::Context->config('intranetdir') . "/installer/data/$installer->{dbms}/elasticsearch_mapping.sql";
+    my $error     = $installer->load_sql($full_path);
+    warn $error if $error;
+    print "Upgrade to $DBversion done (Bug 12478 - set up elasticsearch tables)\n";
+    SetVersion($DBversion);
+}
 
 # DEVELOPER PROCESS, search for anything to execute in the db_update directory
 # SEE bug 13068