From d5a1c97b93eeb59e9843a22da6e84ffb5b421505 Mon Sep 17 00:00:00 2001 From: Emily Lamancusa Date: Mon, 30 Oct 2023 11:31:31 -0400 Subject: [PATCH] Bug 35190: Set default NULL for authorised_value_category in additional_fields table To test: 1. Start KTD without this patch 2. In the Administration module, create an Additional Field with Authorized Value set to None 3. Create another Additional Field with Authorized Value set to an existing authorized value 4. Apply patch and updatedatabase 5. Access the database in the command line with koha-mysql kohadev 6. Select all rows from additional_fields 7. Confirm that the two Additional Fields from earlier have values of NULL and the correct authorized value, respectively, in their authorised_value_category fields. 8. reset_all to test new install 9. Access the database in the command line 10. Show the table structure for additional_fields and confirm that default for authorised_value_category is NULL Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 40414f9c694f3d044f81662c6d9df9c6ca19e2fc) Signed-off-by: Fridolin Somers --- .../data/mysql/atomicupdate/bug_35190.pl | 22 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_35190.pl diff --git a/installer/data/mysql/atomicupdate/bug_35190.pl b/installer/data/mysql/atomicupdate/bug_35190.pl new file mode 100755 index 0000000000..d3c74dc1b6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35190.pl @@ -0,0 +1,22 @@ +use Modern::Perl; + +return { + bug_number => "35190", + description => "Allow null values for authorized_value_category in additional_fields", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Set NULL as the default value + $dbh->do( + q{ALTER TABLE additional_fields MODIFY COLUMN authorised_value_category varchar(32) DEFAULT NULL COMMENT 'is an authorised value category'} + ); + + # Update any existing rows + $dbh->do(q{UPDATE additional_fields SET authorised_value_category=NULL WHERE authorised_value_category=''}); + + # tables + say $out "Altered authorized_value_category in additional_fields to set NULL as the default value"; + + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e92c6d1215..5d7fab4746 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -243,7 +243,7 @@ CREATE TABLE `additional_fields` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key identifier', `tablename` varchar(255) NOT NULL DEFAULT '' COMMENT 'tablename of the new field', `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'name of the field', - `authorised_value_category` varchar(32) NOT NULL DEFAULT '' COMMENT 'is an authorised value category', + `authorised_value_category` varchar(32) DEFAULT NULL COMMENT 'is an authorised value category', `marcfield` varchar(16) NOT NULL DEFAULT '' COMMENT 'contains the marc field to copied into the record', `marcfield_mode` enum('get','set') NOT NULL DEFAULT 'get' COMMENT 'mode of operation (get or set) for marcfield', `searchable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is the field searchable?', -- 2.39.5