<?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('danger_points', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('code')->nullable();
            $table->unsignedInteger('user_id')->nullable()->index('danger_points_user_id_foreign');
            $table->unsignedTinyInteger('province_id')->nullable()->index('danger_points_province_id_foreign');
            $table->string('province_fa')->nullable();
            $table->unsignedSmallInteger('city_id')->nullable()->index('danger_points_city_id_foreign');
            $table->string('city_fa')->nullable();
            $table->string('axis_name')->nullable();
            $table->unsignedTinyInteger('axis_type')->nullable();
            $table->string('axis_type_fa')->nullable();
            $table->string('axis_start')->nullable();
            $table->string('axis_end')->nullable();
            $table->string('distance_axis_start')->nullable();
            $table->string('local_name')->nullable();
            $table->string('lat')->nullable();
            $table->string('lng')->nullable();
            $table->boolean('accident_251')->default(false);
            $table->string('accident_251_code')->nullable();
            $table->string('speed_limit')->nullable();
            $table->string('speed_average')->nullable();
            $table->boolean('accident_possibility')->nullable();
            $table->boolean('road_guard')->nullable();
            $table->unsignedTinyInteger('geometric_desc')->nullable();
            $table->string('geometric_desc_fa')->nullable();
            $table->string('accident_cause')->nullable();
            $table->text('accident_cause_suggest')->nullable();
            $table->string('accident_severity')->nullable();
            $table->text('accident_severity_suggest')->nullable();
            $table->text('correction_plan_done')->nullable();
            $table->text('correction_plan_doing')->nullable();
            $table->text('correction_plan_doing_desc')->nullable();
            $table->text('correction_plan_doing_suggest')->nullable();
            $table->string('signature_file')->nullable();
            $table->string('police_file')->nullable();
            $table->boolean('status')->default(false);
            $table->text('status_desc')->nullable();
            $table->tinyInteger('accident_result_de')->nullable();
            $table->tinyInteger('accident_result_in')->nullable();
            $table->double('weighted_average', null, 0)->nullable();
            $table->double('accident_zi', null, 0)->nullable();
            $table->double('accident_p', null, 0)->nullable();
            $table->double('accident_avg_weighted_average', null, 0)->nullable();
            $table->double('standard_deviation', null, 0)->nullable();
            $table->double('accident_sigma', null, 0)->nullable();
            $table->double('accident_sigma_2', null, 0)->nullable();
            $table->timestamps();
            $table->string('n_axis_type_fa')->nullable();
            $table->string('n_geometric_desc_fa')->nullable();
        });
    }

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