<?php

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

class CreateDangerPointAccidentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('danger_point_accidents', 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('serial_number')->unique('serial_number')->nullable();
            $table->date('accident_date')->nullable();
            $table->unsignedTinyInteger('day')->nullable();
            $table->string('time')->nullable();
            $table->unsignedTinyInteger('accident_direction')->nullable();
            $table->unsignedTinyInteger('collision_type')->nullable();
            $table->json('accident_factors')->nullable();
            $table->unsignedTinyInteger('accident_type')->nullable();
            $table->json('accident_result')->nullable();
            $table->timestamps();
        });
    }

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