From 46c59f80fc19a10be61da1b8eff700fc209c5e3b 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 --- .../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 3869b55ccc..91877d51b3 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3261,7 +3261,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.34.1