<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Voice-dictation silence tolerance: max seconds of silence a doctor can pause
 * mid-dictation before the recogniser auto-closes the session and inserts
 * what's been captured. Default 30s (Chrome's hard-coded no-speech timeout
 * is ~5-8s, so we auto-restart underneath this budget).
 */
class AddSilenceLimitToVaiSettings extends Migration
{
    public function up()
    {
        if (!Schema::hasColumn('vai_settings', 't_silence_limit_sec')) {
            Schema::table('vai_settings', function (Blueprint $table) {
                $table->unsignedSmallInteger('t_silence_limit_sec')->default(30)->after('t_language_hint');
            });
        }
    }

    public function down()
    {
        if (Schema::hasColumn('vai_settings', 't_silence_limit_sec')) {
            Schema::table('vai_settings', function (Blueprint $table) {
                $table->dropColumn('t_silence_limit_sec');
            });
        }
    }
}
