From 57b7c7163d213824c557df8221cfdcdb74383845 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 5 Jun 2024 22:10:34 +0000 Subject: [PATCH] Bug 35635: DB Updates Signed-off-by: Brendan Lawlor --- .../bug_35635_add_opac_mandatory.pl | 30 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 3 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_35635_add_opac_mandatory.pl diff --git a/installer/data/mysql/atomicupdate/bug_35635_add_opac_mandatory.pl b/installer/data/mysql/atomicupdate/bug_35635_add_opac_mandatory.pl new file mode 100755 index 0000000000..61fa381551 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35635_add_opac_mandatory.pl @@ -0,0 +1,30 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); + +return { + bug_number => "35635", + description => "Add opac_mandatory column to borrower_attribute_type table", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + if ( !column_exists( 'borrower_attribute_types', 'opac_mandatory' ) ) { + $dbh->do( + q{ + ALTER TABLE borrower_attribute_types + ADD COLUMN `opac_mandatory` tinyint(1) DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not on the OPAC' + AFTER `mandatory` + } + ); + + say $out "Added column 'borrower_attribute_types.opac_mandatory'"; + + $dbh->do(q{ + UPDATE borrower_attribute_types + SET opac_mandatory = 1 WHERE mandatory = 1; + }); + say $out "Update opac_mandatory to match mandatory column"; + } + }, + +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 7afeabffc0..a2d6b147fd 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1250,7 +1250,8 @@ CREATE TABLE `borrower_attribute_types` ( `category_code` varchar(10) DEFAULT NULL COMMENT 'defines a category for an attribute_type', `class` varchar(255) NOT NULL DEFAULT '' COMMENT 'defines a class for an attribute_type', `keep_for_pseudonymization` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 for no)', - `mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not', + `mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not in the staff client', + `opac_mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not in the OPAC', PRIMARY KEY (`code`), KEY `auth_val_cat_idx` (`authorised_value_category`), KEY `category_code` (`category_code`), -- 2.39.2