?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('tickets', function (Blueprint $table) { $table->id(); $table->string('ticket_number')->unique(); $table->foreignId('customer_id')->constrained()->cascadeOnDelete()->index(); $table->foreignId('company_id')->nullable()->constrained()->nullOnDelete()->index(); $table->string('subject'); $table->string('priority')->default('normal')->index(); $table->string('status')->default('open')->index(); $table->foreignId('assigned_engineer_id')->nullable()->constrained('users')->nullOnDelete()->index(); $table->foreignId('server_id')->nullable()->constrained()->nullOnDelete(); $table->foreignId('service_id')->nullable()->constrained()->nullOnDelete(); $table->timestamp('sla_first_response_due_at')->nullable()->index(); $table->timestamp('sla_resolution_due_at')->nullable()->index(); $table->boolean('sla_breached')->default(false)->index(); $table->timestamp('first_response_at')->nullable(); $table->timestamp('resolved_at')->nullable(); $table->timestamp('closed_at')->nullable(); $table->string('source')->default('portal'); $table->timestamps(); $table->softDeletes(); }); } public function down(): void { Schema::dropIfExists('tickets'); } };