<?php

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

class CreateFlagNode extends Migration
{
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::dropIfExists('flag_node');
		Schema::create('flag_node', function (Blueprint $table) {
			$table->integer('flag_id');
			$table->integer('node_id');
			$table->string('arguments')->nullable();

			$table->index('node_id');
			$table->index('flag_id');
			$table->unique(['node_id','flag_id']);
			$table->foreign('node_id')->references('id')->on('nodes');
			$table->foreign('flag_id')->references('id')->on('flags');
		});
	}

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