<?php

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

/**
 * Migration auto-generated by Sequel Pro Laravel Export (1.4.1)
 * @see https://github.com/cviebrock/sequel-pro-laravel-export
 */
class CreateArrangementTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('arrangement', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('template_id')->nullable();
            $table->date('state')->nullable();
            $table->date('begin')->nullable();
            $table->date('end')->nullable();
            $table->string('type_s', 80)->nullable();
            $table->text('data_s')->nullable();
            $table->bigInteger('view_position')->nullable();
            $table->bigInteger('booking_id')->nullable();
            $table->bigInteger('type_id');
            $table->tinyInteger('in_pdf')->nullable()->default(0);

            $table->index('template_id', 'arrangement_template_id_idx');
            $table->index('booking_id', 'arrangement_booking_id_idx');

            $table->foreign('booking_id', 'arrangement_booking_id_booking_id')->references('id')->on('booking')->onDelete('CASCADE
')->onUpdate('RESTRICT');
            $table->foreign('template_id', 'arrangement_template_id_arrangement_template_id')->references('id')->on('arrangement_template')->onDelete('CASCADE
')->onUpdate('RESTRICT');

        });



    }

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