<?php

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
    {
        Schema::create('bio_time_attendance_logs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('employee_id')->nullable()->constrained()->nullOnDelete();
            $table->string('biotime_log_id')->nullable()->unique();
            $table->string('emp_code')->nullable()->index();
            $table->string('device_user_id')->nullable()->index();
            $table->dateTime('punch_time')->index();
            $table->string('punch_state')->nullable();
            $table->string('verify_type')->nullable();
            $table->string('terminal_sn')->nullable();
            $table->json('raw')->nullable();
            $table->timestamp('synced_at')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('bio_time_attendance_logs');
    }
};
