major helpdesk updates
This commit is contained in:
+208
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
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('helpdesk_products', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('company_id')->nullable()->constrained('companies')->nullOnDelete();
|
||||
$table->string('name', 160);
|
||||
$table->string('slug', 180);
|
||||
$table->string('type', 60)->default('service');
|
||||
$table->string('version', 80)->nullable();
|
||||
$table->string('release_channel', 80)->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->unique(['company_id', 'slug']);
|
||||
});
|
||||
|
||||
|
||||
Schema::create('helpdesk_sla_policies', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('company_id')->nullable()->constrained('companies')->nullOnDelete();
|
||||
$table->foreignId('priority_id')->nullable()->constrained('helpdesk_priorities')->nullOnDelete();
|
||||
$table->foreignId('category_id')->nullable()->constrained('helpdesk_categories')->nullOnDelete();
|
||||
$table->string('name', 160);
|
||||
$table->string('slug', 180);
|
||||
$table->unsignedInteger('first_response_minutes')->default(240);
|
||||
$table->unsignedInteger('resolution_minutes')->default(2880);
|
||||
$table->boolean('business_hours_only')->default(false);
|
||||
$table->boolean('is_default')->default(false);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->unique(['company_id', 'slug']);
|
||||
$table->index(['priority_id', 'category_id', 'is_active']);
|
||||
});
|
||||
|
||||
Schema::table('helpdesk_tickets', static function (Blueprint $table): void {
|
||||
if (! Schema::hasColumn('helpdesk_tickets', 'sla_policy_id')) {
|
||||
$table->foreignId('sla_policy_id')->nullable()->after('team_id')->constrained('helpdesk_sla_policies')->nullOnDelete();
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_tickets', 'product_id')) {
|
||||
$table->foreignId('product_id')->nullable()->after('project_id')->constrained('helpdesk_products')->nullOnDelete();
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_tickets', 'first_response_at')) {
|
||||
$table->timestamp('first_response_at')->nullable()->after('due_at');
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_tickets', 'sla_first_response_due_at')) {
|
||||
$table->timestamp('sla_first_response_due_at')->nullable()->after('first_response_at');
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_tickets', 'sla_resolution_due_at')) {
|
||||
$table->timestamp('sla_resolution_due_at')->nullable()->after('sla_first_response_due_at');
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_tickets', 'sla_first_response_breached_at')) {
|
||||
$table->timestamp('sla_first_response_breached_at')->nullable()->after('sla_resolution_due_at');
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_tickets', 'sla_resolution_breached_at')) {
|
||||
$table->timestamp('sla_resolution_breached_at')->nullable()->after('sla_first_response_breached_at');
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_tickets', 'public_replies_count')) {
|
||||
$table->unsignedInteger('public_replies_count')->default(0)->after('sla_resolution_breached_at');
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_tickets', 'time_spent_minutes')) {
|
||||
$table->unsignedInteger('time_spent_minutes')->default(0)->after('public_replies_count');
|
||||
}
|
||||
|
||||
$table->index(['sla_policy_id', 'sla_resolution_due_at'], 'helpdesk_tickets_sla_policy_due_idx');
|
||||
$table->index(['product_id', 'completed_at'], 'helpdesk_tickets_product_closed_idx');
|
||||
});
|
||||
|
||||
Schema::table('helpdesk_workflow_logs', static function (Blueprint $table): void {
|
||||
if (! Schema::hasColumn('helpdesk_workflow_logs', 'tracking_token')) {
|
||||
$table->string('tracking_token', 64)->nullable()->unique()->after('status');
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_workflow_logs', 'first_opened_at')) {
|
||||
$table->timestamp('first_opened_at')->nullable()->after('tracking_token');
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_workflow_logs', 'last_opened_at')) {
|
||||
$table->timestamp('last_opened_at')->nullable()->after('first_opened_at');
|
||||
}
|
||||
if (! Schema::hasColumn('helpdesk_workflow_logs', 'opened_count')) {
|
||||
$table->unsignedInteger('opened_count')->default(0)->after('last_opened_at');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_canned_responses', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('company_id')->nullable()->constrained('companies')->nullOnDelete();
|
||||
$table->foreignId('category_id')->nullable()->constrained('helpdesk_categories')->nullOnDelete();
|
||||
$table->foreignId('team_id')->nullable()->constrained('helpdesk_teams')->nullOnDelete();
|
||||
$table->string('name', 160);
|
||||
$table->string('slug', 180);
|
||||
$table->string('visibility', 40)->default('agents');
|
||||
$table->string('subject', 220)->nullable();
|
||||
$table->longText('body');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
$table->unique(['company_id', 'slug']);
|
||||
$table->index(['category_id', 'team_id', 'is_active']);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Schema::create('helpdesk_automation_rules', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('company_id')->nullable()->constrained('companies')->nullOnDelete();
|
||||
$table->string('name', 160);
|
||||
$table->string('slug', 180);
|
||||
$table->string('match_sender', 190)->nullable();
|
||||
$table->string('match_subject', 220)->nullable();
|
||||
$table->string('match_mailbox', 190)->nullable();
|
||||
$table->foreignId('match_category_id')->nullable()->constrained('helpdesk_categories')->nullOnDelete();
|
||||
$table->foreignId('set_priority_id')->nullable()->constrained('helpdesk_priorities')->nullOnDelete();
|
||||
$table->foreignId('set_category_id')->nullable()->constrained('helpdesk_categories')->nullOnDelete();
|
||||
$table->foreignId('set_team_id')->nullable()->constrained('helpdesk_teams')->nullOnDelete();
|
||||
$table->foreignId('set_project_id')->nullable()->constrained('helpdesk_projects')->nullOnDelete();
|
||||
$table->foreignId('set_status_id')->nullable()->constrained('helpdesk_statuses')->nullOnDelete();
|
||||
$table->foreignId('set_agent_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
$table->unique(['company_id', 'slug']);
|
||||
$table->index(['is_active', 'sort_order']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_ticket_sla_events', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('ticket_id')->constrained('helpdesk_tickets')->cascadeOnDelete();
|
||||
$table->foreignId('sla_policy_id')->nullable()->constrained('helpdesk_sla_policies')->nullOnDelete();
|
||||
$table->string('event', 80);
|
||||
$table->timestamp('due_at')->nullable();
|
||||
$table->timestamp('occurred_at')->nullable();
|
||||
$table->boolean('breached')->default(false);
|
||||
$table->json('meta')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['ticket_id', 'event']);
|
||||
$table->index(['breached', 'due_at']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_ticket_ratings', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('ticket_id')->constrained('helpdesk_tickets')->cascadeOnDelete();
|
||||
$table->foreignId('agent_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('team_id')->nullable()->constrained('helpdesk_teams')->nullOnDelete();
|
||||
$table->foreignId('category_id')->nullable()->constrained('helpdesk_categories')->nullOnDelete();
|
||||
$table->unsignedTinyInteger('rating');
|
||||
$table->string('token', 80)->unique();
|
||||
$table->text('comment')->nullable();
|
||||
$table->timestamp('rated_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['agent_id', 'rating']);
|
||||
$table->index(['team_id', 'category_id']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_tags', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('company_id')->nullable()->constrained('companies')->nullOnDelete();
|
||||
$table->string('name', 80);
|
||||
$table->string('slug', 100);
|
||||
$table->string('color', 30)->default('zinc');
|
||||
$table->timestamps();
|
||||
$table->unique(['company_id', 'slug']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_ticket_tag', static function (Blueprint $table): void {
|
||||
$table->foreignId('ticket_id')->constrained('helpdesk_tickets')->cascadeOnDelete();
|
||||
$table->foreignId('tag_id')->constrained('helpdesk_tags')->cascadeOnDelete();
|
||||
$table->primary(['ticket_id', 'tag_id']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_checklist_templates', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('company_id')->nullable()->constrained('companies')->nullOnDelete();
|
||||
$table->foreignId('category_id')->nullable()->constrained('helpdesk_categories')->nullOnDelete();
|
||||
$table->foreignId('project_id')->nullable()->constrained('helpdesk_projects')->nullOnDelete();
|
||||
$table->string('name', 160);
|
||||
$table->string('slug', 180);
|
||||
$table->json('items');
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->unique(['company_id', 'slug']);
|
||||
$table->index(['category_id', 'project_id', 'is_active']);
|
||||
});
|
||||
|
||||
Schema::create('helpdesk_checklist_items', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('ticket_id')->constrained('helpdesk_tickets')->cascadeOnDelete();
|
||||
$table->foreignId('template_id')->nullable()->constrained('helpdesk_checklist_templates')->nullOnDelete();
|
||||
$table->string('title', 220);
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('is_completed')->default(false);
|
||||
$table->foreignId('completed_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
$table->index(['ticket_id', 'is_completed']);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Add auditable Git webhook ingestion support.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::hasTable('helpdesk_git_webhook_logs')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('helpdesk_git_webhook_logs', static function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('repository_id')->constrained('helpdesk_git_repositories')->cascadeOnDelete();
|
||||
$table->string('provider', 40);
|
||||
$table->string('delivery_id', 190)->nullable();
|
||||
$table->string('event', 120)->nullable();
|
||||
$table->string('status', 40)->default('accepted');
|
||||
$table->string('message', 500)->nullable();
|
||||
$table->unsignedInteger('commit_count')->default(0);
|
||||
$table->unsignedInteger('linked_count')->default(0);
|
||||
$table->unsignedInteger('ignored_count')->default(0);
|
||||
$table->json('payload')->nullable();
|
||||
$table->timestamp('received_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['repository_id', 'status', 'received_at']);
|
||||
$table->index(['provider', 'event']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user