<?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::table('services', function (Blueprint $table) {
            $table->text('keterangan')->nullable()->after('file_hasil_uji');

            // Drop dan recreate kolom status untuk menambahkan opsi 'Ditolak'
            $table->dropColumn('status');
        });

        // Membuat ulang kolom status dengan enum yang diperbarui
        Schema::table('services', function (Blueprint $table) {
            $table->enum('status', ['Menunggu', 'Diterima', 'Diproses', 'Selesai', 'Ditolak'])
                ->default('Menunggu')
                ->nullable()
                ->after('jarak_pengambilan_sampel');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('services', function (Blueprint $table) {
            $table->dropColumn('keterangan');

            // Drop dan recreate kolom status tanpa opsi 'Ditolak'
            $table->dropColumn('status');
        });

        // Membuat ulang kolom status dengan enum original
        Schema::table('services', function (Blueprint $table) {
            $table->enum('status', ['Menunggu', 'Diterima', 'Diproses', 'Selesai'])
                ->default('Menunggu')
                ->nullable()
                ->after('jarak_pengambilan_sampel');
        });
    }
};
