1c7aa856bSGreg Roach<?php 2c7aa856bSGreg Roach 3c7aa856bSGreg Roach/** 4c7aa856bSGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 6c7aa856bSGreg Roach * This program is free software: you can redistribute it and/or modify 7c7aa856bSGreg Roach * it under the terms of the GNU General Public License as published by 8c7aa856bSGreg Roach * the Free Software Foundation, either version 3 of the License, or 9c7aa856bSGreg Roach * (at your option) any later version. 10c7aa856bSGreg Roach * This program is distributed in the hope that it will be useful, 11c7aa856bSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12c7aa856bSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13c7aa856bSGreg Roach * GNU General Public License for more details. 14c7aa856bSGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16c7aa856bSGreg Roach */ 17c7aa856bSGreg Roach 18c7aa856bSGreg Roachdeclare(strict_types=1); 19c7aa856bSGreg Roach 20c7aa856bSGreg Roachnamespace Fisharebest\Webtrees\Schema; 21c7aa856bSGreg Roach 22c7aa856bSGreg Roachuse Illuminate\Database\Capsule\Manager as DB; 23c7aa856bSGreg Roach 24c7aa856bSGreg Roach/** 25c7aa856bSGreg Roach * Upgrade the database schema from version 43 to version 44. 26c7aa856bSGreg Roach */ 27c7aa856bSGreg Roachclass Migration43 implements MigrationInterface 28c7aa856bSGreg Roach{ 29c7aa856bSGreg Roach /** 30d9efec4aSGreg Roach * Upgrade to the next version 31c7aa856bSGreg Roach * 32c7aa856bSGreg Roach * @return void 33c7aa856bSGreg Roach */ 34c7aa856bSGreg Roach public function upgrade(): void 35c7aa856bSGreg Roach { 36c7aa856bSGreg Roach // Language was previously a tree-setting. 37c7aa856bSGreg Roach $language = DB::table('gedcom_setting') 38c7aa856bSGreg Roach ->where('setting_name', '=', 'LANGUAGE') 39c7aa856bSGreg Roach ->where('gedcom_id', '>', 0) 40c7aa856bSGreg Roach ->value('setting_value'); 41c7aa856bSGreg Roach 42c7aa856bSGreg Roach // Now it is a site-setting. 43c7aa856bSGreg Roach DB::table('site_setting')->updateOrInsert([ 44c7aa856bSGreg Roach 'setting_name' => 'LANGUAGE', 45c7aa856bSGreg Roach ], [ 46c7aa856bSGreg Roach 'setting_value' => $language ?? 'en-US', 47c7aa856bSGreg Roach ]); 48c7aa856bSGreg Roach 49c7aa856bSGreg Roach // Cleanup 50c7aa856bSGreg Roach DB::table('gedcom_setting') 51c7aa856bSGreg Roach ->where('setting_name', '=', 'LANGUAGE') 52c7aa856bSGreg Roach ->delete(); 53c7aa856bSGreg Roach } 54c7aa856bSGreg Roach} 55