<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Database\Migrations\TenantMigration;
return new class extends TenantMigration
{
    public function up()
    {
        Schema::create('sms_scheduled', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('template_id')->nullable();
            $table->text('content');
            $table->timestamp('scheduled_at');
            $table->enum('status', ['scheduled', 'sent', 'failed'])->default('scheduled');
            $table->unsignedBigInteger('created_by');
            $table->timestamps();

            $table->foreign('template_id')->references('id')->on('sms_templates')->onDelete('set null');
            $table->foreign('created_by')->references('id')->on('users');
        });
    }

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