<?php

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

class CreateAbAccountTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_account', function(Blueprint $table)
		{
			$table->bigInteger('id')->default(0);
			$table->integer('site_id')->default(0)->index('fk_acc_set_idx');
			$table->bigInteger('date_orig')->nullable();
			$table->bigInteger('date_last')->nullable();
			$table->bigInteger('date_expire')->nullable();
			$table->integer('language_id')->index('fk_acc_lan_idx');
			$table->integer('country_id')->index('fk_acc_cty_idx');
			$table->bigInteger('rtm_id')->nullable();
			$table->integer('currency_id')->index('fk_acc_cur_idx');
			$table->string('username', 128)->nullable();
			$table->string('password', 128)->nullable();
			$table->boolean('active')->nullable();
			$table->string('first_name', 128)->nullable();
			$table->string('last_name', 128)->nullable();
			$table->string('title', 128)->nullable();
			$table->string('email')->nullable();
			$table->string('company')->nullable();
			$table->string('address1', 128)->nullable();
			$table->string('address2', 128)->nullable();
			$table->string('city', 32)->nullable();
			$table->string('state', 32)->nullable();
			$table->string('zip', 16)->nullable();
			$table->boolean('email_type')->nullable();
			$table->integer('invoice_delivery')->nullable();
			$table->string('mail_type')->nullable();
			$table->primary(['id','site_id']);
			$table->unique(['site_id','username'], 'uq_username');
			$table->index(['rtm_id','site_id'], 'fk_acc_rtm_idx');
		});
	}


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

}
