<?php

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

class CreateAbAdslSupplierPlanTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_adsl_supplier_plan', function(Blueprint $table)
		{
			$table->bigInteger('id')->default(0);
			$table->integer('site_id')->default(0);
			$table->bigInteger('date_orig')->nullable();
			$table->bigInteger('date_last')->nullable();
			$table->boolean('active')->nullable();
			$table->integer('supplier_id')->default(0);
			$table->string('product_id', 16)->nullable();
			$table->string('product_desc', 128)->nullable();
			$table->float('base_cost', 10, 0)->nullable();
			$table->float('setup_cost', 10, 0)->nullable();
			$table->integer('contract_term')->nullable();
			$table->float('base_down_peak', 10, 0)->nullable();
			$table->float('base_up_peak', 10, 0)->nullable();
			$table->float('base_down_offpeak', 10, 0)->nullable();
			$table->float('base_up_offpeak', 10, 0)->nullable();
			$table->boolean('extra_charged')->nullable();
			$table->string('extra_shaped', 8)->nullable();
			$table->bigInteger('offpeak_start')->nullable();
			$table->bigInteger('offpeak_end')->nullable();
			$table->float('extra_down_peak', 10, 0)->nullable();
			$table->float('extra_up_peak', 10, 0)->nullable();
			$table->float('extra_down_offpeak', 10, 0)->nullable();
			$table->float('extra_up_offpeak', 10, 0)->nullable();
			$table->float('metric', 10, 0)->default(0);
			$table->string('speed', 64)->nullable();
			$table->primary(['id','site_id','supplier_id']);
			$table->index(['supplier_id','site_id'], 'fk_asp_as_idx');
		});
	}


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

}
