1<?php 2namespace Fisharebest\Webtrees\Schema; 3 4/** 5 * webtrees: online genealogy 6 * Copyright (C) 2015 webtrees development team 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18use Fisharebest\Webtrees\Database; 19 20/** 21 * Class Migration3 - upgrade the database schema from version 3 to version 4. 22 */ 23class Migration3 implements MigrationInterface { 24 /** {@inheritDoc} */ 25 public function upgrade() { 26 // Update the max_relation_path_length from a separate 27 // user setting and gedcom setting to a combined user-gedcom 28 // setting. 29 // Also clean out some old/unused values. 30 31 Database::exec( 32 "INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value)" . 33 " SELECT u.user_id, g.gedcom_id, 'RELATIONSHIP_PATH_LENGTH', LEAST(us1.setting_value, gs1.setting_value)" . 34 " FROM `##user` u" . 35 " CROSS JOIN `##gedcom` g" . 36 " LEFT JOIN `##user_setting` us1 ON (u.user_id =us1.user_id AND us1.setting_name='max_relation_path')" . 37 " LEFT JOIN `##user_setting` us2 ON (u.user_id =us2.user_id AND us2.setting_name='relationship_privacy')" . 38 " LEFT JOIN `##gedcom_setting` gs1 ON (g.gedcom_id=gs1.gedcom_id AND gs1.setting_name='MAX_RELATION_PATH_LENGTH')" . 39 " LEFT JOIN `##gedcom_setting` gs2 ON (g.gedcom_id=gs2.gedcom_id AND gs2.setting_name='USE_RELATIONSHIP_PRIVACY')" . 40 " WHERE us2.setting_value AND gs2.setting_value" 41 ); 42 43 // Delete old/unused settings 44 Database::exec( 45 "DELETE FROM `##site_setting` WHERE setting_name IN ('SESSION_SAVE_PATH')" 46 ); 47 Database::exec( 48 "DELETE FROM `##gedcom_setting` WHERE setting_name IN ('HOME_SITE_TEXT', 'HOME_SITE_URL', 'CHECK_MARRIAGE_RELATIONS', 'MAX_RELATION_PATH_LENGTH', 'USE_RELATIONSHIP_PRIVACY')" 49 ); 50 Database::exec( 51 "DELETE FROM `##user_setting` WHERE setting_name IN ('loggedin', 'relationship_privacy', 'max_relation_path_length')" 52 ); 53 54 // Fix Mc/Mac problems - See SVN9701 55 Database::exec( 56 "UPDATE `##name` SET n_surn=CONCAT('MC', SUBSTRING(n_surn, 4)) WHERE n_surn LIKE 'MC0%'" 57 ); 58 } 59} 60