<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // Langkah 1: Drop kolom enum payment_method
        Schema::table('bookings', function (Blueprint $table) {
            $table->dropColumn('payment_method');
        });

        // Langkah 2: Tambahkan kolom baru dengan tipe varchar
        Schema::table('bookings', function (Blueprint $table) {
            $table->string('payment_method', 50)->nullable()->after('payment_status');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Langkah 1: Drop kolom varchar payment_method
        Schema::table('bookings', function (Blueprint $table) {
            $table->dropColumn('payment_method');
        });

        // Langkah 2: Kembalikan ke kolom enum
        Schema::table('bookings', function (Blueprint $table) {
            $table->enum('payment_method', ['tunai', 'transfer_bank', 'ewallet', 'qris'])->nullable()->after('payment_status');
        });
    }
}; 