<?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('tbl_upload_docs', function (Blueprint $table) {
            $table->id();
            $table->string('upl_num')->unique();
            $table->string('project_code');
            $table->foreignId('project_id')->constrained(
                table: 'projects',
                indexName: 'idx_upl_docs_project_id'
            );
            $table->string('unit_code');
            $table->foreignId('unit_id')->constrained(
                table: 'tbl_unit',
                indexName: 'idx_upl_docs_unit_id'
            );
            $table->foreignId('upl_ref_id')->constrained(
                table: 'tbl_maintenance_units',
                indexName: 'idx_tbl_mnt_unit_id'
            );
            $table->string('upl_ref_num');
            $table->string('upl_ref_code');
            $table->datetime('upl_date');
            $table->string('upl_type');
            $table->string('upl_filename');
            $table->double('upl_filesize');
            $table->string('upl_filetype');
            $table->string('upl_filepath');
            $table->timestamps();
        });
    }

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