<?php

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

class CreateBlockProjectDetailTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('block_project_detail', function (Blueprint $table) {
            $table->unsignedBigInteger('project_detail_id');
            $table->unsignedBigInteger('block_id');
            $table->unsignedInteger('position')->nullable();
            $table->foreign('project_detail_id')->references('id')
                ->on('project_details')->onDelete('CASCADE')->onUpdate('CASCADE');
            $table->foreign('block_id')->references('id')
                ->on('blocks')->onDelete('CASCADE')->onUpdate('CASCADE');
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('block_project_detail');
    }
}
