From d01f0e83ac02a4b29c8dc4c8298b419b7d10293e 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 --- .../data/mysql/atomicupdate/bug_38330.pl | 39 +++++++++++++++++++ .../mandatory/marc21_framework_DEFAULT.yml | 2 +- installer/data/mysql/kohastructure.sql | 2 + 3 files changed, 42 insertions(+), 1 deletion(-) 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 0000000000..b5f006b42f --- /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 48fdce3942..6f4889b390 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: "" diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 3bf15c1007..46af1ab0d2 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1111,6 +1111,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; @@ -2575,6 +2576,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.39.5