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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Emily Lamancusa 2023-10-30 11:31:31 -04:00 committed by Tomas Cohen Arazi
parent 4310e13a64
commit 40414f9c69
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 23 additions and 1 deletions

View file

@ -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";
},
};

View file

@ -260,7 +260,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?',