<?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('posts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            $table->foreignId('category_id')->constrained()->restrictOnDelete();
            $table->enum('type', ['offer', 'request']);
            $table->string('title');
            $table->text('description');
            $table->enum('price_type', ['fixed', 'negotiable', 'free_to_offer']);
            $table->unsignedBigInteger('price_min')->nullable();
            $table->unsignedBigInteger('price_max')->nullable();
            $table->string('price_label')->nullable();
            $table->string('location')->nullable();
            $table->boolean('is_remote')->default(false);
            $table->timestamp('deadline')->nullable();
            $table->enum('status', ['open', 'taken', 'done', 'cancelled'])->default('open');
            $table->timestamps();
        });
    }

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