From 2bb11a0cc7a59ee1bb56b11d0ffaf2823a71e1b7 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 18 Dec 2024 09:09:44 -0300 Subject: [PATCH] Bug 38330: DB changes Signed-off-by: Andrew Fuerste Henry Signed-off-by: Martin Renvoize --- .../data/mysql/atomicupdate/bug_38330.pl | 39 +++++++++++++++++++ .../mandatory/marc21_framework_DEFAULT.yml | 4 +- installer/data/mysql/kohastructure.sql | 2 + 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_38330.pl diff --git a/installer/data/mysql/atomicupdate/bug_38330.pl b/installer/data/mysql/atomicupdate/bug_38330.pl new file mode 100755 index 00000000000..b5f006b42f3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_38330.pl @@ -0,0 +1,39 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "38330", + description => "Make bib-level suppression a biblio table field instead of part of a marc tag", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + if ( !column_exists( 'biblio', 'opac_suppressed' ) ) { + $dbh->do( + q{ + ALTER TABLE `biblio` + ADD COLUMN `opac_suppressed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether the record should be suppressed in the OPAC' AFTER `abstract`; + } + ); + say $out "Added column 'biblio.opac_suppressed'"; + } + + if ( !column_exists( 'deletedbiblio', 'opac_suppressed' ) ) { + $dbh->do( + q{ + ALTER TABLE `deletedbiblio` + ADD COLUMN `opac_suppressed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether the record should be suppressed in the OPAC' AFTER `abstract`; + } + ); + say $out "Added column 'deletedbiblio.opac_suppressed'"; + } + + $dbh->do( + q{ + UPDATE marc_subfield_structure SET kohafield='biblio.opac_suppressed' WHERE tagfield=942 AND tagsubfield='n'; + } + ); + say $out "Set the 942\$n => biblio.opac_suppressed mapping for all MARC frameworks"; + say_warning( $out, "You need to run the `maintenance/touch_all_biblios.pl` script" ); + }, +}; diff --git a/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.yml b/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.yml index a0717cccf7a..56bfdfadedb 100644 --- a/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.yml +++ b/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.yml @@ -318,7 +318,7 @@ tables: libopac: "Suppress in OPAC" repeatable: 0 mandatory: 0 - kohafield: + kohafield: biblio.opac_suppressed tab: 9 authorised_value: YES_NO authtypecode: "" @@ -82909,4 +82909,4 @@ sql_statements: SELECT tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, 'ACQ', seealso, link, defaultvalue, maxlength FROM marc_subfield_structure WHERE frameworkcode='' - AND kohafield IN ('biblio.title', 'biblio.author', 'biblioitems.publishercode', 'biblioitems.editionstatement', 'biblio.copyrightdate', 'biblioitems.isbn', 'biblio.seriestitle' );" + AND kohafield IN ('biblio.title', 'biblio.author', 'biblioitems.publishercode', 'biblioitems.editionstatement', 'biblio.copyrightdate', 'biblioitems.isbn', 'biblio.seriestitle' );" \ No newline at end of file diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 9b7dc7fc6ec..f8cc74d189e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1110,6 +1110,7 @@ CREATE TABLE `biblio` ( `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this record was last touched', `datecreated` date NOT NULL COMMENT 'the date this record was added to Koha', `abstract` longtext DEFAULT NULL COMMENT 'summary from the MARC record (520$a in MARC21)', + `opac_suppressed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether the record should be suppressed in the OPAC', PRIMARY KEY (`biblionumber`), KEY `blbnoidx` (`biblionumber`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; @@ -2597,6 +2598,7 @@ CREATE TABLE `deletedbiblio` ( `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this record was last touched', `datecreated` date NOT NULL COMMENT 'the date this record was added to Koha', `abstract` longtext DEFAULT NULL COMMENT 'summary from the MARC record (520$a in MARC21)', + `opac_suppressed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'whether the record should be suppressed in the OPAC', PRIMARY KEY (`biblionumber`), KEY `blbnoidx` (`biblionumber`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 2.48.1