<?php

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

class CreateVehiclesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('vehicles', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('fire_station_id')->unsigned();
            $table->foreign('fire_station_id')->references('id')->on('fire_stations')->onDelete('cascade');
            $table->string('name');
            $table->string('codename');
            $table->string('brand')->nullable();
            $table->string('registration_number', 20)->nullable();
            $table->integer('production_year')->nullable();         
            $table->date('exam_expiration_date')->nullable(); //Data ważności przegladu
            $table->date('insurance_expiration_date')->nullable();
            $table->string('drive_type')->nullable(); //układ napędowy
            $table->string('chassis_type')->nullable();   //typ podwozia
            $table->string('body_producer')->nullable();  //producent nadwozia
            $table->integer('crew_number')->nullable();
            $table->integer('foam_agent')->nullable();  //Ilość środka pianotwórczego w litrach
            $table->integer('engine_power')->nullable();  //Moc silnika w kW
            $table->integer('mass')->nullable();  //Masa całkowita pojazdu
            $table->string('chassis_number')->nullable();
            $table->string('engine_number')->nullable();
            $table->string('fuel_type')->nullable();
            $table->integer('chassis_poduction_year')->nullable();
            $table->date('entry_into_service_date')->nullable();
            $table->string('fire_engine_pump_description')->nullable();// Opis autopompy
            $table->integer('status')->default('0');
            $table->integer('editor_id')->nullable()->default(null);
            $table->timestamps();
            $table->softDeletes();
        });
    }

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