From 1dd482bb8ebf7091dfff913ad9dc8f8a0e6f328d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 6 Oct 2023 10:41:20 +0100 Subject: [PATCH] Bug 34328: Make update idempotent Signed-off-by: Katrin Fischer Perltidied the atomic update. Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- .../data/mysql/atomicupdate/bug_34328.pl | 68 ++++++++++++------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_34328.pl b/installer/data/mysql/atomicupdate/bug_34328.pl index 5fbf7cdee2..82a1ce5ef3 100755 --- a/installer/data/mysql/atomicupdate/bug_34328.pl +++ b/installer/data/mysql/atomicupdate/bug_34328.pl @@ -6,45 +6,65 @@ return { up => sub { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; - $dbh->do(q{ - INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) + + # Unique key on subtag + code.. use INSERT IGNORE + $dbh->do( + q{ + INSERT IGNORE INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code) VALUES ( 'gd','gla' ) - }); + } + ); - $dbh->do(q{ - INSERT INTO language_subtag_registry( subtag, type, description, added) + # Unique key on subtag + type.. use INSERT IGNORE + $dbh->do( + q{ + INSERT IGNORE INTO language_subtag_registry( subtag, type, description, added) VALUES ( 'gd', 'language', 'Scottish Gaelic', NOW() ) - }); + } + ); - $dbh->do(q{ - INSERT INTO language_descriptions(subtag, type, lang, description) + # Unique key on subtag + type + lang.. use INSERT IGNORE + $dbh->do( + q{ + INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'gd', 'language', 'en', 'Scottish Gaelic') - }); + } + ); - $dbh->do(q{ - INSERT INTO language_descriptions(subtag, type, lang, description) + $dbh->do( + q{ + INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'gd', 'language', 'en_GB', 'Scottish Gaelic') - }); + } + ); - $dbh->do(q{ - INSERT INTO language_descriptions(subtag, type, lang, description) + $dbh->do( + q{ + INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'gd', 'language', 'gd', 'Gàidhlig') - }); + } + ); - $dbh->do(q{ - INSERT INTO language_descriptions(subtag, type, lang, description) + $dbh->do( + q{ + INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'gd', 'language', 'fr', 'Gaélique écossais') - }); + } + ); - $dbh->do(q{ - INSERT INTO language_descriptions(subtag, type, lang, description) + $dbh->do( + q{ + INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'gd', 'language', 'de', 'Schottisch-Gälisch') - }); + } + ); - $dbh->do(q{ - INSERT INTO language_descriptions(subtag, type, lang, description) + $dbh->do( + q{ + INSERT IGNORE INTO language_descriptions(subtag, type, lang, description) VALUES ( 'gd', 'language', 'pl', 'Język szkocki gaelicki') - }); + } + ); say $out "Added new language 'Scottish Gaelic'"; }, -- 2.39.5