36 lines
1.4 KiB
PHP
36 lines
1.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
// A world is a season: crown villages appear, a holder wins, the world ends.
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::table('villages', function (Blueprint $table) {
|
|
$table->boolean('crown')->default(false)->after('player_id');
|
|
});
|
|
Schema::table('worlds', function (Blueprint $table) {
|
|
// ends_at (already there) is when the holder wins if they keep their crowns.
|
|
$table->dateTime('crowns_placed_at', 3)->nullable()->after('started_at');
|
|
$table->foreignId('holder_player_id')->nullable()->after('crowns_placed_at')->constrained('players')->nullOnDelete();
|
|
$table->foreignId('winner_player_id')->nullable()->after('holder_player_id')->constrained('players')->nullOnDelete();
|
|
$table->dateTime('ended_at', 3)->nullable()->after('ends_at');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::table('worlds', function (Blueprint $table) {
|
|
$table->dropConstrainedForeignId('holder_player_id');
|
|
$table->dropConstrainedForeignId('winner_player_id');
|
|
$table->dropColumn(['crowns_placed_at', 'ended_at']);
|
|
});
|
|
Schema::table('villages', function (Blueprint $table) {
|
|
$table->dropColumn('crown');
|
|
});
|
|
}
|
|
};
|