<?php

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

/**
 * Migration auto-generated by Sequel Pro Laravel Export (1.4.1)
 * @see https://github.com/cviebrock/sequel-pro-laravel-export
 */
class CreateLeadTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('lead', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('customer_id');
            $table->date('request_date');
            $table->date('travelperiod_start')->nullable();
            $table->date('travelperiod_end')->nullable();
            $table->bigInteger('travelperiod_length')->nullable();
            $table->bigInteger('travelcountry_id')->nullable();
            $table->bigInteger('travelagenda_id')->nullable();
            $table->text('remarks')->nullable();
            $table->integer('sf_guard_user_id');
            $table->tinyInteger('is_closed')->nullable()->default(0);
            $table->bigInteger('initialcontacttype_id')->nullable();
            $table->bigInteger('searchengine_id')->nullable();
            $table->string('searchengine_keywords', 80)->nullable();
            $table->bigInteger('status_id');
            $table->date('next_due_date')->nullable();
            $table->bigInteger('website_id')->nullable();
            $table->bigInteger('travelcategory_id')->nullable();
            $table->dateTime('created_at');
            $table->dateTime('updated_at');
            $table->decimal('price', 10, 2)->nullable();
            $table->bigInteger('pax')->nullable();
            $table->string('participant_name', 80)->nullable();
            $table->string('participant_firstname', 80)->nullable();
            $table->date('participant_birthdate')->nullable();
            $table->bigInteger('participant_salutation_id')->nullable();

            $table->index('initialcontacttype_id', 'initialcontacttype_id_idx');
            $table->index('searchengine_id', 'searchengine_id_idx');
            $table->index('status_id', 'status_id_idx');
            $table->index('travelcountry_id', 'travelcountry_id_idx');
            $table->index('travelagenda_id', 'travelagenda_id_idx');
            $table->index('sf_guard_user_id', 'sf_guard_user_id_idx');
            $table->index('website_id', 'website_id_idx');
            $table->index('travelcategory_id', 'travelcategory_id_idx');
            $table->index('customer_id', 'customer_id_idx');
            $table->index('participant_salutation_id', 'lead_participant_salutation_id_idx');

            $table->foreign('customer_id', 'lead_customer_id_customer_id')->references('id')->on('customer')->onDelete('RESTRICT
')->onUpdate('RESTRICT');
            $table->foreign('initialcontacttype_id', 'lead_initialcontacttype_id_initial_contact_type_id')->references('id')->on('initial_contact_type')->onDelete('RESTRICT
')->onUpdate('RESTRICT');
            $table->foreign('participant_salutation_id', 'lead_participant_salutation_id_salutation_id')->references('id')->on('salutation')->onDelete('RESTRICT
')->onUpdate('RESTRICT');
            $table->foreign('searchengine_id', 'lead_searchengine_id_searchengine_id')->references('id')->on('searchengine')->onDelete('RESTRICT
')->onUpdate('RESTRICT');
            $table->foreign('sf_guard_user_id', 'lead_sf_guard_user_id_sf_guard_user_id')->references('id')->on('sf_guard_user')->onDelete('RESTRICT
')->onUpdate('RESTRICT');
            $table->foreign('status_id', 'lead_status_id_status_id')->references('id')->on('status')->onDelete('RESTRICT
')->onUpdate('RESTRICT');
            $table->foreign('travelagenda_id', 'lead_travelagenda_id_travel_agenda_id')->references('id')->on('travel_agenda')->onDelete('RESTRICT
')->onUpdate('RESTRICT');
            $table->foreign('travelcategory_id', 'lead_travelcategory_id_travel_category_id')->references('id')->on('travel_category')->onDelete('RESTRICT
')->onUpdate('RESTRICT');
            $table->foreign('travelcountry_id', 'lead_travelcountry_id_travel_country_id')->references('id')->on('travel_country')->onDelete('RESTRICT
')->onUpdate('RESTRICT');
            $table->foreign('website_id', 'lead_website_id_website_id')->references('id')->on('website')->onDelete('RESTRICT
')->onUpdate('RESTRICT');

        });



    }

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