1c9beb871SGreg Roach<?php 23976b470SGreg Roach 3c9beb871SGreg Roach/** 4c9beb871SGreg Roach * webtrees: online genealogy 589f7189bSGreg Roach * Copyright (C) 2021 webtrees development team 6c9beb871SGreg Roach * This program is free software: you can redistribute it and/or modify 7c9beb871SGreg Roach * it under the terms of the GNU General Public License as published by 8c9beb871SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9c9beb871SGreg Roach * (at your option) any later version. 10c9beb871SGreg Roach * This program is distributed in the hope that it will be useful, 11c9beb871SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12c9beb871SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13c9beb871SGreg Roach * GNU General Public License for more details. 14c9beb871SGreg 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/>. 16c9beb871SGreg Roach */ 17fcfa147eSGreg Roach 18c9beb871SGreg Roachdeclare(strict_types=1); 19c9beb871SGreg Roach 20c9beb871SGreg Roachnamespace Fisharebest\Webtrees\Schema; 21c9beb871SGreg Roach 22c9beb871SGreg Roachuse Illuminate\Database\Capsule\Manager as DB; 23c9beb871SGreg Roachuse Illuminate\Database\Schema\Blueprint; 24c9beb871SGreg Roach 25c9beb871SGreg Roach/** 26c9beb871SGreg Roach * Upgrade the database schema from version 40 to version 41. 27c9beb871SGreg Roach */ 28c9beb871SGreg Roachclass Migration40 implements MigrationInterface 29c9beb871SGreg Roach{ 30c9beb871SGreg Roach /** 31*d9efec4aSGreg Roach * Upgrade to the next version 32c9beb871SGreg Roach * 33c9beb871SGreg Roach * @return void 34c9beb871SGreg Roach */ 35c9beb871SGreg Roach public function upgrade(): void 36c9beb871SGreg Roach { 37c9beb871SGreg Roach // This table was previously created by the favorites module in 1.7.9. 38c9beb871SGreg Roach // These migrations are now part of the core code. 39c9beb871SGreg Roach 40c9beb871SGreg Roach if (!DB::schema()->hasTable('news')) { 410b5fd0a6SGreg Roach DB::schema()->create('news', static function (Blueprint $table): void { 42c9beb871SGreg Roach $table->integer('news_id', true); 43e162ec40SGreg Roach $table->integer('user_id')->nullable(); 44e162ec40SGreg Roach $table->integer('gedcom_id')->nullable(); 45c9beb871SGreg Roach $table->string('subject', 255); 46c9beb871SGreg Roach $table->text('body'); 47c9beb871SGreg Roach $table->timestamp('updated')->useCurrent(); 48c9beb871SGreg Roach 49c9beb871SGreg Roach $table->index(['user_id', 'updated']); 50c9beb871SGreg Roach $table->index(['gedcom_id', 'updated']); 51c9beb871SGreg 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 }); 55c9beb871SGreg Roach } 56c9beb871SGreg Roach } 57c9beb871SGreg Roach} 58