<?php

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

class CreateDangerPointsTable 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');
            $table->foreign('user_id')
                ->references('id')
                ->on('users');
            $table->unsignedTinyInteger('province_id')->nullable();
            $table->foreign('province_id')
                ->references('id')
                ->on('provinces');
            $table->unsignedSmallInteger('city_id')->nullable();
            $table->foreign('city_id')
                ->references('id')
                ->on('cities');
            $table->string('axis_name')->nullable();
            $table->unsignedTinyInteger('axis_type')->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(0);
            $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('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(0);
            $table->text('status_desc')->nullable();
            $table->timestamps();
        });
    }

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