<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Enums\LinkStatus;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('links', function (Blueprint $table) {
            $table->id();
            $table->foreignId('campaign_id')->constrained()->cascadeOnDelete();
            $table->foreignId('donateur_id')->constrained()->cascadeOnDelete();
            $table->string('token')->unique();
            $table->string('feda_request_id')->nullable();
            $table->string('hosted_url')->nullable();
            $table->enum('status', array_column(LinkStatus::cases(), 'value'))
                  ->default(LinkStatus::Pending->value);
            $table->timestamps();
        });
    }


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