<?php

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

class CreateAbServiceHostingTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_service__hosting', 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('host_server_id')->default(0);
			$table->string('domain_name', 128)->nullable();
			$table->bigInteger('host_expire')->nullable();
			$table->string('host_type', 16)->nullable();
			$table->string('host_username', 45)->nullable();
			$table->string('host_password', 45)->nullable();
			$table->string('ftp_username', 16)->nullable();
			$table->string('ftp_password', 16)->nullable();
			$table->binary('server_data', 65535)->nullable();
			$table->text('server_data_date', 65535)->nullable();
			$table->primary(['id','site_id','service_id','domain_tld_id','host_server_id'],'pk_unique');
			$table->unique(['id','site_id'], 'UNIQUE');
			$table->unique(['host_server_id','ftp_username'], 'uq_ftp_username');
			$table->index(['service_id','site_id'], 'fk_service_id');
			$table->index(['domain_tld_id','site_id'], 'fk_domain_tld_id');
			$table->index(['host_server_id','site_id'], 'fk_sh_hs_idx');
		});
	}


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

}
