<?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::create('field_jobs', function (Blueprint $table) {
            $table->id();
            $table->foreignId('field_job_setting_id')->constrained('field_job_settings')->cascadeOnDelete();
            $table->foreignId('asigned_user_id')->nullable()->constrained('users')->nullOnDelete();
            $table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete();
            $table->date('assigned_at')->nullable();
            $table->date('completed_at')->nullable();
            $table->date('cancelled_at')->nullable();
            $table->boolean('priority')->default(false);
            $table->string('notes', 255)->nullable();
            $table->jsonb('address_snapshot ')->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('field_jobs');
    }
};
