<?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('deals', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('business_id')->nullable();
            $table->unsignedBigInteger('owner_id')->nullable();
            $table->unsignedBigInteger('contact_id')->nullable();
            $table->unsignedBigInteger('account_id')->nullable();
            $table->unsignedBigInteger('lead_id')->nullable();
            $table->unsignedBigInteger('company_id')->nullable();
            $table->string('sic_code')->nullable();
            $table->unsignedBigInteger('time_frame_id')->nullable();
            $table->unsignedBigInteger('priority_id')->nullable();
            $table->string('deal_type')->nullable();
            $table->unsignedBigInteger('currency_id')->nullable();
            $table->decimal('estimate_amount', 15, 2)->nullable();
            $table->date('closing_date')->nullable();
            $table->date('create_date')->nullable();
            $table->unsignedBigInteger('billing_frequency_id')->nullable();
            $table->string('billing_frequency_repeat_status')->nullable();
            $table->unsignedBigInteger('campaign_source_id')->nullable();
            $table->decimal('total', 15, 2)->nullable();
            $table->decimal('discount', 15, 2)->nullable();
            $table->decimal('tax', 15, 2)->nullable();
            $table->decimal('grand_total', 15, 2)->nullable();
            $table->enum('status', ['active', 'inactive', 'archived'])->default('active')->nullable();
            $table->timestamps();
        });
    }

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