From a1b65d90c80906eea847dcf0a0bb895772e7a30a Mon Sep 17 00:00:00 2001 From: Jake Deery Date: Mon, 2 Mar 2026 17:49:57 +0000 Subject: [PATCH] Bug 37346: atomicupdate - DO NOT PUSH --- .../data/mysql/atomicupdate/bug_37346.pl | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_37346.pl diff --git a/installer/data/mysql/atomicupdate/bug_37346.pl b/installer/data/mysql/atomicupdate/bug_37346.pl new file mode 100644 index 00000000000..6cbe75ba107 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_37346.pl @@ -0,0 +1,43 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); + +return { + bug_number => "37346", + description => "The VirtualShelf object should have an 'owner' accessor to return the related owner Koha::Patron", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + if ( !column_exists( 'virtualshelves', 'owner_id' ) ) { + $dbh->do( + q{ + ALTER TABLE virtualshelves + RENAME COLUMN owner TO owner_id + } + ); + + say_success $out, 'Renamed owner column to owner_id in virtualshelves table'; + } + + if ( foreign_key_exists( 'virtualshelves', 'virtualshelves_ibfk_1' ) ) { + $dbh->do( + q{ + ALTER TABLE virtualshelves + DROP FOREIGN KEY virtualshelves_ibfk_1 + } + ); + $dbh->do( + q{ + ALTER TABLE virtualshelves + ADD CONSTRAINT virtualshelves_ibfk_1 + FOREIGN KEY (`owner_id`) + REFERENCES `borrowers` (`borrowernumber`) + ON DELETE SET NULL + ON UPDATE SET NULL + } + ); + + say_success $out, 'Dropped and recreated owner_id foreign key in virtualshelves'; + } + }, +}; -- 2.50.1 (Apple Git-155)