first&last

This commit is contained in:
sbb45
2026-03-20 15:47:17 +05:00
commit d6441abdd2
230 changed files with 20367 additions and 0 deletions
@@ -0,0 +1,40 @@
<?php
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::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('role')->default(UserRole::CLIENT->value)->index();
$table->string('phone', 32)->nullable();
$table->string('avatar')->nullable();
$table->unsignedBigInteger('department_id')->nullable()->index();
$table->boolean('is_active')->default(true)->index();
$table->timestamp('last_login_at')->nullable();
$table->rememberToken();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
}
};
@@ -0,0 +1,28 @@
<?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('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};
@@ -0,0 +1,32 @@
<?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('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,33 @@
<?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('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('departments', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->text('description')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('departments');
}
};
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->foreign('department_id')
->references('id')
->on('departments')
->nullOnDelete()
->cascadeOnUpdate();
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['department_id']);
});
}
};
@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('equipment_categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('equipment_categories');
}
};
@@ -0,0 +1,41 @@
<?php
use App\Enums\EquipmentCondition;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('equipment', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('serial_number')->unique();
$table->string('inventory_number')->unique();
$table->foreignId('category_id')
->constrained('equipment_categories')
->cascadeOnUpdate()
->restrictOnDelete();
$table->foreignId('client_id')
->nullable()
->constrained('users')
->nullOnDelete()
->cascadeOnUpdate();
$table->date('purchase_date')->nullable();
$table->date('warranty_until')->nullable();
$table->string('condition')->default(EquipmentCondition::GOOD->value)->index();
$table->text('notes')->nullable();
$table->timestamps();
$table->index(['client_id', 'category_id']);
$table->index('warranty_until');
});
}
public function down(): void
{
Schema::dropIfExists('equipment');
}
};
@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('request_types', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->text('description')->nullable();
$table->unsignedInteger('sla_hours')->default(24);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('request_types');
}
};
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('priorities', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('color_hex', 7);
$table->unsignedTinyInteger('level')->unique();
$table->timestamps();
$table->index('level');
});
}
public function down(): void
{
Schema::dropIfExists('priorities');
}
};
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('statuses', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('color_hex', 7);
$table->string('slug')->unique();
$table->boolean('is_final')->default(false);
$table->unsignedSmallInteger('sort_order')->default(0);
$table->timestamps();
$table->index(['sort_order', 'is_final']);
});
}
public function down(): void
{
Schema::dropIfExists('statuses');
}
};
@@ -0,0 +1,69 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('requests', function (Blueprint $table) {
$table->id();
$table->string('ticket_number')->unique();
$table->string('title');
$table->text('description');
$table->foreignId('type_id')
->constrained('request_types')
->cascadeOnUpdate()
->restrictOnDelete();
$table->foreignId('priority_id')
->constrained('priorities')
->cascadeOnUpdate()
->restrictOnDelete();
$table->foreignId('status_id')
->constrained('statuses')
->cascadeOnUpdate()
->restrictOnDelete();
$table->foreignId('client_id')
->constrained('users')
->cascadeOnUpdate()
->restrictOnDelete();
$table->foreignId('assigned_to')
->nullable()
->constrained('users')
->nullOnDelete()
->cascadeOnUpdate();
$table->foreignId('equipment_id')
->nullable()
->constrained('equipment')
->nullOnDelete()
->cascadeOnUpdate();
$table->string('location')->nullable();
$table->dateTime('planned_at')->nullable();
$table->dateTime('deadline_at')->nullable();
$table->dateTime('started_at')->nullable();
$table->dateTime('completed_at')->nullable();
$table->text('resolution_notes')->nullable();
$table->unsignedTinyInteger('client_rating')->nullable();
$table->text('client_comment')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('type_id');
$table->index('priority_id');
$table->index('status_id');
$table->index('client_id');
$table->index('assigned_to');
$table->index('equipment_id');
$table->index('deadline_at');
$table->index('created_at');
$table->index(['status_id', 'deadline_at']);
});
}
public function down(): void
{
Schema::dropIfExists('requests');
}
};
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('request_comments', function (Blueprint $table) {
$table->id();
$table->foreignId('request_id')
->constrained('requests')
->cascadeOnDelete()
->cascadeOnUpdate();
$table->foreignId('user_id')
->constrained('users')
->cascadeOnDelete()
->cascadeOnUpdate();
$table->text('body');
$table->boolean('is_internal')->default(false)->index();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('request_comments');
}
};
@@ -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
{
public function up(): void
{
Schema::create('request_attachments', function (Blueprint $table) {
$table->id();
$table->foreignId('request_id')
->constrained('requests')
->cascadeOnDelete()
->cascadeOnUpdate();
$table->foreignId('user_id')
->nullable()
->constrained('users')
->nullOnDelete()
->cascadeOnUpdate();
$table->string('filename');
$table->string('path');
$table->unsignedBigInteger('size');
$table->timestamps();
$table->index('created_at');
});
}
public function down(): void
{
Schema::dropIfExists('request_attachments');
}
};
@@ -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
{
public function up(): void
{
Schema::create('activity_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')
->nullable()
->constrained('users')
->nullOnDelete()
->cascadeOnUpdate();
$table->string('model_type');
$table->unsignedBigInteger('model_id');
$table->string('action');
$table->text('description')->nullable();
$table->string('ip_address', 45)->nullable();
$table->timestamp('created_at')->useCurrent();
$table->index(['model_type', 'model_id']);
$table->index('action');
$table->index('created_at');
});
}
public function down(): void
{
Schema::dropIfExists('activity_logs');
}
};
@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('notifications');
}
};
@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->longText('value')->nullable();
$table->string('type')->default('string');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('settings');
}
};
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}
public function down(): void
{
Schema::dropIfExists('jobs');
}
};
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
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();
});
}
public function down(): void
{
Schema::dropIfExists('job_batches');
}
};
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};