xref: /webtrees/app/Schema/Migration6.php (revision e7f56f2af615447ab1a7646851f88b465ace9e04)
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 */
16*e7f56f2aSGreg Roachdeclare(strict_types=1);
17*e7f56f2aSGreg Roach
1876692c8bSGreg Roachnamespace Fisharebest\Webtrees\Schema;
1976692c8bSGreg Roach
203bfb94b0SGreg Roachuse Fisharebest\Webtrees\Database;
21bd52fa32SGreg Roachuse Fisharebest\Webtrees\DebugBar;
223bfb94b0SGreg Roachuse PDOException;
233bfb94b0SGreg Roach
243bfb94b0SGreg Roach/**
2576692c8bSGreg Roach * Upgrade the database schema from version 6 to version 7.
263bfb94b0SGreg Roach */
27c1010edaSGreg Roachclass Migration6 implements MigrationInterface
28c1010edaSGreg Roach{
2976692c8bSGreg Roach    /**
3076692c8bSGreg Roach     * Upgrade to to the next version
3119d91378SGreg Roach     *
3219d91378SGreg Roach     * @return void
3376692c8bSGreg Roach     */
34c1010edaSGreg Roach    public function upgrade()
35c1010edaSGreg Roach    {
363bfb94b0SGreg Roach        // Remove tables/columns relating to remote linking
373bfb94b0SGreg Roach        Database::exec(
388f5f5da8SGreg Roach            "DROP TABLE IF EXISTS `##remotelinks`"
393bfb94b0SGreg Roach        );
403bfb94b0SGreg Roach
413bfb94b0SGreg Roach        try {
423bfb94b0SGreg Roach            Database::exec(
433bfb94b0SGreg Roach                "ALTER TABLE `##sources` DROP INDEX ix2"
443bfb94b0SGreg Roach            );
453bfb94b0SGreg Roach        } catch (PDOException $ex) {
46bd52fa32SGreg Roach            DebugBar::addThrowable($ex);
47bd52fa32SGreg Roach
483bfb94b0SGreg Roach            // already been done?
493bfb94b0SGreg Roach        }
503bfb94b0SGreg Roach
513bfb94b0SGreg Roach        try {
523bfb94b0SGreg Roach            Database::exec(
533bfb94b0SGreg Roach                "ALTER TABLE `##sources` DROP COLUMN s_dbid"
543bfb94b0SGreg Roach            );
553bfb94b0SGreg Roach        } catch (PDOException $ex) {
56bd52fa32SGreg Roach            DebugBar::addThrowable($ex);
57bd52fa32SGreg Roach
583bfb94b0SGreg Roach            // already been done?
593bfb94b0SGreg Roach        }
603bfb94b0SGreg Roach    }
613bfb94b0SGreg Roach}
62