<?php

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

class CreateRoadMaintenanceProjectHistoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('road_maintenance_project_histories', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('project_id');
            $table->foreign('project_id')
                ->references('id')
                ->on('road_maintenance_projects');
            $table->unsignedInteger('user_id');
            $table->foreign('user_id')
                ->references('id')
                ->on('users');
            $table->string('previous_axis_name')->nullable();
            $table->unsignedTinyInteger('previous_axis_type')->nullable();
            $table->string('previous_project_name')->nullable();
            $table->json('previous_cities_id')->nullable();
            $table->string('previous_contractor_name')->nullable();
            $table->string('previous_consultant_name')->nullable();
            $table->string('previous_contract_date')->nullable();
            $table->string('previous_contract_credit')->nullable();
            $table->string('previous_start_latlng')->nullable();
            $table->string('previous_end_latlng')->nullable();
            $table->string('previous_team_latlng')->nullable();
            $table->string('previous_stop_reason')->nullable();
            $table->timestamp('previous_submited_at', 0)->nullable();
            $table->timestamp('previous_last_updated_at', 0)->nullable();
            $table->json('previous_project_distance')->nullable();
            $table->json('previous_project_distance_update')->nullable();
            $table->string('previous_contractor_credit')->nullable();
            $table->string('previous_physical_progress')->nullable();
            $table->text('previous_description')->nullable();
            $table->boolean('previous_status')->default(0);
            $table->boolean('previous_project_status')->default(0);
            $table->text('new_files')->nullable();
            $table->timestamps();
        });
    }

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