Line 0
Link Here
|
|
|
1 |
$DBversion = 'XXX'; |
2 |
if( CheckVersion( $DBversion ) ) { |
3 |
if( !unique_key_exists( 'language_subtag_registry', 'uniq_lang' ) ) { |
4 |
my $dupe_languages = $dbh->selectall_arrayref(q| |
5 |
SELECT subtag, type FROM language_subtag_registry GROUP BY subtag, type HAVING COUNT(*) > 1 |
6 |
|, { Slice => {} }); |
7 |
if ( @$dupe_languages ) { |
8 |
warn "You have duplicated languages in the language_subtag_registry table in your database, unique constraint cannot be added"; |
9 |
} else { |
10 |
$dbh->do(q{ |
11 |
ALTER TABLE language_subtag_registry |
12 |
ADD UNIQUE KEY uniq_lang (subtag, type) |
13 |
}); |
14 |
} |
15 |
}; |
16 |
|
17 |
if( !unique_key_exists( 'language_descriptions', 'uniq_desc' ) ) { |
18 |
my $dupe_language_descriptions = $dbh->selectall_arrayref(q| |
19 |
SELECT subtag, lang, type FROM language_descriptions GROUP BY subtag, lang, type HAVING COUNT(*) > 1 |
20 |
|, { Slice => {} }); |
21 |
if ( @$dupe_language_descriptions ) { |
22 |
warn "You have duplicated language descriptionss in the language_descriptions table in your database, unique constraint cannot be added"; |
23 |
} else { |
24 |
$dbh->do(q{ |
25 |
ALTER TABLE language_descriptions |
26 |
ADD UNIQUE KEY uniq_desc (subtag, type, lang) |
27 |
}); |
28 |
} |
29 |
}; |
30 |
|
31 |
if( !unique_key_exists( 'language_rfc4646_to_iso639', 'uniq_code' ) ) { |
32 |
my $dupe_language_rfc = $dbh->selectall_arrayref(q| |
33 |
SELECT rfc4646_subtag, iso639_2_code FROM language_rfc4646_to_iso639 GROUP BY rfc4646_subtag, iso639_2_code HAVING COUNT(*) > 1 |
34 |
|, { Slice => {} }); |
35 |
if ( @$dupe_language_rfc ) { |
36 |
warn "You have duplicated languages in the language_rfc4646_to_iso639 in your database, unique constraint cannot be added"; |
37 |
} else { |
38 |
$dbh->do(q{ |
39 |
ALTER TABLE language_rfc4646_to_iso639 |
40 |
ADD UNIQUE KEY uniq_code (rfc4646_subtag, iso639_2_code) |
41 |
}); |
42 |
} |
43 |
}; |
44 |
|
45 |
$dbh->do(q{ |
46 |
INSERT IGNORE INTO language_subtag_registry (subtag, type, description, added) |
47 |
VALUES |
48 |
('et', 'language', 'Estonian', now()), |
49 |
('lv', 'language', 'Latvian', now()), |
50 |
('lt', 'language', 'Lithuanian', now()), |
51 |
('iu', 'language', 'Inuktitut', now()), |
52 |
('ik', 'language', 'Inupiaq', now()) |
53 |
}); |
54 |
|
55 |
$dbh->do(q{ |
56 |
INSERT IGNORE INTO language_descriptions (subtag, type, lang, description) |
57 |
VALUES |
58 |
('et', 'language', 'en', 'Estonian'), |
59 |
('et', 'language', 'et', 'Eesti'), |
60 |
('lv', 'language', 'en', 'Latvian'), |
61 |
('lv', 'language', 'lv', 'Latvija'), |
62 |
('lt', 'language', 'en', 'Lithuanian'), |
63 |
('lt', 'language', 'lt', 'Lietuvių'), |
64 |
('iu', 'language', 'en', 'Inuktitut'), |
65 |
('iu', 'language', 'iu', 'ᐃᓄᒃᑎᑐᑦ'), |
66 |
('ik', 'language', 'en', 'Inupiaq'), |
67 |
('ik', 'language', 'ik', 'Iñupiaq') |
68 |
}); |
69 |
|
70 |
$dbh->do(q{ |
71 |
INSERT IGNORE INTO language_rfc4646_to_iso639 (rfc4646_subtag, iso639_2_code) |
72 |
VALUES |
73 |
('et', 'est'), |
74 |
('lv', 'lav'), |
75 |
('lt', 'lit'), |
76 |
('iu', 'iku'), |
77 |
('ik', 'ipk') |
78 |
}); |
79 |
|
80 |
NewVersion( $DBversion, 15067, "Add missing languages"); |
81 |
} |