<?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
    {
        if (Schema::hasTable('promotion_reminders_log')) {
            return;
        }

        Schema::create('promotion_reminders_log', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('promotion_id')->index();
            $table->unsignedInteger('student_id')->nullable()->index();
            $table->unsignedInteger('parent_id')->nullable();
            $table->string('reminder_type', 40)->default('manual')
                ->comment('first|halfway|final|expiration|manual');
            $table->string('channel', 20)->default('in_app');
            $table->string('subject', 191)->nullable();
            $table->text('message')->nullable();
            $table->dateTime('sent_at')->nullable();
            $table->unsignedInteger('sent_by')->nullable();
            $table->timestamps();
        });
    }

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