From bb05b37f3e80c6e8f0421e3ae618e981e1b10b13 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 30 Nov 2021 20:06:46 -0300 Subject: [PATCH] Bug 29605: (follow-up) Add language_script_mapping primary key Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens Signed-off-by: Fridolin Somers --- .../data/mysql/atomicupdate/bug_29605.pl | 27 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_29605.pl diff --git a/installer/data/mysql/atomicupdate/bug_29605.pl b/installer/data/mysql/atomicupdate/bug_29605.pl new file mode 100755 index 0000000000..4a2cfe022e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_29605.pl @@ -0,0 +1,27 @@ +use Modern::Perl; + +return { + bug_number => "29605", + description => "Add language_script_mapping primary key", + up => sub { + my ($args) = @_; + my ($dbh) = @$args{qw(dbh)}; + + if ( !primary_key_exists( 'language_script_mapping', 'language_subtag' ) + and index_exists( 'language_script_mapping', 'language_subtag' ) ) { + + $dbh->do(q{ + ALTER TABLE language_script_mapping + DROP KEY `language_subtag`; + }); + } + + if ( !primary_key_exists( 'language_script_mapping', 'language_subtag' ) ) { + + $dbh->do(q{ + ALTER TABLE language_script_mapping + ADD PRIMARY KEY `language_subtag` (`language_subtag`); + }); + } + }, +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 7ae37eca61..9cc6267bfa 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3263,7 +3263,7 @@ DROP TABLE IF EXISTS `language_script_mapping`; CREATE TABLE `language_script_mapping` ( `language_subtag` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `script_subtag` varchar(25) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - KEY `language_subtag` (`language_subtag`) + PRIMARY KEY `language_subtag` (`language_subtag`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- 2.39.5