<?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('admin_meeting_logs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tenant_id')->constrained()->comment('테넌트 ID');
            $table->foreignId('user_id')->constrained()->comment('작성자 ID');
            $table->string('title', 200)->default('무제 회의록')->comment('제목');
            $table->string('audio_file_path', 500)->nullable()->comment('GCS 오디오 파일 경로');
            $table->string('audio_gcs_uri', 500)->nullable()->comment('GCS URI (gs://...)');
            $table->longText('transcript_text')->nullable()->comment('STT 변환 텍스트');
            $table->longText('summary_text')->nullable()->comment('AI 요약 텍스트');
            $table->string('status', 20)->default('PENDING')->comment('상태: PENDING, PROCESSING, COMPLETED, FAILED');
            $table->integer('duration_seconds')->nullable()->comment('녹음 시간(초)');
            $table->timestamp('file_expiry_date')->nullable()->comment('파일 삭제 예정일');
            $table->timestamps();
            $table->softDeletes();

            $table->index('tenant_id');
            $table->index('user_id');
            $table->index('status');
            $table->index('file_expiry_date');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('admin_meeting_logs');
    }
};
