xref: /webtrees/app/Schema/Migration38.php (revision 26420f84cb96928cdc566963a4499db677a38ff9)
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', static 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);
44                $table->string('pl_long', 30)->nullable();
45                $table->string('pl_lati', 30)->nullable();
46                $table->integer('pl_zoom')->nullable();
47                $table->string('pl_icon', 255)->nullable();
48
49                $table->index('pl_place');
50                $table->unique(['pl_parent_id', 'pl_place']);
51            });
52        }
53
54        if (DB::schema()->hasColumn('placelocation', 'pl_media')) {
55            DB::schema()->table('placelocation', static function (Blueprint $table): void {
56                $table->dropColumn('pl_media');
57                $table->dropColumn('sv_long');
58                $table->dropColumn('sv_lati');
59                $table->dropColumn('sv_bearing');
60                $table->dropColumn('sv_elevation');
61                $table->dropColumn('sv_zoom');
62            });
63        }
64    }
65}
66