diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-06-02 23:51:34 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-06-03 00:43:38 +0100 |
| commit | 3bfb94b0b402ff08e5888afb946384316f6d3e60 (patch) | |
| tree | 82b9b0ce9b47e146778c29b01eed2fcf5ae1a41a /app/Module/GoogleMaps | |
| parent | 38d2124dba7359bb63bf14ade54d80ebccbb2376 (diff) | |
| download | webtrees-3bfb94b0b402ff08e5888afb946384316f6d3e60.tar.gz webtrees-3bfb94b0b402ff08e5888afb946384316f6d3e60.tar.bz2 webtrees-3bfb94b0b402ff08e5888afb946384316f6d3e60.zip | |
Refactor database migrations to use autoloading and remove duplicates
Diffstat (limited to 'app/Module/GoogleMaps')
| -rw-r--r-- | app/Module/GoogleMaps/Schema/Migration0.php | 48 | ||||
| -rw-r--r-- | app/Module/GoogleMaps/Schema/Migration1.php | 44 | ||||
| -rw-r--r-- | app/Module/GoogleMaps/Schema/Migration2.php | 31 | ||||
| -rw-r--r-- | app/Module/GoogleMaps/Schema/Migration3.php | 36 | ||||
| -rw-r--r-- | app/Module/GoogleMaps/Schema/Migration4.php | 33 |
5 files changed, 192 insertions, 0 deletions
diff --git a/app/Module/GoogleMaps/Schema/Migration0.php b/app/Module/GoogleMaps/Schema/Migration0.php new file mode 100644 index 0000000000..ccaf8355d2 --- /dev/null +++ b/app/Module/GoogleMaps/Schema/Migration0.php @@ -0,0 +1,48 @@ +<?php +namespace Fisharebest\Webtrees\Module\GoogleMaps\Schema; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 webtrees development team + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\Database; +use Fisharebest\Webtrees\Schema\MigrationInterface; + +/** + * Class Migration0 - upgrade the database schema from version 0 (empty database) to version 1. + */ +class Migration0 implements MigrationInterface { + /** {@inheritDoc} */ + public function upgrade() { + // Create the tables, as per PhpGedView 4.2.1 + + Database::exec( + "CREATE TABLE IF NOT EXISTS `##placelocation` (" . + " pl_id INTEGER NOT NULL," . + " pl_parent_id INTEGER NULL," . + " pl_level INTEGER NULL," . + " pl_place VARCHAR(255) NULL," . + " pl_long VARCHAR(30) NULL," . + " pl_lati VARCHAR(30) NULL," . + " pl_zoom INTEGER NULL," . + " pl_icon VARCHAR(255) NULL," . + " PRIMARY KEY (pl_id)," . + " KEY ix1 (pl_level)," . + " KEY ix2 (pl_long)," . + " KEY ix3 (pl_lati)," . + " KEY ix4 (pl_place)," . + " KEY ix5 (pl_parent_id)" . + ") COLLATE utf8_unicode_ci ENGINE=InnoDB" + ); + } +} diff --git a/app/Module/GoogleMaps/Schema/Migration1.php b/app/Module/GoogleMaps/Schema/Migration1.php new file mode 100644 index 0000000000..d5843e5c65 --- /dev/null +++ b/app/Module/GoogleMaps/Schema/Migration1.php @@ -0,0 +1,44 @@ +<?php +namespace Fisharebest\Webtrees\Module\GoogleMaps\Schema; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 webtrees development team + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\Database; +use Fisharebest\Webtrees\Schema\MigrationInterface; +use PDOException; + +/** + * Class Migration1 - upgrade the database schema from version 1 to version 2. + */ +class Migration1 implements MigrationInterface { + /** {@inheritDoc} */ + public function upgrade() { + // Update the tables to support streetview + try { + Database::exec( + "ALTER TABLE `##placelocation` ADD (" . + " pl_media VARCHAR(60) NULL," . + " sv_long FLOAT NOT NULL DEFAULT 0," . + " sv_lati FLOAT NOT NULL DEFAULT 0," . + " sv_bearing FLOAT NOT NULL DEFAULT 0," . + " sv_elevation FLOAT NOT NULL DEFAULT 0," . + " sv_zoom FLOAT NOT NULL DEFAULT 1" . + ")" + ); + } catch (PDOException $ex) { + // Already done this? + } + } +} diff --git a/app/Module/GoogleMaps/Schema/Migration2.php b/app/Module/GoogleMaps/Schema/Migration2.php new file mode 100644 index 0000000000..ac17dce363 --- /dev/null +++ b/app/Module/GoogleMaps/Schema/Migration2.php @@ -0,0 +1,31 @@ +<?php +namespace Fisharebest\Webtrees\Module\GoogleMaps\Schema; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 webtrees development team + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\Database; +use Fisharebest\Webtrees\Schema\MigrationInterface; + +/** + * Class Migration2 - upgrade the database schema from version 2 to version 3. + */ +class Migration2 implements MigrationInterface { + /** {@inheritDoc} */ + public function upgrade() { + // Convert flag icons from .gif to .png + + Database::exec("UPDATE `##placelocation` SET pl_icon=REPLACE(pl_icon, '.gif', '.png')"); + } +} diff --git a/app/Module/GoogleMaps/Schema/Migration3.php b/app/Module/GoogleMaps/Schema/Migration3.php new file mode 100644 index 0000000000..a10ef44920 --- /dev/null +++ b/app/Module/GoogleMaps/Schema/Migration3.php @@ -0,0 +1,36 @@ +<?php +namespace Fisharebest\Webtrees\Module\GoogleMaps\Schema; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 webtrees development team + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\Database; +use Fisharebest\Webtrees\Schema\MigrationInterface; + +/** + * Class Migration3 - upgrade the database schema from version 3 to version 4. + */ +class Migration3 implements MigrationInterface { + /** {@inheritDoc} */ + public function upgrade() { + // Combine the two ways of enabling the GM module + Database::exec( + "UPDATE `##module` m, `##module_setting` ms SET m.status=CASE WHEN (m.status=1 AND ms.setting_value=1) THEN 'enabled' ELSE 'disabled' END WHERE m.module_name=ms.module_name AND m.module_name='googlemap' AND ms.setting_name='GM_ENABLED'" + ); + + Database::exec( + "DELETE FROM `##module_setting` WHERE module_name='googlemap' AND setting_name='GM_ENABLED'" + ); + } +} diff --git a/app/Module/GoogleMaps/Schema/Migration4.php b/app/Module/GoogleMaps/Schema/Migration4.php new file mode 100644 index 0000000000..a07a4c448d --- /dev/null +++ b/app/Module/GoogleMaps/Schema/Migration4.php @@ -0,0 +1,33 @@ +<?php +namespace Fisharebest\Webtrees\Module\GoogleMaps\Schema; + +/** + * webtrees: online genealogy + * Copyright (C) 2015 webtrees development team + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +use Fisharebest\Webtrees\Database; +use Fisharebest\Webtrees\Schema\MigrationInterface; + +/** + * Class Migration4 - upgrade the database schema from version 4 to version 5. + */ +class Migration4 implements MigrationInterface { + /** {@inheritDoc} */ + public function upgrade() { + // Delete some old/unused configuration settings + Database::exec( + "DELETE FROM `##module_setting` WHERE module_name='googlemap' AND setting_name IN ( + 'GM_API_KEY', 'GM_DEFAULT_TOP_VALUE', 'GM_DISP_COUNT', 'GM_MAX_NOF_LEVELS', 'GM_PH_CONTROLS', 'GM_PH_WHEEL', 'GM_PRE_POST_MODE_1', 'GM_PRE_POST_MODE_2', 'GM_PRE_POST_MODE_3', 'GM_PRE_POST_MODE_4', 'GM_PRE_POST_MODE_5', 'GM_PRE_POST_MODE_6', 'GM_PRE_POST_MODE_7', 'GM_PRE_POST_MODE_8', 'GM_PRE_POST_MODE_9')" + ); + } +} |
