mirror of https://github.com/Lukibeg/OmniBoard.git
54 lines
1.6 KiB
PHP
54 lines
1.6 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('agents', function (Blueprint $table) {
|
|
$table->id();
|
|
|
|
// Vínculo com o Tenant (Multi-tenancy)
|
|
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
|
|
|
// Nome de exibição (Ex: "Lucas Gomes")
|
|
$table->string('name');
|
|
|
|
// MUDANÇA 1: Identificador técnico no Asterisk
|
|
// Armazena "PJSIP/200" ou "SIP/200". Indexado para busca rápida na API.
|
|
$table->string('interface')->index();
|
|
|
|
// Status atual do agente
|
|
$table->enum('status', ['available', 'paused', 'talking', 'offline'])
|
|
->default('offline');
|
|
|
|
// MUDANÇA 2: Motivo da pausa (vindo do AMI)
|
|
// Ex: "Almoco", "Banheiro", "Reuniao"
|
|
$table->string('pause_reason')->nullable();
|
|
|
|
// Momento da última alteração de status (útil para calcular tempo de pausa)
|
|
$table->timestamp('last_status_change')->useCurrent();
|
|
|
|
// MUDANÇA 3: Métricas acumuladas (KPIs rápidos)
|
|
$table->integer('total_calls_answered')->default(0);
|
|
$table->integer('total_ring_no_answer')->default(0);
|
|
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('agents');
|
|
}
|
|
};
|