<?php

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

class CreateAbPaymentTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_payment', function(Blueprint $table)
		{
			$table->bigInteger('id')->default(0);
			$table->integer('site_id')->default(0);
			$table->bigInteger('date_orig')->nullable();
			$table->bigInteger('date_last')->nullable();
			$table->bigInteger('account_id')->default(0);
			$table->bigInteger('date_payment')->nullable();
			$table->integer('checkout_id')->default(0);
			$table->string('checkout_data')->nullable();
			$table->float('total_amt', 10, 0)->nullable();
			$table->float('fees_amt', 10, 0)->nullable();
			$table->bigInteger('source_id')->nullable();
			$table->boolean('pending_status')->nullable();
			$table->text('notes', 65535)->nullable();
			$table->string('ip', 32)->nullable();
			$table->primary(['id','checkout_id','account_id','site_id']);
			$table->unique(['id','site_id'], 'UNIQUE');
			$table->index(['account_id','site_id'], 'fk_pay_acc_idx');
			$table->index(['checkout_id','site_id'], 'fk_pay_cp_idx');
			$table->index(['source_id','site_id'], 'fk_pay_acc_b_idx');
		});
	}


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

}
