<?php

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

class CreateCustomersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customers', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
			$table->softDeletes();
			$table->integer('company_id')->unsigned();
			$table->foreign('company_id')->references('id')->on('companies');
			$table->string('account_number')->nullable();
			$table->string('name');
            $table->longText('contacts');
            $table->longText('preferences');
			$table->longText('about')->nullable();
			$table->integer('customer_source_id')->unsigned()->nullable();
			$table->foreign('customer_source_id')->references('id')->on('customer_sources');
            $table->tinyInteger('status')->default(2);
			$table->tinyInteger('recurring')->default(0);
			$table->decimal('billed', 10, 2)->default(0);
			$table->decimal('paid', 10, 2)->default(0);
			$table->decimal('balance', 10, 2)->default(0);
			$table->text('tags')->nullable();
			$table->date('leaded_at')->nullable();
			$table->date('activated_at')->nullable();
			$table->date('archived_at')->nullable();
			$table->integer('quickbooks_id')->nullable();
			$table->longText('payjunction_id')->nullable();
			$table->longText('payjunction_vault_id')->nullable();
			$table->tinyInteger('auto_payment')->default(0);
        });
    }

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