<?php

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

class CreateAbAdslPlanTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_adsl_plan', function(Blueprint $table)
		{
			$table->bigInteger('id')->default(0);
			$table->integer('site_id')->default(0);
			$table->bigInteger('adsl_supplier_plan_id')->default(0);
			$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->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->primary(['id','site_id','adsl_supplier_plan_id']);
			$table->index(['adsl_supplier_plan_id','site_id'], 'fk_ap_asp_idx');
		});
	}


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

}
