<?php

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

class CreatePromotionUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('promotion_users', function (Blueprint $table) {

            $table->increments('id');
            $table->unsignedInteger('promotion_admin_id')->index();
            $table->unsignedInteger('user_id');

            $table->string('name', 255);
            $table->text('description')->nullable();
            $table->text('about_you')->nullable();

            $table->string('internal_name', 255);
            $table->text('internal_description')->nullable();

            $table->string('url', 255)->nullable();

            $table->boolean('pick_up')->default(true);
            $table->text('user_address')->nullable();

            $table->decimal('used_budget_total', 13, 2)->nullable();
            $table->unsignedSmallInteger('sell_items_total')->nullable();

            $table->boolean('active')->default(false);

            $table->timestamp('user_deleted_at')->nullable();

            $table->timestamps();

            $table->foreign('promotion_admin_id')
            ->references('id')
            ->on('promotion_admins');   

            $table->foreign('user_id')
            ->references('id')
            ->on('users');
        });
    }

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