<?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('availabilities', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('worker_id')->index();
            $table->bigInteger('company_id')->index();
            $table->enum('worker_type', ['borrowed', 'inhouse']);
            $table->decimal('rate', 10, 2)->comment = 'Hard copy of worker rate';
            $table->date('min_availability_date');
            $table->date('max_availability_date');
            $table->bigInteger('fallback_reference_id')->nullable()->index();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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