a bit of progress

This commit is contained in:
2026-07-04 17:09:55 +03:00
parent f6e7d37428
commit 082b532d52
29 changed files with 2734 additions and 47 deletions
@@ -0,0 +1,46 @@
<?php
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('attacks', function (Blueprint $table) {
$table->id();
$table->foreignId('attacker_id')->constrained('characters')->onDelete('cascade');
$table->foreignId('defender_id')->constrained('characters')->onDelete('cascade');
$table->integer('attacker_damage')->default(0);
$table->integer('defender_damage')->default(0);
$table->integer('attacker_health_after')->default(0);
$table->integer('defender_health_after')->default(0);
$table->string('result')->default('draw'); // win, lose, draw, escape
$table->integer('money_stolen')->default(0);
$table->integer('experience_gained')->default(0);
$table->boolean('was_critical')->default(false);
$table->boolean('was_mugging')->default(false);
$table->foreignId('attacker_weapon_id')->nullable()->constrained('items')->onDelete('set null');
$table->foreignId('defender_armor_id')->nullable()->constrained('items')->onDelete('set null');
$table->timestamp('attacked_at')->useCurrent();
$table->timestamps();
$table->index('attacker_id');
$table->index('defender_id');
$table->index('attacked_at');
$table->index('result');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('attacks');
}
};
@@ -0,0 +1,92 @@
<?php
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
{
// Add indexes to characters table
Schema::table('characters', function (Blueprint $table) {
$table->index('user_id');
$table->index('location_id');
$table->index('faction_id');
$table->index('status');
$table->index('level');
$table->index('health');
$table->index('energy');
$table->index('last_action_at');
$table->index('in_hospital_until');
$table->index('in_jail_until');
});
// Add indexes to crimes table
Schema::table('crimes', function (Blueprint $table) {
$table->index('name');
$table->index('slug');
$table->index('difficulty');
$table->index('location_id');
$table->index('requires_level');
});
// Add indexes to crime_attempts table
Schema::table('crime_attempts', function (Blueprint $table) {
$table->index('character_id');
$table->index('crime_id');
$table->index('success');
$table->index('attempted_at');
});
// Add indexes to inventories table
Schema::table('inventories', function (Blueprint $table) {
$table->index('character_id');
$table->index('item_id');
$table->index('equipped');
});
// Add indexes to items table
Schema::table('items', function (Blueprint $table) {
$table->index('name');
$table->index('slug');
$table->index('type');
$table->index('requires_level');
$table->index('is_tradeable');
$table->index('is_usable');
});
// Add indexes to locations table
Schema::table('locations', function (Blueprint $table) {
$table->index('name');
$table->index('slug');
});
// Add indexes to notifications table
Schema::table('notifications', function (Blueprint $table) {
$table->index('user_id');
$table->index('type');
$table->index('read_at');
$table->index('created_at');
});
// Add indexes to activity_logs table
Schema::table('activity_logs', function (Blueprint $table) {
$table->index('character_id');
$table->index('action');
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// We don't remove indexes in down() as it's generally safe to keep them
// and removing them might cause issues with existing data
}
};
@@ -0,0 +1,35 @@
<?php
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('cooldowns', function (Blueprint $table) {
$table->id();
$table->foreignId('character_id')->constrained('characters')->onDelete('cascade');
$table->string('action_type'); // attack, crime, travel, train, etc.
$table->timestamp('last_action_at')->useCurrent();
$table->timestamps();
$table->unique(['character_id', 'action_type']);
$table->index('character_id');
$table->index('action_type');
$table->index('last_action_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cooldowns');
}
};