<?php

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

class CreateWorkOrderVisitsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('work_order_visits', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
			$table->softDeletes();
			$table->integer('company_id')->unsigned();
			$table->foreign('company_id')->references('id')->on('companies');
			$table->integer('work_order_id')->unsigned();
			$table->foreign('work_order_id')->references('id')->on('work_orders');
			$table->date('date');
			$table->time('start_time')->default('00:00:00');
			$table->time('end_time')->default('00:00:00');
			$table->integer('status')->default(-1);
			$table->tinyInteger('was_filter_cleaned')->default(0);
			$table->tinyInteger('finished')->default(0);
			$table->text('technical_information')->nullable();
			$table->text('chemicals')->nullable();
			$table->text('notes_to_customer')->nullable();
			$table->text('other_notes')->nullable();
			$table->integer('visit_order')->default(0);
			$table->tinyInteger('billing')->default(1);
			$table->integer('invoice_id')->unsigned();
			$table->foreign('invoice_id')->references('id')->on('invoices');
			$table->string('hash')->unique()->nullable();
        });
    }

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