I am making an extension that can design multiple endings of text stories in the management interface, and I designed a database migration file. I clearly have up and down functions, but the forum reported an error about this.
Database migration files:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
class CreateGameTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('games', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('description');
$table->timestamps();
});
Schema::create('game_states', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('game_id');
$table->text('story');
$table->json('options'); // 选项和跳转逻辑
$table->foreign('game_id')->references('id')->on('games')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('game_states');
Schema::dropIfExists('games');
}
}
logs:
[2025-03-05 12:03:16] flarum.ERROR: Flarum\Database\Exception\MigrationKeyMissing: Migration file C:\laragon\www\extends\TextAdventure\migrations\2023_10_01_create_game_table.php should contain an array with up/down (looking for up) in C:\laragon\www\vendor\flarum\core\src\Database\Exception\MigrationKeyMissing.php:28
The truth is, I'm a complete code noob, thanks for your reply!