BastionSSO/database/migrations/2026_06_18_064549_create_tickets_table.php

39 lines
1.2 KiB
PHP

<?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('tickets', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('ticket_category_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('assigned_user_id')->nullable()->constrained('users')->nullOnDelete();
$table->string('title');
$table->text('content');
$table->string('status', 32)->default('open')->index();
$table->timestamp('last_replied_at')->nullable()->index();
$table->timestamp('closed_at')->nullable();
$table->timestamps();
$table->index(['user_id', 'status']);
$table->index(['ticket_category_id', 'status']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tickets');
}
};