<?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
    {
        // Uploaded student papers (Tazkira / Passport / پارچه / certificates …),
        // stored as base64 data URIs so they travel with the SQLite database.
        Schema::create('student_documents', function (Blueprint $table) {
            $table->id();
            $table->foreignId('student_id')->constrained()->cascadeOnDelete();
            $table->string('doc_type')->default('other'); // tazkira|passport|parcha|certificate|photo|other
            $table->string('title');
            $table->string('mime')->nullable();
            $table->unsignedInteger('size')->default(0);
            $table->longText('content')->nullable(); // data: URI
            $table->timestamps();
            $table->index(['student_id', 'doc_type']);
        });
    }

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