xref: /webtrees/app/Schema/Migration38.php (revision 8fcd0d32e56ee262912bbdb593202cfd1cbc1615)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 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 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Schema;
19
20use Illuminate\Database\Capsule\Manager as DB;
21use Illuminate\Database\Schema\Blueprint;
22
23/**
24 * Upgrade the database schema from version 38 to version 39.
25 */
26class Migration38 implements MigrationInterface
27{
28    /**
29     * Upgrade to to the next version
30     *
31     * @return void
32     */
33    public function upgrade(): void
34    {
35        // This table was previously created by the googlemap module in 1.7.9.
36        // These migrations are now part of the core code.
37
38        if (!DB::schema()->hasTable('placelocation')) {
39            DB::schema()->create('placelocation', function (Blueprint $table): void {
40                $table->integer('pl_id')->primary();
41                $table->integer('pl_parent_id');
42                $table->integer('pl_level');
43                $table->string('pl_place', 255)->index();
44                $table->string('pl_long', 30);
45                $table->string('pl_lati', 30);
46                $table->integer('pl_zoom');
47                $table->string('pl_icon', 255);
48
49                $table->unique(['pl_parent_id', 'pl_place']);
50            });
51        }
52
53        if (DB::schema()->hasColumn('placelocation', 'pl_media')) {
54            DB::schema()->table('placelocation', function (Blueprint $table): void {
55                $table->dropColumn('pl_media');
56                $table->dropColumn('sv_long');
57                $table->dropColumn('sv_lati');
58                $table->dropColumn('sv_bearing');
59                $table->dropColumn('sv_elevation');
60                $table->dropColumn('sv_zoom');
61            });
62        }
63    }
64}
65