<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('document_files', function (Blueprint $table) {
            $table->id();
            $table->string('uuid');
            $table->string('type');
            $table->string('file_path');
            $table->foreignId('uploaded_by_id')->constrained('users');
            $table->timestamps();
        });
        Schema::create('documents', function (Blueprint $table) {
            $table->id();
            $table->string('type');
            $table->string('doc_number')->nullable();
            $table->string('doc_type')->nullable();
            $table->string('doc_certifier')->nullable();
            $table->foreignId('user')->constrained('users');
            $table->foreignId('added_by')->constrained('users');
            $table->foreignId('document_file_id')->nullable()->constrained('document_files');
            $table->dateTime('date')->nullable();
            $table->dateTime('expiration_date')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('documents');
        Schema::dropIfExists('document_files');
    }
};
