<?php

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

class CreateWorkOrderSchedulesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('work_order_schedules', 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('start_date');
			$table->time('start_time')->nullable();
			$table->date('end_date')->nullable();
			$table->time('end_time')->nullable();
			$table->string('frequency');
			$table->integer('count')->nullable();
			$table->integer('interval')->default(1);
			$table->text('byday')->nullable();
			$table->text('bymonthday')->nullable();
        });
    }

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