<?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('contracts', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->double('paid_amount');
            $table->double('amount');
            $table->foreignId('project_id')->nullable()->constrained()->restrictOnUpdate()->restrictOnDelete();
            $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete()->cascadeOnUpdate();
            $table->foreignId("proposal_id")->nullable()->constrained()->restrictOnUpdate()->restrictOnDelete();
            $table->unsignedBigInteger('contractor_id');
            $table->string('contractor_type');
            $table->timestamp('contractor_signed_at')->nullable();
            $table->timestamp('user_signed_at')->nullable();
            $table->timestamp('start_date')->nullable();
            $table->timestamp('due_date')->nullable();
            $table->string('contractor_signature')->nullable();
            $table->string('client_signature')->nullable();
            $table->enum('status',['Active', 'Closed', 'Canceled'])->default('Active');
            $table->softDeletes();
        });
    }

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