<?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('consents', function (Blueprint $table) {
            $table->id();
            $table->foreignId('case_id')->constrained('cases');
            $table->string('subject_name', 180);
            $table->string('subject_document', 60)->nullable();
            $table->enum('consent_type', ['written','digital','recorded']);
            $table->text('scope_text');
            $table->foreignId('collected_by')->nullable()->constrained('users');
            $table->dateTime('granted_at');
            $table->dateTime('revoked_at')->nullable();
            $table->string('ip_address', 45)->nullable();
            $table->string('proof_file_path', 255)->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }
    public function down(): void { Schema::dropIfExists('consents'); }
};
