<?php

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

class CreateAbServiceDomainTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_service__domain', function(Blueprint $table)
		{
			$table->bigInteger('id')->default(0);
			$table->integer('site_id')->default(0);
			$table->bigInteger('service_id')->default(0);
			$table->integer('domain_tld_id')->default(0);
			$table->integer('domain_registrar_id')->default(0);
			$table->string('domain_name', 128)->nullable();
			$table->bigInteger('domain_expire')->nullable();
			$table->string('registrar_type', 16)->nullable();
			$table->string('registrar_username', 128)->nullable();
			$table->string('registrar_password', 128)->nullable();
			$table->string('registrar_auth_password', 128)->nullable();
			$table->string('registrar_pending_transfer', 16)->nullable();
			$table->string('registrar_ns', 1024)->nullable();
			$table->bigInteger('registrar_lastsync')->nullable();
			$table->primary(['id','site_id','service_id','domain_tld_id','domain_registrar_id'],'pk_unique');
			$table->unique(['id','site_id'], 'UNIQUE');
			$table->index(['service_id','site_id'], 'fk_sd_svc_idx');
			$table->index(['domain_registrar_id','site_id'], 'fk_sd_hrp_idx');
			$table->index(['domain_tld_id','site_id'], 'fk_sd_ht_idx');
		});
	}


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

}
