<?php

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_recipients', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('sms_scheduled_id');
            $table->unsignedBigInteger('user_id');
            $table->timestamps();

            $table->foreign('sms_scheduled_id')->references('id')->on('sms_scheduled')->onDelete('cascade');
            $table->foreign('user_id')->references('id')->on('users');
            $table->unique(['sms_scheduled_id', 'user_id']);
        });
    }

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