<?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_maintenance_units', function (Blueprint $table) {
            $table->id();
            $table->foreignId('project_id')->constrained(
                table: 'projects',
                indexName: 'idx_mnt_project_id'
            );
            $table->string('project_code');
            $table->string('mnt_num')->unique();
            $table->string('mnt_code')->unique();
            $table->integer('step');
            $table->date('mnt_date');
            $table->foreignId('unit_id')->constrained(
                table: 'tbl_unit',
                indexName: 'idx_mnt_unit_id'
            );
            $table->string('unit_code');
            $table->text('description')->nullable();
            $table->timestamps();
        });
    }

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