From e5a55ad5559b79e7e33b23a5f4f466cdeb105f16 Mon Sep 17 00:00:00 2001 From: CJ Lynce Date: Sat, 25 Oct 2025 17:58:00 +0000 Subject: [PATCH] Bug 41101: DB Updates --- Koha/Schema/Result/BorrowerAttributeType.pm | 2 ++ .../bug_41101_add_staff_editable.pl | 33 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + 3 files changed, 36 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_41101_add_staff_editable.pl diff --git a/Koha/Schema/Result/BorrowerAttributeType.pm b/Koha/Schema/Result/BorrowerAttributeType.pm index 36bf42d4c9..bdf4f6a94d 100644 --- a/Koha/Schema/Result/BorrowerAttributeType.pm +++ b/Koha/Schema/Result/BorrowerAttributeType.pm @@ -188,6 +188,8 @@ __PACKAGE__->add_columns( { data_type => "tinyint", default_value => 0, is_nullable => 0 }, "opac_mandatory", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, + "staff_viewonly", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, ); =head1 PRIMARY KEY diff --git a/installer/data/mysql/atomicupdate/bug_41101_add_staff_editable.pl b/installer/data/mysql/atomicupdate/bug_41101_add_staff_editable.pl new file mode 100644 index 0000000000..70a73ed33b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_41101_add_staff_editable.pl @@ -0,0 +1,33 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); + +return { + bug_number => "41101", + description => "Add staff_viewonly column to borrower_attribute_type table", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + if ( !column_exists( 'borrower_attribute_types', 'staff_viewonly' ) ) { + + $dbh->do( + q{ + ALTER TABLE borrower_attribute_types + ADD COLUMN `staff_viewonly` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is view-only by staff in the staff interface' + AFTER `opac_mandatory` + } + ); + + say $out "Added column 'borrower_attribute_types.staff_viewonly'"; + + $dbh->do( + q{ + UPDATE borrower_attribute_types + SET staff_viewonly = 0; + } + ); + say $out "Update staff_viewonly to make all existing attributes editable by default"; + } + }, + +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 1e57660d28..67ae75d6cc 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1263,6 +1263,7 @@ CREATE TABLE `borrower_attribute_types` ( `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 in the staff interface', `opac_mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not in the OPAC', + `staff_viewonly` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is view-only by staff in the staff interface', PRIMARY KEY (`code`), KEY `auth_val_cat_idx` (`authorised_value_category`), KEY `category_code` (`category_code`), -- 2.39.5