<?php

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

class CreateAbServiceAdslTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_service__adsl', function(Blueprint $table)
		{
			$table->bigInteger('id')->default(0);
			$table->integer('site_id')->default(0);
			$table->bigInteger('service_id')->default(0);
			$table->bigInteger('provided_adsl_plan_id')->nullable();
			$table->string('service_number', 10)->default('')->index('fk_service_number');
			$table->string('service_address', 128)->nullable();
			$table->integer('contract_term')->nullable();
			$table->bigInteger('service_connect_date')->nullable();
			$table->bigInteger('service_contract_date')->nullable();
			$table->string('service_username', 128)->nullable()->unique('uq_service_username');
			$table->string('service_password', 16)->nullable();
			$table->boolean('service_stats_collect')->nullable();
			$table->date('service_stats_lastupdate')->nullable();
			$table->string('ipaddress', 45)->nullable();
			$table->time('offpeak_start')->nullable();
			$table->time('offpeak_end')->nullable();
			$table->primary(['id','site_id','service_id']);
			$table->unique(['id','site_id'], 'UNIQUE');
			$table->index(['service_id','site_id'], 'fk_sa_svc_idx');
			$table->index(['provided_adsl_plan_id','site_id'], 'fk_sa_ap_idx');
		});
	}


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

}
