<?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
    {
        Schema::create('earn_legal_acceptances', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('earn_member_id')->constrained()->restrictOnDelete();
            $table->string('document_type', 30);
            $table->string('document_version', 50);
            $table->timestamp('accepted_at');
            $table->ipAddress('ip_address')->nullable();
            $table->string('user_agent', 1000)->nullable();
            $table->timestamps();
            $table->unique(['earn_member_id', 'document_type', 'document_version'], 'earn_legal_acceptance_unique');
        });
    }

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