<?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 staff papers (Tazkira / degree / contract / certificates …),
        // stored as base64 data URIs so they travel with the SQLite database.
        Schema::create('staff_documents', function (Blueprint $table) {
            $table->id();
            $table->foreignId('staff_id')->constrained()->cascadeOnDelete();
            $table->string('doc_type')->default('other'); // tazkira|degree|contract|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(['staff_id', 'doc_type']);
        });
    }

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