<?php

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

/**
 * Class CreateParentEntityClassesTable
 */
class CreatePossibleParentClassesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('possible_parent_classes', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('child_entity_class_id');
            $table->unsignedInteger('parent_entity_class_id');
            $table->boolean('parent_must_not_have_parent');

            $table->foreign('child_entity_class_id')
                ->references('id')->on('entity_classes')
                ->onUpdate('cascade')->onDelete('cascade');

            $table->foreign('parent_entity_class_id')
                ->references('id')->on('entity_classes')
                ->onUpdate('cascade')->onDelete('cascade');

        });
    }

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