<?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
    {
        if (Schema::hasTable('attendance_policies')) {
            return;
        }

        Schema::create('attendance_policies', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_id')->unique();
            $table->string('mode', 32)->default('normal');
            $table->boolean('geo_fence_enabled')->default(false);
            $table->boolean('remote_attendance_enabled')->default(false);
            $table->boolean('remote_approval_required')->default(false);
            $table->unsignedInteger('default_radius_meters')->default(250);
            $table->unsignedInteger('gps_accuracy_requirement')->nullable();
            $table->boolean('require_location_for_office')->default(true);
            $table->boolean('allow_web_checkin')->default(true);
            $table->boolean('allow_mobile_checkin')->default(true);
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('attendance_policies');
    }
};
