From 4c2928f8f08d1b97027f0aae32197992d2584c2a Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 1 Jul 2022 14:43:09 +0000 Subject: [PATCH] Bug 31086: DB update This update sets branchcode as NOT NULL default set to 0 as borrowernumber is Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 1565efe8f3e4c782e4d94a6c06cc71d2ac460d43) Signed-off-by: Lucas Gass --- ...6_do_not_allow_null_branchcode_in_reserves.pl | 16 ++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl diff --git a/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl b/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl new file mode 100755 index 0000000000..f0635e1f2c --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "31086", + description => "Do not allow null values in branchcodes for reserves", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do(q{ + ALTER TABLE reserves + MODIFY COLUMN `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 0 COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at' + }); + # Print useful stuff here + say $out "Removed NULL option from branchcode for reserves"; + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index bffd10c5b5..1bc5aba513 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4383,7 +4383,7 @@ CREATE TABLE `reserves` ( `borrowernumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the borrowers table defining which patron this hold is for', `reservedate` date DEFAULT NULL COMMENT 'the date the hold was placed', `biblionumber` int(11) NOT NULL DEFAULT 0 COMMENT 'foreign key from the biblio table defining which bib record this hold is on', - `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at', + `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 0 COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at', `desk_id` int(11) DEFAULT NULL COMMENT 'foreign key from the desks table defining which desk the patron should pick this hold up at', `notificationdate` date DEFAULT NULL COMMENT 'currently unused', `reminderdate` date DEFAULT NULL COMMENT 'currently unused', -- 2.39.5