<?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::create('notification_logs', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('booking_id')->nullable()->constrained('bookings')->nullOnDelete();
            $table->string('recipient_type');
            $table->string('recipient_name')->nullable();
            $table->string('recipient_email')->nullable();
            $table->string('channel')->default('email');
            $table->string('event');
            $table->string('subject')->nullable();
            $table->longText('body')->nullable();
            $table->string('status')->default('logged');
            $table->json('meta_json')->nullable();
            $table->timestamp('sent_at')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('notification_logs');
    }
};
