13bfb94b0SGreg Roach<?php 23bfb94b0SGreg Roach/** 33bfb94b0SGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 webtrees development team 53bfb94b0SGreg Roach * This program is free software: you can redistribute it and/or modify 63bfb94b0SGreg Roach * it under the terms of the GNU General Public License as published by 73bfb94b0SGreg Roach * the Free Software Foundation, either version 3 of the License, or 83bfb94b0SGreg Roach * (at your option) any later version. 93bfb94b0SGreg Roach * This program is distributed in the hope that it will be useful, 103bfb94b0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 113bfb94b0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 123bfb94b0SGreg Roach * GNU General Public License for more details. 133bfb94b0SGreg Roach * You should have received a copy of the GNU General Public License 143bfb94b0SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 153bfb94b0SGreg Roach */ 1676692c8bSGreg Roachnamespace Fisharebest\Webtrees\Schema; 1776692c8bSGreg Roach 183bfb94b0SGreg Roachuse Fisharebest\Webtrees\Database; 193bfb94b0SGreg Roach 203bfb94b0SGreg Roach/** 2176692c8bSGreg Roach * Upgrade the database schema from version 3 to version 4. 223bfb94b0SGreg Roach */ 23c1010edaSGreg Roachclass Migration3 implements MigrationInterface 24c1010edaSGreg Roach{ 2576692c8bSGreg Roach /** 2676692c8bSGreg Roach * Upgrade to to the next version 27*19d91378SGreg Roach * 28*19d91378SGreg Roach * @return void 2976692c8bSGreg Roach */ 30c1010edaSGreg Roach public function upgrade() 31c1010edaSGreg Roach { 323bfb94b0SGreg Roach // Update the max_relation_path_length from a separate 333bfb94b0SGreg Roach // user setting and gedcom setting to a combined user-gedcom 343bfb94b0SGreg Roach // setting. 353bfb94b0SGreg Roach // Also clean out some old/unused values. 363bfb94b0SGreg Roach 373bfb94b0SGreg Roach Database::exec( 383bfb94b0SGreg Roach "INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value)" . 393bfb94b0SGreg Roach " SELECT u.user_id, g.gedcom_id, 'RELATIONSHIP_PATH_LENGTH', LEAST(us1.setting_value, gs1.setting_value)" . 403bfb94b0SGreg Roach " FROM `##user` u" . 413bfb94b0SGreg Roach " CROSS JOIN `##gedcom` g" . 423bfb94b0SGreg Roach " LEFT JOIN `##user_setting` us1 ON (u.user_id =us1.user_id AND us1.setting_name='max_relation_path')" . 433bfb94b0SGreg Roach " LEFT JOIN `##user_setting` us2 ON (u.user_id =us2.user_id AND us2.setting_name='relationship_privacy')" . 443bfb94b0SGreg Roach " LEFT JOIN `##gedcom_setting` gs1 ON (g.gedcom_id=gs1.gedcom_id AND gs1.setting_name='MAX_RELATION_PATH_LENGTH')" . 453bfb94b0SGreg Roach " LEFT JOIN `##gedcom_setting` gs2 ON (g.gedcom_id=gs2.gedcom_id AND gs2.setting_name='USE_RELATIONSHIP_PRIVACY')" . 463bfb94b0SGreg Roach " WHERE us2.setting_value AND gs2.setting_value" 473bfb94b0SGreg Roach ); 483bfb94b0SGreg Roach 493bfb94b0SGreg Roach // Delete old/unused settings 503bfb94b0SGreg Roach Database::exec( 513bfb94b0SGreg Roach "DELETE FROM `##site_setting` WHERE setting_name IN ('SESSION_SAVE_PATH')" 523bfb94b0SGreg Roach ); 533bfb94b0SGreg Roach Database::exec( 543bfb94b0SGreg Roach "DELETE FROM `##gedcom_setting` WHERE setting_name IN ('HOME_SITE_TEXT', 'HOME_SITE_URL', 'CHECK_MARRIAGE_RELATIONS', 'MAX_RELATION_PATH_LENGTH', 'USE_RELATIONSHIP_PRIVACY')" 553bfb94b0SGreg Roach ); 563bfb94b0SGreg Roach Database::exec( 573bfb94b0SGreg Roach "DELETE FROM `##user_setting` WHERE setting_name IN ('loggedin', 'relationship_privacy', 'max_relation_path_length')" 583bfb94b0SGreg Roach ); 593bfb94b0SGreg Roach 603bfb94b0SGreg Roach // Fix Mc/Mac problems - See SVN9701 613bfb94b0SGreg Roach Database::exec( 623bfb94b0SGreg Roach "UPDATE `##name` SET n_surn=CONCAT('MC', SUBSTRING(n_surn, 4)) WHERE n_surn LIKE 'MC0%'" 633bfb94b0SGreg Roach ); 643bfb94b0SGreg Roach } 653bfb94b0SGreg Roach} 66