1a4439c01SGreg Roach<?php 2a4439c01SGreg Roach/** 3a4439c01SGreg Roach * webtrees: online genealogy 48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 5a4439c01SGreg Roach * This program is free software: you can redistribute it and/or modify 6a4439c01SGreg Roach * it under the terms of the GNU General Public License as published by 7a4439c01SGreg Roach * the Free Software Foundation, either version 3 of the License, or 8a4439c01SGreg Roach * (at your option) any later version. 9a4439c01SGreg Roach * This program is distributed in the hope that it will be useful, 10a4439c01SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11a4439c01SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12a4439c01SGreg Roach * GNU General Public License for more details. 13a4439c01SGreg Roach * You should have received a copy of the GNU General Public License 14a4439c01SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15a4439c01SGreg Roach */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 18a4439c01SGreg Roachnamespace Fisharebest\Webtrees\Schema; 19a4439c01SGreg Roach 20c9beb871SGreg Roachuse Illuminate\Database\Capsule\Manager as DB; 21c9beb871SGreg Roachuse Illuminate\Database\Schema\Blueprint; 22a4439c01SGreg Roach 23a4439c01SGreg Roach/** 24a4439c01SGreg Roach * Upgrade the database schema from version 39 to version 40. 25a4439c01SGreg Roach */ 26c1010edaSGreg Roachclass Migration39 implements MigrationInterface 27c1010edaSGreg Roach{ 28a4439c01SGreg Roach /** 29a4439c01SGreg Roach * Upgrade to to the next version 3019d91378SGreg Roach * 3119d91378SGreg Roach * @return void 32a4439c01SGreg Roach */ 33362be83aSGreg Roach public function upgrade(): void 34c1010edaSGreg Roach { 35c9beb871SGreg Roach // This table was previously created by the favorites module in 1.7.9. 36c9beb871SGreg Roach // These migrations are now part of the core code. 37a4439c01SGreg Roach 38c9beb871SGreg Roach if (!DB::schema()->hasTable('favorite')) { 390b5fd0a6SGreg Roach DB::schema()->create('favorite', static function (Blueprint $table): void { 40c9beb871SGreg Roach $table->integer('favorite_id', true); 41*d788e003SGreg Roach $table->integer('user_id')->nullable(); 42c9beb871SGreg Roach $table->integer('gedcom_id'); 43c9beb871SGreg Roach $table->string('xref', 20)->nullable(); 44c9beb871SGreg Roach $table->enum('favorite_type', ['INDI', 'FAM', 'SOUR', 'REPO', 'OBJE', 'NOTE', 'URL']); 45c9beb871SGreg Roach $table->string('url', 255)->nullable(); 46c9beb871SGreg Roach $table->string('title', 255)->nullable(); 47c9beb871SGreg Roach $table->string('note', 1000)->nullable(); 48a4439c01SGreg Roach 49e5a6b4d4SGreg Roach $table->index('user_id'); 50c9beb871SGreg Roach $table->index(['gedcom_id', 'user_id']); 51a4439c01SGreg Roach 52c9beb871SGreg Roach $table->foreign('user_id')->references('user_id')->on('user')->onDelete('cascade'); 53c9beb871SGreg Roach $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade'); 54c9beb871SGreg Roach }); 55a4439c01SGreg Roach } 56a4439c01SGreg Roach } 57a4439c01SGreg Roach} 58