<?php

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

class CreateAbAccountOauthTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_account_oauth', function(Blueprint $table)
		{
			$table->bigInteger('id');
			$table->integer('site_id');
			$table->bigInteger('date_orig')->nullable();
			$table->bigInteger('date_last')->nullable();
			$table->bigInteger('account_id');
			$table->integer('oauth_id');
			$table->string('userid', 128);
			$table->binary('oauth_data', 65535)->nullable();
			$table->primary(['id','site_id','account_id','oauth_id']);
			$table->unique(['site_id','account_id','oauth_id'], 'UNIQUE');
			$table->index(['oauth_id','site_id'], 'fk_ao_o_idx');
			$table->index(['account_id','site_id'], 'fk_ao_a_idx');
		});
	}


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

}
