Bug 19670: Change Collation of marc_field to allow mixed case mappings
authorEre Maijala <ere.maijala@helsinki.fi>
Thu, 14 Mar 2019 12:33:18 +0000 (14:33 +0200)
committerLucas Gass <lucas@bywatersolutions.com>
Tue, 23 Apr 2019 13:46:51 +0000 (13:46 +0000)
Test plan:
1. Apply patch and update database
2. Verify that you can add a search field mapping for both 100a and 100A.
3. Verify that the above also works with a newly-created database.

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit a5f3d405f56202beb4426da52f3bf4019f26484b)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 4a1986b6b102304ab0cce24e32a334f11d9556df)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

installer/data/mysql/atomicupdate/bug_19670.perl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql

diff --git a/installer/data/mysql/atomicupdate/bug_19670.perl b/installer/data/mysql/atomicupdate/bug_19670.perl
new file mode 100644 (file)
index 0000000..fbe9e91
--- /dev/null
@@ -0,0 +1,13 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    my $table_sth = $dbh->prepare('SHOW CREATE TABLE `search_marc_map`');
+    $table_sth->execute();
+    my @table = $table_sth->fetchrow_array();
+    unless ( $table[1] =~ /`marc_field`.*COLLATE utf8mb4_bin/ ) { #catches utf8mb4 collated tables
+        $dbh->do("ALTER TABLE `search_marc_map` MODIFY `marc_field` VARCHAR(255) NOT NULL COLLATE utf8mb4_bin COMMENT 'the MARC specifier for this field'");
+    }
+
+    # Always end with this (adjust the bug info)
+    SetVersion( $DBversion );
+       print "Upgrade to $DBversion done (Bug 19670 - Change collation of marc_field to allow mixed case search field mappings)\n";
+}
index a1037f5..059b537 100644 (file)
@@ -1504,7 +1504,7 @@ CREATE TABLE `search_marc_map` (
   id int(11) NOT NULL AUTO_INCREMENT,
   index_name ENUM('biblios','authorities') NOT NULL COMMENT 'what storage index this map is for',
   marc_type ENUM('marc21', 'unimarc', 'normarc') NOT NULL COMMENT 'what MARC type this map is for',
-  marc_field VARCHAR(255) NOT NULL COMMENT 'the MARC specifier for this field',
+  marc_field VARCHAR(255) NOT NULL COLLATE utf8mb4_bin COMMENT 'the MARC specifier for this field',
   PRIMARY KEY(`id`),
   UNIQUE key `index_name` (`index_name`, `marc_field` (191), `marc_type`),
   INDEX (`index_name`)