58 lines
2.1 KiB
PHP
58 lines
2.1 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
use App\Enums\CharacterStatus;
|
||
|
|
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('characters', function (Blueprint $table) {
|
||
|
|
$table->id();
|
||
|
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||
|
|
$table->string('name', 50);
|
||
|
|
$table->enum('gender', ['male', 'female', 'other']);
|
||
|
|
$table->unsignedInteger('level')->default(1);
|
||
|
|
$table->unsignedBigInteger('experience')->default(0);
|
||
|
|
$table->unsignedBigInteger('money')->default(5000);
|
||
|
|
$table->unsignedBigInteger('bank')->default(0);
|
||
|
|
$table->unsignedInteger('energy')->default(100);
|
||
|
|
$table->unsignedInteger('max_energy')->default(100);
|
||
|
|
$table->unsignedInteger('health')->default(100);
|
||
|
|
$table->unsignedInteger('max_health')->default(100);
|
||
|
|
$table->unsignedInteger('strength')->default(5);
|
||
|
|
$table->unsignedInteger('defense')->default(5);
|
||
|
|
$table->unsignedInteger('speed')->default(5);
|
||
|
|
$table->unsignedInteger('dexterity')->default(5);
|
||
|
|
$table->foreignId('location_id')->constrained();
|
||
|
|
$table->unsignedBigInteger('faction_id')->nullable();
|
||
|
|
$table->timestamp('in_hospital_until')->nullable();
|
||
|
|
$table->timestamp('in_jail_until')->nullable();
|
||
|
|
$table->timestamp('last_action_at')->nullable();
|
||
|
|
$table->enum('status', CharacterStatus::values())->default(CharacterStatus::ACTIVE->value);
|
||
|
|
$table->timestamps();
|
||
|
|
|
||
|
|
// Indexes
|
||
|
|
$table->index('user_id');
|
||
|
|
$table->index('name');
|
||
|
|
$table->index('level');
|
||
|
|
$table->index('location_id');
|
||
|
|
$table->index('faction_id');
|
||
|
|
$table->index('status');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Reverse the migrations.
|
||
|
|
*/
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
Schema::dropIfExists('characters');
|
||
|
|
}
|
||
|
|
};
|