<?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('purchase_requisition_makloons', function (Blueprint $table) {
            $table->id();
            $table->string('purchase_requisition_makloon_number')->unique();
            $table->date('document_date');
            $table->date('overdue_date')->nullable();
            $table->unsignedBigInteger('department_id');
            $table->string('status')->nullable();
            $table->text('notes')->nullable();
            $table->decimal('print_number', 20, 0)->nullable();
            $table->timestamps();
            $table->unsignedBigInteger('created_by')->nullable();
            $table->unsignedBigInteger('updated_by')->nullable();

            // Foreign key constraint
            $table->foreign('department_id')->references('id')->on('department')->onDelete('restrict');

            // Foreign key constraints for created_by and updated_by (assuming a users table)
            $table->foreign('created_by')->references('id')->on('users')->onDelete('restrict');
            $table->foreign('updated_by')->references('id')->on('users')->onDelete('restrict');
        });
    }

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