<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('employees', function (Blueprint $table) {
            if (!Schema::hasColumn('employees', 'is_auto_attendance')) {
                $table->boolean('is_auto_attendance')->default(false)->after('status');
            }

            if (!Schema::hasColumn('employees', 'auto_attendance_note')) {
                $table->string('auto_attendance_note')->nullable()->after('is_auto_attendance');
            }
        });
    }

    public function down(): void
    {
        Schema::table('employees', function (Blueprint $table) {
            if (Schema::hasColumn('employees', 'auto_attendance_note')) {
                $table->dropColumn('auto_attendance_note');
            }

            if (Schema::hasColumn('employees', 'is_auto_attendance')) {
                $table->dropColumn('is_auto_attendance');
            }
        });
    }
};