<?php

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

return new class extends Migration
{
    public function up(): void
    {
        if (DB::getDriverName() === 'mysql') {
            DB::statement("ALTER TABLE sales MODIFY invoice_type ENUM('tax_invoice','simplified_tax_invoice','non_tax_invoice') NOT NULL DEFAULT 'tax_invoice'");
        }
    }

    public function down(): void
    {
        if (DB::getDriverName() === 'mysql') {
            DB::table('sales')->where('invoice_type', 'non_tax_invoice')->update(['invoice_type' => 'tax_invoice']);
            DB::statement("ALTER TABLE sales MODIFY invoice_type ENUM('tax_invoice','simplified_tax_invoice') NOT NULL DEFAULT 'tax_invoice'");
        }
    }
};
