feat: default enums

This commit is contained in:
Leon 2026-01-05 11:56:33 +01:00
parent 9ddfb7622a
commit a75fd5c93c
1 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,38 @@
<?php
use App\Enums\HuntDifficulty;
use App\Enums\UserRole;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('hunts', function (Blueprint $table) {
$table->string('difficulty')->default(HuntDifficulty::EASY->value)->change();
});
Schema::table('users', function (Blueprint $table) {
$table->string('role')->default(UserRole::USER->value)->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('hunts', function (Blueprint $table) {
$table->string('difficulty')->nullable(false)->change();
});
Schema::table('users', function (Blueprint $table) {
$table->string('role')->default('user')->change(); // Originally it was default 'user' string, restoring to that or removing default if it had none before (but it did have one).
});
}
};