<?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('spek_bagunan_analisa', function (Blueprint $table) {
            $table->id();
            $table->string('name');

            // Foreign key to analisa_tanah_bangunan
            $table->unsignedBigInteger('analisa_tanah_bangunan_id');
            $table->foreign('analisa_tanah_bangunan_id')->references('id')->on('analisa_tanah_bangunan');

            $table->char('authorized_status', 1);
            $table->timestamp('authorized_at')->nullable();
            $table->unsignedBigInteger('authorized_by')->nullable();

            $table->timestamps();
            $table->unsignedBigInteger('created_by');
            $table->unsignedBigInteger('updated_by')->nullable();

            $table->timestamp('deleted_at')->nullable();
            $table->unsignedBigInteger('deleted_by')->nullable();
        });
    }

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