<?php

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

class CreateAbAffiliateTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('ab_affiliate', 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->bigInteger('account_id')->default(0);
			$table->text('avail_campaign_id')->nullable();
			$table->string('affiliate_plugin', 32)->nullable();
			$table->string('parent_affiliate_id', 16)->nullable();
			$table->integer('max_tiers')->nullable();
			$table->float('commission_minimum', 10, 0)->nullable();
			$table->boolean('new_commission_type')->nullable();
			$table->text('new_commission_rate')->nullable();
			$table->boolean('recurr_commission_type')->nullable();
			$table->text('recurr_commission_rate')->nullable();
			$table->integer('recurr_max_commission_periods')->nullable();
			$table->text('plugin_data')->nullable();
			$table->primary(['id','site_id','account_id']);
			$table->index(['account_id','site_id']);
		});
	}


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

}
