<?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('user_preferences', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->json('preferred_categories')->nullable(); // Array of category IDs
            $table->json('preferred_price_ranges')->nullable(); // Array of price range objects
            $table->json('preferred_listing_types')->nullable(); // sale, trade, both
            $table->json('preferred_conditions')->nullable(); // excellent, good, fair, poor
            $table->json('preferred_locations')->nullable(); // Cities/states they're interested in
            $table->boolean('onboarding_completed')->default(false);
            $table->timestamps();
            
            $table->unique('user_id');
        });
    }

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