<?php

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

class CreatePackSimpleContent extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
        Schema::create('pack_simple_content', function (Blueprint $table) {
            $table->unsignedBigInteger('pack_id');
            $table->unsignedBigInteger('simple_content_id');
            $table->integer('position')->nullable();
            $table->primary(['pack_id', 'simple_content_id']);

            $table->foreign('pack_id')->references('id')
                ->on('packs')->onDelete('CASCADE')->onUpdate('CASCADE');
            $table->foreign('simple_content_id')->references('id')
                ->on('simple_contents')->onDelete('CASCADE')->onUpdate('CASCADE');
        });
	}

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

}
