<?php

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

class CreateAbPivotProductCatTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_pivot_product_cat', function(Blueprint $table)
		{
			$table->bigInteger('id', false);
			$table->integer('site_id');
			$table->bigInteger('product_id')->nullable();
			$table->integer('product_cat_id')->nullable();
			$table->primary(['id','site_id']);
			$table->unique(['site_id','product_id','product_cat_id']);
			$table->index(['product_cat_id','site_id']);
			$table->index(['product_id','site_id']);
		});
	}


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

}
