first commit

This commit is contained in:
Doar Mihai
2026-06-27 14:38:18 +03:00
commit 96d317480b
165 changed files with 20061 additions and 0 deletions
@@ -0,0 +1,49 @@
<?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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -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('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->bigInteger('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->bigInteger('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,59 @@
<?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('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedSmallInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->string('connection');
$table->string('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
$table->index(['connection', 'queue', 'failed_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,38 @@
<?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('locations', function (Blueprint $table) {
$table->id();
$table->string('name', 100);
$table->string('slug', 100)->unique();
$table->text('description')->nullable();
$table->unsignedInteger('travel_cost')->default(0);
$table->unsignedInteger('requires_level')->nullable()->default(null);
$table->unsignedBigInteger('faction_control')->nullable();
$table->timestamps();
// Indexes
$table->index('slug');
$table->index('requires_level');
$table->index('faction_control');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('locations');
}
};
@@ -0,0 +1,57 @@
<?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');
}
};
@@ -0,0 +1,48 @@
<?php
use App\Enums\ItemType;
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('items', function (Blueprint $table) {
$table->id();
$table->string('name', 100);
$table->string('slug', 100)->unique();
$table->text('description')->nullable();
$table->enum('type', ItemType::values());
$table->unsignedInteger('value')->default(0);
$table->unsignedInteger('buy_price')->nullable()->default(null);
$table->unsignedInteger('sell_price')->nullable()->default(null);
$table->unsignedInteger('requires_level')->nullable()->default(null);
$table->integer('attack_bonus')->default(0);
$table->integer('defense_bonus')->default(0);
$table->integer('health_bonus')->default(0);
$table->integer('energy_bonus')->default(0);
$table->boolean('is_tradeable')->default(true);
$table->boolean('is_usable')->default(false);
$table->timestamps();
// Indexes
$table->index('slug');
$table->index('type');
$table->index('requires_level');
$table->index('buy_price');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('items');
}
};
@@ -0,0 +1,46 @@
<?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');
}
};
@@ -0,0 +1,38 @@
<?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('crime_attempts', function (Blueprint $table) {
$table->id();
$table->foreignId('character_id')->constrained()->cascadeOnDelete();
$table->foreignId('crime_id')->constrained();
$table->boolean('success')->default(false);
$table->unsignedBigInteger('reward')->default(0);
$table->unsignedBigInteger('experience_gained')->default(0);
$table->timestamp('attempted_at')->useCurrent();
// Indexes
$table->index('character_id');
$table->index('crime_id');
$table->index('success');
$table->index('attempted_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('crime_attempts');
}
};
@@ -0,0 +1,37 @@
<?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('activity_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('character_id')->constrained()->cascadeOnDelete();
$table->string('action', 100);
$table->text('description')->nullable();
$table->string('ip_address', 45)->nullable();
$table->string('user_agent')->nullable();
$table->timestamps();
// Indexes
$table->index('character_id');
$table->index('action');
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('activity_logs');
}
};
@@ -0,0 +1,37 @@
<?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('notifications', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('type', 100);
$table->json('data')->nullable();
$table->timestamp('read_at')->nullable();
$table->timestamps();
// Indexes
$table->index('user_id');
$table->index('type');
$table->index('read_at');
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notifications');
}
};
@@ -0,0 +1,39 @@
<?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('inventories', function (Blueprint $table) {
$table->id();
$table->foreignId('character_id')->constrained()->cascadeOnDelete();
$table->foreignId('item_id')->constrained();
$table->unsignedInteger('quantity')->default(1);
$table->boolean('equipped')->default(false);
$table->timestamps();
// Indexes
$table->index('character_id');
$table->index('item_id');
$table->index('equipped');
// Unique constraint: one inventory entry per character per item
$table->unique(['character_id', 'item_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('inventories');
}
};