Bug 29631: Prevent uniq_lang creation to fail
We got 2 reports of this problem in the last 24h, uniq_lang unique key is failing to be created because several rows with the same (subtag, type) exist in DB. I have no idea how this is possible, but apparently it is. Test plan: Checkout a commit before 21.06.00.012 reset_all Create duplicate in language_subtag_registry > insert into language_subtag_registry(subtag, type, description) values('IN', 'region', 'India'); Checkout master+this patch, updatedatabase => Only 1 IN-region exists in the DB, the last one. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
1eb6a02c2f
commit
9c2929a351
1 changed files with 9 additions and 0 deletions
|
@ -8,6 +8,15 @@ return {
|
|||
my $dbh = $args->{dbh};
|
||||
|
||||
if( !unique_key_exists( 'language_subtag_registry', 'uniq_lang' ) ) {
|
||||
|
||||
$dbh->do(q{
|
||||
DELETE a
|
||||
FROM language_subtag_registry AS a, language_subtag_registry AS b
|
||||
WHERE a.id < b.id
|
||||
AND a.subtag IS NOT NULL
|
||||
AND a.subtag=b.subtag
|
||||
AND a.type=b.type
|
||||
});
|
||||
$dbh->do(q{
|
||||
ALTER TABLE language_subtag_registry
|
||||
ADD UNIQUE KEY uniq_lang (subtag, type)
|
||||
|
|
Loading…
Reference in a new issue