1c7aa856bSGreg Roach<?php 2c7aa856bSGreg Roach 3c7aa856bSGreg Roach/** 4c7aa856bSGreg Roach * webtrees: online genealogy 5d11be702SGreg 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 22*6f4ec3caSGreg Roachuse Fisharebest\Webtrees\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 public function upgrade(): void 30c7aa856bSGreg Roach { 31c7aa856bSGreg Roach // Language was previously a tree-setting. 32c7aa856bSGreg Roach $language = DB::table('gedcom_setting') 33c7aa856bSGreg Roach ->where('setting_name', '=', 'LANGUAGE') 34c7aa856bSGreg Roach ->where('gedcom_id', '>', 0) 35c7aa856bSGreg Roach ->value('setting_value'); 36c7aa856bSGreg Roach 37c7aa856bSGreg Roach // Now it is a site-setting. 38c7aa856bSGreg Roach DB::table('site_setting')->updateOrInsert([ 39c7aa856bSGreg Roach 'setting_name' => 'LANGUAGE', 40c7aa856bSGreg Roach ], [ 41c7aa856bSGreg Roach 'setting_value' => $language ?? 'en-US', 42c7aa856bSGreg Roach ]); 43c7aa856bSGreg Roach 44c7aa856bSGreg Roach // Cleanup 45c7aa856bSGreg Roach DB::table('gedcom_setting') 46c7aa856bSGreg Roach ->where('setting_name', '=', 'LANGUAGE') 47c7aa856bSGreg Roach ->delete(); 48c7aa856bSGreg Roach } 49c7aa856bSGreg Roach} 50