1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2015 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 */ 16namespace Fisharebest\Webtrees\Schema; 17 18use Fisharebest\Webtrees\Database; 19 20/** 21 * Upgrade the database schema from version 26 to version 27. 22 */ 23class Migration26 implements MigrationInterface { 24 /** 25 * Upgrade to to the next version 26 */ 27 public function upgrade() { 28 // Earlier versions of webtrees put quote marks round soundex codes. 29 // These are harmless, but clean them up for consistency. 30 Database::exec( 31 "UPDATE `##name` SET" . 32 " n_soundex_givn_std = TRIM('''' FROM n_soundex_givn_std)," . 33 " n_soundex_surn_std = TRIM('''' FROM n_soundex_surn_std)," . 34 " n_soundex_givn_dm = TRIM('''' FROM n_soundex_givn_dm )," . 35 " n_soundex_surn_dm = TRIM('''' FROM n_soundex_surn_dm )" 36 ); 37 38 // Earlier versions of webtrees added zero codes for names without phonetic content. 39 // These are harmless, but clean them up for consistency. 40 Database::exec( 41 "UPDATE `##name` SET" . 42 " n_soundex_givn_std = REPLACE(n_soundex_givn_std, '0000:', '')," . 43 " n_soundex_surn_std = REPLACE(n_soundex_surn_std, '0000:', '')," . 44 " n_soundex_givn_dm = REPLACE(n_soundex_givn_dm, '000000:', '')," . 45 " n_soundex_surn_dm = REPLACE(n_soundex_surn_dm, '000000:', '')" 46 ); 47 Database::exec( 48 "UPDATE `##name` SET" . 49 " n_soundex_givn_std = REPLACE(n_soundex_givn_std, ':0000', '')," . 50 " n_soundex_surn_std = REPLACE(n_soundex_surn_std, ':0000', '')," . 51 " n_soundex_givn_dm = REPLACE(n_soundex_givn_dm, ':000000', '')," . 52 " n_soundex_surn_dm = REPLACE(n_soundex_surn_dm, ':000000', '')" 53 ); 54 Database::exec( 55 "UPDATE `##name` SET" . 56 " n_soundex_givn_std = NULLIF(n_soundex_givn_std, '0000' )," . 57 " n_soundex_surn_std = NULLIF(n_soundex_surn_std, '0000' )," . 58 " n_soundex_givn_dm = NULLIF(n_soundex_givn_dm, '000000')," . 59 " n_soundex_surn_dm = NULLIF(n_soundex_surn_dm, '000000')" 60 ); 61 62 Database::exec( 63 "UPDATE `##places` SET" . 64 " p_std_soundex = REPLACE(p_std_soundex, '0000:', '')," . 65 " p_dm_soundex = REPLACE(p_dm_soundex, '000000:', '')" 66 ); 67 Database::exec( 68 "UPDATE `##places` SET" . 69 " p_std_soundex = REPLACE(p_std_soundex, ':0000', '')," . 70 " p_dm_soundex = REPLACE(p_dm_soundex, ':000000', '')" 71 ); 72 Database::exec( 73 "UPDATE `##places` SET" . 74 " p_std_soundex = NULLIF(p_std_soundex, '0000' )," . 75 " p_dm_soundex = NULLIF(p_dm_soundex, '000000')" 76 ); 77 } 78} 79