From 1cb9890f4ecfb285b3b17ba0bc14cc391fa7d8fb 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 --- .../data/mysql/atomicupdate/bug_35539.pl | 59 +++++++++++++++++++ 1 file changed, 59 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..1dcc34491e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35539.pl @@ -0,0 +1,59 @@ +use Modern::Perl; + +use Term::ANSIColor qw(:constants); + +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 $out YELLOW, + "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 $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 $out YELLOW, + "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 $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 $out YELLOW, + "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 $out "Removed 'issuelimit' column from 'categories' table"; + } + } + + say $out WHITE, "Bug 35539: All done."; + }, +}; -- 2.30.2