<?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
    {
        // Check if column doesn't exist before adding
        if (!Schema::hasColumn('m_raw_materials', 'tipe_barang')) {
            Schema::table('m_raw_materials', function (Blueprint $table) {
                $table->enum('tipe_barang', ['Basah', 'Kering'])
                    ->default('Kering')
                    ->after('tipe_dokumen')
                    ->comment('Tipe barang: Basah atau Kering');
            });
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        if (Schema::hasColumn('m_raw_materials', 'tipe_barang')) {
            Schema::table('m_raw_materials', function (Blueprint $table) {
                $table->dropColumn('tipe_barang');
            });
        }
    }
};
