<?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('sites', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tenant_id')->comment('테넌트 ID');
            $table->string('name', 100)->comment('현장명');
            $table->string('address', 255)->nullable()->comment('현장 주소');
            $table->decimal('latitude', 10, 8)->nullable()->comment('위도');
            $table->decimal('longitude', 11, 8)->nullable()->comment('경도');
            $table->boolean('is_active')->default(true)->comment('활성화 여부');
            $table->foreignId('created_by')->nullable()->comment('생성자');
            $table->foreignId('updated_by')->nullable()->comment('수정자');
            $table->foreignId('deleted_by')->nullable()->comment('삭제자');
            $table->softDeletes();
            $table->timestamps();

            $table->index('tenant_id');
            $table->index('is_active');
        });
    }

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