From 0d1723c82f759b7d1c7f44a030732d6dd0f54ee4 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 10 Dec 2024 14:44:44 +0000 Subject: [PATCH] Bug 38663: Preparation: Change record_id to varchar: database record_if in the additional_field_values is an int(11) This works for most cases, but in the branches case, the id column is actually a varchar (branchcode). This patch updates the column to accomodate for this. --- .../data/mysql/atomicupdate/bug_38663.pl | 21 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_38663.pl diff --git a/installer/data/mysql/atomicupdate/bug_38663.pl b/installer/data/mysql/atomicupdate/bug_38663.pl new file mode 100755 index 00000000000..1f2b0277fb9 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_38663.pl @@ -0,0 +1,21 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "38663", + description => "Add additional fields to libraries", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do(q{ ALTER TABLE additional_field_values ADD COLUMN new_record_id VARCHAR(11) NOT NULL DEFAULT ''; }); + + $dbh->do(q{ UPDATE additional_field_values SET new_record_id = CAST(record_id AS CHAR(11)); }); + + $dbh->do(q{ ALTER TABLE additional_field_values DROP COLUMN record_id; }); + + $dbh->do(q{ ALTER TABLE additional_field_values RENAME COLUMN new_record_id TO record_id; }); + + say_success( $out, "Converted record_id to VARCHAR" ); + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 3bf15c1007d..c8d6ceb2c9a 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -247,7 +247,7 @@ DROP TABLE IF EXISTS `additional_field_values`; CREATE TABLE `additional_field_values` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key identifier', `field_id` int(11) NOT NULL COMMENT 'foreign key references additional_fields(id)', - `record_id` int(11) NOT NULL COMMENT 'record_id', + `record_id` varchar(11) NOT NULL COMMENT 'record_id', `value` varchar(255) NOT NULL DEFAULT '' COMMENT 'value for this field', PRIMARY KEY (`id`), KEY `afv_fk` (`field_id`), -- 2.39.5