47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
use App\Enums\CrimeDifficulty;
|
||
|
|
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::create('crimes', function (Blueprint $table) {
|
||
|
|
$table->id();
|
||
|
|
$table->string('name', 100);
|
||
|
|
$table->string('slug', 100)->unique();
|
||
|
|
$table->text('description')->nullable();
|
||
|
|
$table->enum('difficulty', CrimeDifficulty::values())->default(CrimeDifficulty::EASY->value);
|
||
|
|
$table->float('success_rate')->default(0.70);
|
||
|
|
$table->unsignedInteger('reward_min')->default(0);
|
||
|
|
$table->unsignedInteger('reward_max')->default(0);
|
||
|
|
$table->unsignedInteger('experience')->default(0);
|
||
|
|
$table->unsignedInteger('energy_cost')->default(10);
|
||
|
|
$table->unsignedInteger('cooldown')->default(120); // seconds
|
||
|
|
$table->unsignedInteger('requires_level')->nullable()->default(null);
|
||
|
|
$table->foreignId('location_id')->nullable()->constrained();
|
||
|
|
$table->timestamps();
|
||
|
|
|
||
|
|
// Indexes
|
||
|
|
$table->index('slug');
|
||
|
|
$table->index('difficulty');
|
||
|
|
$table->index('requires_level');
|
||
|
|
$table->index('location_id');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Reverse the migrations.
|
||
|
|
*/
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
Schema::dropIfExists('crimes');
|
||
|
|
}
|
||
|
|
};
|