<?php

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

class CreateEntryDownload extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('entry_download', function(Blueprint $table)
		{
			$table->unsignedInteger('entry_id');
			$table->unsignedInteger('archive_id');
			$table->unsignedInteger('position');
			$table->primary(['entry_id','archive_id']);
			$table->foreign('entry_id')
				->references('id')->on('entries')
				->onDelete('cascade');
			$table->foreign('archive_id')
				->references('id')->on('archives')
				->onDelete('cascade');
		});
	}

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

}
