<?php

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

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('equip_works', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('equip_id')->unsigned()   
            ->nullable();
            $table->date('date');
            $table->bigInteger('land_id')->unsigned()
            ->nullable();
            $table->double('hours_count');
            $table->double('hour_price');
            $table->decimal('total');
            $table->timestamp('created_at')->nullable();
            $table->timestamp('updated_at')->nullable();

            $table
                ->foreign('equip_id')
                ->references('id')
                ->on('equips')
                ->onDelete('cascade')
                ->onUpdate('cascade');
            $table
                ->foreign('land_id')
                ->references('id')
                ->on('lands')
                ->onDelete('cascade')
                ->onUpdate('cascade');
        });
    }

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