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