<?php

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

class CreateDangerPointHistoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('danger_point_histories', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('point_id');
            $table->foreign('point_id')
                ->references('id')
                ->on('danger_points');
            $table->unsignedInteger('user_id');
            $table->foreign('user_id')
                ->references('id')
                ->on('users');
            $table->string('previous_code')->nullable();
            $table->string('previous_axis_name')->nullable();
            $table->unsignedTinyInteger('previous_axis_type')->nullable();
            $table->string('previous_axis_start')->nullable();
            $table->string('previous_axis_end')->nullable();
            $table->string('previous_distance_axis_start')->nullable();
            $table->string('previous_local_name')->nullable();
            $table->string('previous_lat')->nullable();
            $table->string('previous_lng')->nullable();
            $table->boolean('previous_accident_251')->nullable();
            $table->string('previous_accident_251_code')->nullable();
            $table->string('previous_speed_limit')->nullable();
            $table->string('previous_speed_average')->nullable();
            $table->boolean('previous_accident_possibility')->nullable();
            $table->boolean('previous_road_guard')->nullable();
            $table->unsignedTinyInteger('previous_geometric_desc')->nullable();
            $table->string('previous_accident_cause')->nullable();
            $table->text('previous_accident_cause_suggest')->nullable();
            $table->string('previous_accident_severity')->nullable();
            $table->text('previous_accident_severity_suggest')->nullable();
            $table->text('previous_correction_plan_done')->nullable();
            $table->text('previous_correction_plan_doing')->nullable();
            $table->text('previous_correction_plan_doing_desc')->nullable();
            $table->text('previous_correction_plan_doing_suggest')->nullable();
            $table->string('previous_signature_file')->nullable();
            $table->string('previous_police_file')->nullable();
            $table->boolean('previous_status')->nullable();
            $table->text('previous_status_desc')->nullable();
            $table->text('new_files')->nullable();
            $table->timestamps();
        });
    }

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