From fcc4de201899c1ccd8203b79237bec80a14104d5 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 2 Jan 2024 12:19:20 +0000 Subject: [PATCH] Bug 35539: Atomicupdate Removal of 'bulk' column Removal of 'finetype' column Removal of 'issuelimit' column Test plan, k-t-d: 1) Add data to the relevant columns, run the following mysql: update categories set bulk = 1; update categories set finetype = 1; update categories set issuelimit = 1; 2) Run updatedatabase, notice it shows a warning and does not update the database 3) Clean up the data, run the folllowing mysql: update categories set bulk = null; update categories set finetype = null; update categories set issuelimit = null; 4) Run updatedatabase again, notice it updates the database as intended Run: t/db_dependent/Circulation/GetHardDueDate.t Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- .../data/mysql/atomicupdate/bug_35539.pl | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_35539.pl diff --git a/installer/data/mysql/atomicupdate/bug_35539.pl b/installer/data/mysql/atomicupdate/bug_35539.pl new file mode 100755 index 0000000000..3a3dac2830 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35539.pl @@ -0,0 +1,64 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); + +return { + bug_number => "35539", + description => "Remove unused columns from 'categories' table", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + if ( column_exists( 'categories', 'bulk' ) ) { + my ($bulkdata) = $dbh->selectrow_array( + q| + SELECT bulk FROM categories; + | + ); + if ($bulkdata) { + say_warning( + $out, + "Data was found in 'bulk' column in 'categories' table. Please remove this data and run the update again." + ); + } else { + $dbh->do("ALTER TABLE categories DROP COLUMN bulk"); + say_info( $out, "Removed 'bulk' column from 'categories' table" ); + } + } + + if ( column_exists( 'categories', 'finetype' ) ) { + my ($bulkdata) = $dbh->selectrow_array( + q| + SELECT finetype FROM categories; + | + ); + if ($bulkdata) { + say_warning( + $out, + "Data was found in 'finetype' column in 'categories' table. Please remove this data and run the update again." + ); + + } else { + $dbh->do("ALTER TABLE categories DROP COLUMN finetype"); + say_info( $out, "Removed 'finetype' column from 'categories' table" ); + } + } + + if ( column_exists( 'categories', 'issuelimit' ) ) { + my ($bulkdata) = $dbh->selectrow_array( + q| + SELECT issuelimit FROM categories; + | + ); + if ($bulkdata) { + say_warning( + $out, + "Data was found in 'issuelimit' column in 'categories' table. Please remove this data and run the update again." + ); + } else { + $dbh->do("ALTER TABLE categories DROP COLUMN issuelimit"); + say_info( $out, "Removed 'issuelimit' column from 'categories' table" ); + } + } + say_info( $out, "Bug 35539: All done." ); + }, +}; -- 2.39.5