<?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('rnd_result_process_details', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('rnd_result_process_id');
            $table->unsignedBigInteger('rnd_pengeluaran_bahan_detail_id');
            $table->unsignedBigInteger('item_id');
            $table->decimal('qty', 25, 3);
            $table->unsignedBigInteger('unit');
            $table->string('created_by');
            $table->timestamp('created_at');
            $table->string('updated_by');
            $table->timestamp('updated_at');

            $table->foreign('rnd_result_process_id')->references('id')->on('rnd_result_processes')->onDelete('restrict');
            $table->foreign('rnd_pengeluaran_bahan_detail_id')->references('id')->on('rnd_pengeluaran_bahan_detail')->onDelete('restrict');
            $table->foreign('item_id')->references('id')->on('items')->onDelete('restrict');
        });
    }

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