<?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('bookings', function (Blueprint $table) {
            // Hapus kolom enum payment_status yang lama
            $table->dropColumn('payment_status');
        });

        Schema::table('bookings', function (Blueprint $table) {
            // Buat kolom baru payment_status dengan tipe varchar dan default 'unpaid'
            $table->string('payment_status', 20)->default('unpaid')->after('total_price');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('bookings', function (Blueprint $table) {
            // Hapus kolom string payment_status
            $table->dropColumn('payment_status');
        });

        Schema::table('bookings', function (Blueprint $table) {
            // Kembalikan ke enum payment_status yang lama
            $table->enum('payment_status', ['unpaid', 'paid'])->default('unpaid')->after('total_price');
        });
    }
};
