<?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('road_items_projects', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('user_id')->nullable()->index('road_items_projects_user_id_foreign');
            $table->decimal('start_lat', 12, 10)->index('start_lat');
            $table->decimal('start_lng', 12, 10)->index('start_lng');
            $table->decimal('end_lat', 12, 10)->nullable();
            $table->decimal('end_lng', 12, 10)->nullable();
            $table->string('project_distance')->nullable();
            $table->unsignedTinyInteger('item');//->index('item');
            $table->string('item_fa')->nullable();
            $table->integer('sub_item')->nullable();
            $table->string('sub_item_fa')->nullable();
            $table->longText('sub_item_data')->nullable();
            $table->string('sub_items');
            $table->longText('sub_items_data')->nullable();
            $table->timestamps();
            $table->unsignedTinyInteger('province_id');
            $table->string('province_fa')->nullable();
            $table->bigInteger('city_id');
            $table->string('city_fa')->nullable();
            $table->boolean('is_new')->default(false)->index('road_items_projects_is_new_idx');
            $table->bigInteger('parent_id')->nullable()->default(0);
            $table->bigInteger('start_way_id')->nullable();
            $table->bigInteger('end_way_id')->nullable();
            $table->string('unit_fa')->nullable();
            $table->string('user_name');
            $table->string('created_at_fa')->nullable();
            $table->integer('info_id')->nullable();
            $table->unsignedSmallInteger('status')->nullable()->index('temp');
            $table->string('status_fa', 100)->nullable();
            $table->integer('edarat_id')->nullable();
            $table->string('edarat_name', 100)->nullable();
            $table->string('edarat_type', 100)->nullable();
            $table->date('activity_date')->nullable();
            $table->time('activity_time')->nullable();
            $table->dateTime('activity_date_time')->nullable()->index('times');
            $table->integer('supervisor_id')->nullable();
            $table->string('supervisor_name')->nullable();
            $table->text('supervisor_description')->nullable();
            $table->timestamp('supervising_time')->nullable();

            $table->index(['user_id', 'province_id'], 'province');
        });
    }

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