<?php

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::table('site_briefings', function (Blueprint $table) {
            // attendee 컬럼 삭제 후 attendees JSON 컬럼 추가
            $table->dropColumn('attendee');
        });

        Schema::table('site_briefings', function (Blueprint $table) {
            // JSON 컬럼으로 참석자 목록 저장
            // 구조: [{"user_id": 1, "name": "홍길동", "type": "internal"}, {"name": "외부인", "company": "업체명", "phone": "010-1234-5678", "type": "external"}]
            $table->json('attendees')->nullable()->after('bid_date')->comment('참석자 목록 (JSON)');
        });
    }

    public function down(): void
    {
        Schema::table('site_briefings', function (Blueprint $table) {
            $table->dropColumn('attendees');
        });

        Schema::table('site_briefings', function (Blueprint $table) {
            $table->string('attendee', 100)->nullable()->after('bid_date')->comment('참석자 (단일)');
        });
    }
};
