<?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('assigned_availability', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('availability_id')->index();
            $table->bigInteger('assigned_worker_id')->index();
            $table->enum('worker_type', ['borrowed', 'inhouse']);
            $table->decimal('rate', 10, 2)->comment = 'Hard copy of worker rate';
            $table->longText('conflict_data')->nullable()->comment = 'JSON format {[{action:(number,string), array(object)]}';
            $table->date('start_date');
            $table->date('end_date');
            $table->boolean('is_draft')->default('1');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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