From d83fa3f2daa639ef537ce8b713ff88637e0ddb74 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 6 Oct 2025 10:20:45 +0200 Subject: [PATCH] Bug 40292: Add a specific error if a previous upgrade failed We can reach an inconsistent state if the upgrade DB failed and new_record_id has been created but renamed. I don't think we should try to recover from this state, but have a specific error message in this case. We will guide people asking for help. --- installer/data/mysql/db_revs/241200018.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/db_revs/241200018.pl b/installer/data/mysql/db_revs/241200018.pl index 1c5a4383149..1ef9917fa39 100755 --- a/installer/data/mysql/db_revs/241200018.pl +++ b/installer/data/mysql/db_revs/241200018.pl @@ -12,7 +12,9 @@ return { $sth->execute(); my $column_info = $sth->fetchrow_hashref(); - if ( $column_info && $column_info->{Type} eq 'int(11)' ) { + if ( column_exists('additional_field_values', 'new_record_id') ) { + die "The database is an inconsistent state, a previous upgrade went wrong. Please try a new upgrade from a previous backup and using a newest version of Koha"; + } elsif ( $column_info && $column_info->{Type} eq 'int(11)' ) { # Only run the migration if record_id is still an integer type say_info( $out, "Converting record_id from int(11) to VARCHAR(11)...\n" ); -- 2.34.1