<?php

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

class CreateAbServiceChangeTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_service_change', function(Blueprint $table)
		{
			$table->bigInteger('id');
			$table->integer('site_id');
			$table->bigInteger('service_id');
			$table->bigInteger('product_id');
			$table->bigInteger('ordered_by');
			$table->bigInteger('date_ordered')->nullable();
			$table->bigInteger('date_effective')->nullable();
			$table->boolean('active')->nullable();
			$table->boolean('complete')->nullable();
			$table->primary(['id','site_id','service_id','product_id','ordered_by'],'pk_unique');
			$table->index(['site_id','id'], 'fk_s_sc_idx');
			$table->index(['site_id','product_id'], 'fk_s_p_idx');
			$table->index(['site_id','ordered_by'], 'fk_sc_a_idx');
		});
	}


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

}
