xref: /webtrees/app/Schema/Migration18.php (revision 76692c8b291f16d9251d67f27078779f6737fe7e)
13bfb94b0SGreg Roach<?php
23bfb94b0SGreg Roach/**
33bfb94b0SGreg Roach * webtrees: online genealogy
43bfb94b0SGreg Roach * Copyright (C) 2015 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*76692c8bSGreg Roachnamespace Fisharebest\Webtrees\Schema;
17*76692c8bSGreg Roach
183bfb94b0SGreg Roachuse Fisharebest\Webtrees\Database;
193bfb94b0SGreg Roachuse PDOException;
203bfb94b0SGreg Roach
213bfb94b0SGreg Roach/**
22*76692c8bSGreg Roach * Upgrade the database schema from version 18 to version 19.
233bfb94b0SGreg Roach */
243bfb94b0SGreg Roachclass Migration18 implements MigrationInterface {
25*76692c8bSGreg Roach	/**
26*76692c8bSGreg Roach	 * Upgrade to to the next version
27*76692c8bSGreg Roach	 */
283bfb94b0SGreg Roach	public function upgrade() {
293bfb94b0SGreg Roach		// Update some indexes, based on analysis of slow-query-logs
303bfb94b0SGreg Roach		try {
313bfb94b0SGreg Roach			Database::exec(
323bfb94b0SGreg Roach				"ALTER TABLE `##places`" .
333bfb94b0SGreg Roach				" DROP       KEY ix1," .
343bfb94b0SGreg Roach				" DROP       KEY ix2," .
353bfb94b0SGreg Roach				" DROP       KEY ix3," .
363bfb94b0SGreg Roach				" DROP       KEY ix4," .
373bfb94b0SGreg Roach				" DROP       p_level," . // Not needed - implicit from p_parent
383bfb94b0SGreg Roach				" ADD        KEY ix1 (p_file, p_place)," . // autocomplete.php, find.php
393bfb94b0SGreg Roach				" ADD UNIQUE KEY ux1 (p_parent_id, p_file, p_place)" // placelist.php
403bfb94b0SGreg Roach			);
413bfb94b0SGreg Roach		} catch (PDOException $ex) {
423bfb94b0SGreg Roach			// Already done?
433bfb94b0SGreg Roach		}
443bfb94b0SGreg Roach	}
453bfb94b0SGreg Roach}
46