<?php

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

/**
 * PRC-1143 — konsolide şema: `data_requests` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('data_requests', function (Blueprint $t) {
            $t->id();
            $t->unsignedBigInteger('client_id');
            $t->enum('type', ['export','deletion']);
            $t->enum('status', ['pending','processing','completed','rejected'])->default('pending');
            $t->text('reason')->nullable();
            $t->string('file_path', 255)->nullable();
            $t->timestamp('completed_at')->nullable();
            $t->text('admin_notes')->nullable();
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index('client_id', 'data_requests_client_id_foreign');
            $t->foreign('client_id', 'data_requests_client_id_foreign')->references('id')->on('clients')->onDelete('cascade');
        });
    }

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