<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('projects', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->uuid('slug')->unique();
            $table->foreignId('user_id')->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
            $table->string('title');
            $table->longText('description');
            $table->foreignId('category_id');
            $table->boolean('is_public')->default(true);
            $table->foreignId('level_of_experience_id')->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
            $table->timestamp('start_date')->nullable();
            $table->integer('duration');
            $table->enum('budget_type',['Fixed Price','Rate','Bidding'])->default('Fixed Price');
            $table->enum('status', ['Open','Processing','Completed','Cancelled','Drafted'])->default('Open');
            $table->double('amount');
            $table->enum('rate_type',['daily','monthly','yearly'])->nullable();
            $table->double('bidding_start')->nullable();
            $table->double('bidding_end')->nullable();
            $table->unsignedBigInteger('projectable_id')->nullable();
            $table->string('projectable_type')->nullable();
            $table->softDeletes();
        });
    }

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