<?php

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

class CreateAbChargeTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_charge', 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->boolean('active')->nullable();
			$table->boolean('processed')->nullable();
			$table->integer('sweep_type')->nullable();
			$table->integer('type')->nullable();
			$table->bigInteger('account_id')->default(0);
			$table->bigInteger('product_id')->nullable();
			$table->bigInteger('service_id')->nullable();
			$table->bigInteger('date_charge')->nullable();
			$table->float('amount', 10, 0)->nullable();
			$table->float('quantity', 10, 0)->nullable();
			$table->boolean('taxable')->nullable();
			$table->binary('attributes', 65535)->nullable();
			$table->string('description', 128)->nullable();
			$table->primary(['id','site_id','account_id']);
			$table->index(['account_id','site_id'], 'fk_chg_acc_idx');
			$table->index(['service_id','site_id'], 'fk_chg_svc_idx');
			$table->index(['product_id','site_id'], 'fk_chg_pdt_idx');
		});
	}


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

}
