From 3bd3db0e12869115e63dd23e4c3b6ce547d084de Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 21 Oct 2023 08:17:10 +0200 Subject: [PATCH] Bug 31383: Fix the DB upgrade process This patch fixes misc4dev/run_tests.pl --run-db-upgrade-only We need to make sure the column exists before running the query. Signed-off-by: Jonathan Druart --- installer/data/mysql/db_revs/211200005.pl | 23 +++++++++++++---------- installer/data/mysql/db_revs/211200013.pl | 12 +++++++----- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/installer/data/mysql/db_revs/211200005.pl b/installer/data/mysql/db_revs/211200005.pl index 48c97c746b..c270ae6c58 100755 --- a/installer/data/mysql/db_revs/211200005.pl +++ b/installer/data/mysql/db_revs/211200005.pl @@ -6,15 +6,18 @@ return { up => sub { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - $dbh->do(q{ - DELETE FROM additional_contents - WHERE code NOT IN ( - SELECT code FROM ( - SELECT code - FROM additional_contents - WHERE lang = "default" - ) as tmp - ); - }); + # Run this only if 230600041 has not been run before + if ( column_exists('additional_contents', 'lang') ) { + $dbh->do(q{ + DELETE FROM additional_contents + WHERE code NOT IN ( + SELECT code FROM ( + SELECT code + FROM additional_contents + WHERE lang = "default" + ) as tmp + ); + }); + } }, } diff --git a/installer/data/mysql/db_revs/211200013.pl b/installer/data/mysql/db_revs/211200013.pl index 43097d2e61..1abc5869b2 100755 --- a/installer/data/mysql/db_revs/211200013.pl +++ b/installer/data/mysql/db_revs/211200013.pl @@ -48,11 +48,13 @@ return { }); say $out "Ensure additional_contents.code is VARCHAR(100)"; - $dbh->do(q{ - ALTER TABLE `additional_contents` - MODIFY COLUMN `lang` VARCHAR(50) NOT NULL DEFAULT '' - }); - say $out "Ensure additional_contents.lang is VARCHAR(50)"; + if ( column_exists('additional_contents', 'lang') ) { + $dbh->do(q{ + ALTER TABLE `additional_contents` + MODIFY COLUMN `lang` VARCHAR(50) NOT NULL DEFAULT '' + }); + say $out "Ensure additional_contents.lang is VARCHAR(50)"; + } $dbh->do(q{ ALTER TABLE search_marc_map MODIFY `marc_type` enum('marc21','unimarc') NOT NULL COMMENT 'what MARC type this map is for' -- 2.39.5