<?php

use App\Enums\OrderType;
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
    {
        // DB::statement("ALTER TABLE orders MODIFY COLUMN orderType ENUM('".implode("','",OrderType::getValues())."')");
        DB::statement("ALTER TABLE `orders` CHANGE `orderType` `orderType` ENUM('".implode("','", OrderType::getValues())."') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'daily'");
        DB::statement("ALTER TABLE `order_archives` CHANGE `orderType` `orderType` ENUM('".implode("','", OrderType::getValues())."') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'daily'");

        /*
                Schema::table('orders', function (Blueprint $table) {
                    //dd(implode("','",OrderType::getValues()));
                    $table->enum('orderType', OrderType::getValues())->default(
                        OrderType::daily)->change();
                });*/
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('orders', function (Blueprint $table) {
            //
        });
    }
};
