<?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('order_tracking', function (Blueprint $table) {
            $table->id();
            $table->foreignId('order_id')->constrained('orders')->onDelete('cascade');
            $table->string('status', 50);
            $table->string('status_label', 100);
            $table->text('description');
            $table->string('location')->nullable()->comment('Localização do pacote');
            $table->timestamp('date');
            $table->boolean('completed')->default(false)->comment('Se esta etapa foi concluída');
            $table->timestamps();

            // Indexes
            $table->index('order_id');
            $table->index('status');
            $table->index('date');
            $table->index('completed');
        });
    }

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