<?php

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

return new class extends Migration
{
    public function up()
    {
        Schema::create('pengeluaran_bahan', function (Blueprint $table) {
            $table->id();
            $table->string('pengeluaran_bahan_id')->unique();
            $table->date('document_date');
            $table->unsignedBigInteger('warehouse_id');

            $table->unsignedBigInteger('plan_id');
            $table->unsignedBigInteger('process_id');
            $table->json('employee_result')->nullable();
            $table->string('created_by');
            $table->timestamp('created_at');
            $table->string('updated_by');
            $table->timestamp('updated_at');

            $table->foreign('process_id')->references('id')->on('process')->onDelete('restrict');
            $table->foreign('warehouse_id')->references('id')->on('warehouse')->onDelete('restrict');
        });
    }

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