<?php

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

class CreateAbDiscountTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_discount', function(Blueprint $table)
		{
			$table->bigInteger('id')->nullable();
			$table->integer('site_id')->nullable();
			$table->bigInteger('date_orig')->nullable();
			$table->boolean('active')->nullable()->index();
			$table->bigInteger('date_start')->nullable()->index();
			$table->bigInteger('date_expire')->nullable()->index();
			$table->string('name', 64)->nullable();
			$table->text('notes')->nullable();
			$table->integer('max_usage_account')->nullable();
			$table->integer('max_usage_global')->nullable();
			$table->bigInteger('avail_account_id')->nullable();
			$table->text('avail_product_id')->nullable();
			$table->text('avail_group_id')->nullable();
			$table->text('avail_tld_id')->nullable();
			$table->boolean('new_status')->nullable();
			$table->boolean('new_type')->nullable();
			$table->float('new_rate', 10, 0)->nullable();
			$table->float('new_max_discount', 10, 0)->nullable();
			$table->float('new_min_cost', 10, 0)->nullable();
			$table->boolean('recurr_status')->nullable();
			$table->boolean('recurr_type')->nullable();
			$table->float('recurr_rate', 10, 0)->nullable();
			$table->float('recurr_max_discount', 10, 0)->nullable();
			$table->float('recurr_min_cost', 10, 0)->nullable();
			$table->unique(['site_id','id']);
		});
	}


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

}
