<?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('products', function (Blueprint $table) {
            // Update enum options to include 'booked' natively in MySQL/SQLite
            if (\Illuminate\Support\Facades\DB::getDriverName() === 'sqlite') {
                // SQLite doesn't natively support enum alterations, so we skip or recreate.
                // But in tests, we already created the fresh database, so it should be fine.
                // Actually Laravel handles SQLite `->change()` by recreating the table under the hood.
            }
            $table->enum('status', ['available', 'sold', 'booked'])->default('available')->change();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('products', function (Blueprint $table) {
            $table->enum('status', ['available', 'sold'])->default('available')->change();
        });
    }
};
