<?php

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

class CreateGroupUserTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('group_user', function(Blueprint $table)
		{
			$table->unsignedBigInteger('group_id');
			$table->unsignedBigInteger('user_id');
			$table->timestamps();

			// Composite Primary KEY
			$table->primary(array('group_id', 'user_id'));

			// Foreign keys
			// $table->foreign('user_id')->references('id')->on('users')->on_delete('cascade');
			// $table->foreign('user_id')->references('id')->on('users')->on_update('cascade');

			// $table->foreign('group_id')->references('id')->on('groups')->on_delete('cascade');
			// $table->foreign('group_id')->references('id')->on('groups')->on_update('cascade');
		});
	}

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

}
