1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2018 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Schema; 19 20use Fisharebest\Webtrees\Database; 21 22/** 23 * Upgrade the database schema from version 26 to version 27. 24 */ 25class Migration26 implements MigrationInterface 26{ 27 /** 28 * Upgrade to to the next version 29 * 30 * @return void 31 */ 32 public function upgrade(): void 33 { 34 // Earlier versions of webtrees put quote marks round soundex codes. 35 // These are harmless, but clean them up for consistency. 36 Database::exec( 37 "UPDATE `##name` SET" . 38 " n_soundex_givn_std = TRIM('''' FROM n_soundex_givn_std)," . 39 " n_soundex_surn_std = TRIM('''' FROM n_soundex_surn_std)," . 40 " n_soundex_givn_dm = TRIM('''' FROM n_soundex_givn_dm )," . 41 " n_soundex_surn_dm = TRIM('''' FROM n_soundex_surn_dm )" 42 ); 43 44 // Earlier versions of webtrees added zero codes for names without phonetic content. 45 // These are harmless, but clean them up for consistency. 46 Database::exec( 47 "UPDATE `##name` SET" . 48 " n_soundex_givn_std = REPLACE(n_soundex_givn_std, '0000:', '')," . 49 " n_soundex_surn_std = REPLACE(n_soundex_surn_std, '0000:', '')," . 50 " n_soundex_givn_dm = REPLACE(n_soundex_givn_dm, '000000:', '')," . 51 " n_soundex_surn_dm = REPLACE(n_soundex_surn_dm, '000000:', '')" 52 ); 53 Database::exec( 54 "UPDATE `##name` SET" . 55 " n_soundex_givn_std = REPLACE(n_soundex_givn_std, ':0000', '')," . 56 " n_soundex_surn_std = REPLACE(n_soundex_surn_std, ':0000', '')," . 57 " n_soundex_givn_dm = REPLACE(n_soundex_givn_dm, ':000000', '')," . 58 " n_soundex_surn_dm = REPLACE(n_soundex_surn_dm, ':000000', '')" 59 ); 60 Database::exec( 61 "UPDATE `##name` SET" . 62 " n_soundex_givn_std = NULLIF(n_soundex_givn_std, '0000' )," . 63 " n_soundex_surn_std = NULLIF(n_soundex_surn_std, '0000' )," . 64 " n_soundex_givn_dm = NULLIF(n_soundex_givn_dm, '000000')," . 65 " n_soundex_surn_dm = NULLIF(n_soundex_surn_dm, '000000')" 66 ); 67 68 Database::exec( 69 "UPDATE `##places` SET" . 70 " p_std_soundex = REPLACE(p_std_soundex, '0000:', '')," . 71 " p_dm_soundex = REPLACE(p_dm_soundex, '000000:', '')" 72 ); 73 Database::exec( 74 "UPDATE `##places` SET" . 75 " p_std_soundex = REPLACE(p_std_soundex, ':0000', '')," . 76 " p_dm_soundex = REPLACE(p_dm_soundex, ':000000', '')" 77 ); 78 Database::exec( 79 "UPDATE `##places` SET" . 80 " p_std_soundex = NULLIF(p_std_soundex, '0000' )," . 81 " p_dm_soundex = NULLIF(p_dm_soundex, '000000')" 82 ); 83 } 84} 85