1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2018 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; 19use PDOException; 20 21/** 22 * Upgrade the database schema from version 38 to version 39. 23 */ 24class Migration38 implements MigrationInterface { 25 /** 26 * Upgrade to to the next version 27 */ 28 public function upgrade() { 29 // The geographic data is now handled by the core code. 30 // The following migrations were once part of the old googlemap module. 31 try { 32 // Create the tables, as per PhpGedView 4.2.1 33 Database::exec( 34 "CREATE TABLE IF NOT EXISTS `##placelocation` (" . 35 " pl_id INTEGER NOT NULL," . 36 " pl_parent_id INTEGER NULL," . 37 " pl_level INTEGER NULL," . 38 " pl_place VARCHAR(255) NULL," . 39 " pl_long VARCHAR(30) NULL," . 40 " pl_lati VARCHAR(30) NULL," . 41 " pl_zoom INTEGER NULL," . 42 " pl_icon VARCHAR(255) NULL," . 43 " PRIMARY KEY (pl_id)," . 44 " KEY ix1 (pl_level)," . 45 " KEY ix2 (pl_long)," . 46 " KEY ix3 (pl_lati)," . 47 " KEY ix4 (pl_place)," . 48 " KEY ix5 (pl_parent_id)" . 49 ") COLLATE utf8_unicode_ci ENGINE=InnoDB" 50 ); 51 } catch (PDOException $ex) { 52 // Already done? 53 } 54 55 try { 56 Database::exec( 57 "ALTER TABLE `##placelocation` ADD (" . 58 " pl_media VARCHAR(60) NULL," . 59 " sv_long FLOAT NOT NULL DEFAULT 0," . 60 " sv_lati FLOAT NOT NULL DEFAULT 0," . 61 " sv_bearing FLOAT NOT NULL DEFAULT 0," . 62 " sv_elevation FLOAT NOT NULL DEFAULT 0," . 63 " sv_zoom FLOAT NOT NULL DEFAULT 1" . 64 ")" 65 ); 66 } catch (PDOException $ex) { 67 // Already done? 68 } 69 70 try { 71 Database::exec("ALTER TABLE `##placelocation`" . 72 " DROP COLUMN pl_media," . 73 " DROP COLUMN sv_long," . 74 " DROP COLUMN sv_lati," . 75 " DROP COLUMN sv_bearing," . 76 " DROP COLUMN sv_elevation," . 77 " DROP COLUMN sv_zoom," . 78 " DROP INDEX ix1," . 79 " DROP INDEX ix2," . 80 " DROP INDEX ix3," . 81 " DROP INDEX ix4," . 82 " DROP INDEX ix5," . 83 " ADD UNIQUE INDEX ix1 (pl_parent_id, pl_place)," . 84 " ADD INDEX ix2 (pl_parent_id)," . 85 " ADD INDEX ix3 (pl_place)" 86 ); 87 } catch (PDOException $ex) { 88 // Already done? 89 } 90 91 // Convert flag icons from .gif to .png 92 Database::exec("UPDATE `##placelocation` SET pl_icon=REPLACE(pl_icon, '.gif', '.png')"); 93 94 // Delete old settings 95 Database::exec("DELETE FROM `##module_setting` WHERE module_name='googlemap'"); 96 Database::exec("DELETE FROM `##module_privacy` WHERE module_name='googlemap'"); 97 Database::exec("DELETE FROM `##module` WHERE module_name='googlemap'"); 98 } 99} 100