From 333109c7fd3e463662119f90c5745948cf5764a7 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 1 Sep 2023 12:38:44 +0000 Subject: [PATCH] Bug 27153: DB Updates We start by adding the field to the table It is possible a library would want two versions of the same field in the indexing. We need to make the filter part of the primary key in order to allow this Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- .../data/mysql/atomicupdate/bug_27153.pl | 31 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + 2 files changed, 32 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_27153.pl diff --git a/installer/data/mysql/atomicupdate/bug_27153.pl b/installer/data/mysql/atomicupdate/bug_27153.pl new file mode 100755 index 0000000000..b226888bc6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_27153.pl @@ -0,0 +1,31 @@ +use Modern::Perl; + +return { + bug_number => "27153", + description => "Add option to filter search fields", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + unless ( column_exists( 'search_marc_to_field', 'filter' ) ) { + $dbh->do( + q{ + ALTER TABLE search_marc_to_field + ADD filter varchar(100) NOT NULL DEFAULT '' COMMENT 'specify a filter to be applied to field' + AFTER search + } + ); + say $out "Added column 'search_marc_to_field.filter'"; + } + unless ( primary_key_exists( 'search_marc_to_field', 'filter' ) ) { + $dbh->do( + q{ + ALTER TABLE search_marc_to_field + DROP PRIMARY KEY, + ADD PRIMARY KEY (search_marc_map_id,search_field_id,filter) + } + ); + say $out "Updated primary key to include filter"; + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index ae30fd3478..f90fc2341f 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -5392,6 +5392,7 @@ DROP TABLE IF EXISTS `search_marc_to_field`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `search_marc_to_field` ( `search` tinyint(1) NOT NULL DEFAULT 1, + `filter` varchar(100) NOT NULL DEFAULT '' COMMENT 'specify a filter to be applied to field', `search_marc_map_id` int(11) NOT NULL, `search_field_id` int(11) NOT NULL, `facet` tinyint(1) DEFAULT 0 COMMENT 'true if a facet field should be generated for this', -- 2.39.5