<?php

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

class CreateBoxBoxSettingsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('box_box_settings', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('box_id');
            $table->unsignedBigInteger('box_setting_id');
            $table->string('value');
            $table->timestamps();

            $table->unique(["box_id", "box_setting_id"]);

            $table->foreign('box_id')->references('id')->on('boxes')->onDelete("cascade");
            $table->foreign('box_setting_id')->references('id')->on('box_settings')->onDelete("restrict");
        });
    }

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