<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('domain_renewal_alerts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('client_domain_id')->constrained()->onDelete('cascade');
            $table->integer('days_before_expiry'); // 30, 14, 7, 1
            $table->string('reminder_type', 20)->nullable();
            $table->timestamp('sent_at');
            $table->timestamps();

            $table->unique(['client_domain_id', 'days_before_expiry']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('domain_renewal_alerts');
    }
};
