<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        if (DB::getDriverName() === 'mysql' || DB::getDriverName() === 'mariadb') {
            // For MySQL, we modify the column to add 'draft' to the enum and set it as the new default
            DB::statement("ALTER TABLE payrolls MODIFY COLUMN status ENUM('draft', 'pending', 'approved', 'rejected') DEFAULT 'draft'");
            DB::statement("ALTER TABLE bonus_generations MODIFY COLUMN status ENUM('draft', 'pending', 'approved', 'rejected') DEFAULT 'draft'");
        }
    }


    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        if (config('database.default') === 'mysql' || config('database.default') === 'mariadb') {
            // Revert back
            DB::statement("ALTER TABLE payrolls MODIFY COLUMN status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending'");
            DB::statement("ALTER TABLE bonus_generations MODIFY COLUMN status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending'");
        }
    }

};
