<?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('orders', function (Blueprint $table) {
            $table->uuid('id')->primary(); // Use UUID primary key
            $table->uuid('track_id')->unique();
            $table->uuid('user_id'); // UUID foreign key to users
            $table->uuid('vendor_id'); // UUID foreign key to vendors

            $table->json('items');

            $table->decimal('total_amount', 15, 2);
            $table->string('status')->default('pending');
            $table->string('payment_status')->default('unpaid');

            $table->text('delivery_address')->nullable();
            $table->text('notes')->nullable();

            $table->timestamps();

            // Foreign keys will be added in a later migration after vendors table is updated
        });
    }

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